Revision: 24893
Author: [email protected]
Date: Mon Oct 27 09:02:49 2014 UTC
Log: pass isolate to Value::To* functions
BUG=
[email protected]
Review URL: https://codereview.chromium.org/669373002
https://code.google.com/p/v8/source/detail?r=24893
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/d8-debug.cc
/branches/bleeding_edge/src/d8.cc
/branches/bleeding_edge/src/extensions/statistics-extension.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Tue Oct 21 17:21:32 2014 UTC
+++ /branches/bleeding_edge/include/v8.h Mon Oct 27 09:02:49 2014 UTC
@@ -1703,14 +1703,24 @@
*/
bool IsDataView() const;
- Local<Boolean> ToBoolean() const;
- Local<Number> ToNumber() const;
- Local<String> ToString() const;
- Local<String> ToDetailString() const;
- Local<Object> ToObject() const;
- Local<Integer> ToInteger() const;
- Local<Uint32> ToUint32() const;
- Local<Int32> ToInt32() const;
+ Local<Boolean> ToBoolean(Isolate* isolate) const;
+ Local<Number> ToNumber(Isolate* isolate) const;
+ Local<String> ToString(Isolate* isolate) const;
+ Local<String> ToDetailString(Isolate* isolate) const;
+ Local<Object> ToObject(Isolate* isolate) const;
+ Local<Integer> ToInteger(Isolate* isolate) const;
+ Local<Uint32> ToUint32(Isolate* isolate) const;
+ Local<Int32> ToInt32(Isolate* isolate) const;
+
+ // TODO(dcarney): deprecate all these.
+ inline Local<Boolean> ToBoolean() const;
+ inline Local<Number> ToNumber() const;
+ inline Local<String> ToString() const;
+ inline Local<String> ToDetailString() const;
+ inline Local<Object> ToObject() const;
+ inline Local<Integer> ToInteger() const;
+ inline Local<Uint32> ToUint32() const;
+ inline Local<Int32> ToInt32() const;
/**
* Attempts to convert a string to an array index.
@@ -6636,6 +6646,44 @@
template <class T> Value* Value::Cast(T* value) {
return static_cast<Value*>(value);
}
+
+
+Local<Boolean> Value::ToBoolean() const {
+ return ToBoolean(Isolate::GetCurrent());
+}
+
+
+Local<Number> Value::ToNumber() const {
+ return ToNumber(Isolate::GetCurrent());
+}
+
+
+Local<String> Value::ToString() const {
+ return ToString(Isolate::GetCurrent());
+}
+
+
+Local<String> Value::ToDetailString() const {
+ return ToDetailString(Isolate::GetCurrent());
+}
+
+
+Local<Object> Value::ToObject() const {
+ return ToObject(Isolate::GetCurrent());
+}
+
+
+Local<Integer> Value::ToInteger() const {
+ return ToInteger(Isolate::GetCurrent());
+}
+
+
+Local<Uint32> Value::ToUint32() const {
+ return ToUint32(Isolate::GetCurrent());
+}
+
+
+Local<Int32> Value::ToInt32() const { return
ToInt32(Isolate::GetCurrent()); }
Name* Name::Cast(v8::Value* value) {
=======================================
--- /branches/bleeding_edge/src/api.cc Tue Oct 21 17:21:32 2014 UTC
+++ /branches/bleeding_edge/src/api.cc Mon Oct 27 09:02:49 2014 UTC
@@ -2580,13 +2580,13 @@
}
-Local<String> Value::ToString() const {
+Local<String> Value::ToString(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> str;
if (obj->IsString()) {
str = obj;
} else {
- i::Isolate* isolate = i::Isolate::Current();
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToString");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
@@ -2598,13 +2598,13 @@
}
-Local<String> Value::ToDetailString() const {
+Local<String> Value::ToDetailString(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> str;
if (obj->IsString()) {
str = obj;
} else {
- i::Isolate* isolate = i::Isolate::Current();
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToDetailString");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
@@ -2616,13 +2616,13 @@
}
-Local<v8::Object> Value::ToObject() const {
+Local<v8::Object> Value::ToObject(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> val;
if (obj->IsJSObject()) {
val = obj;
} else {
- i::Isolate* isolate = i::Isolate::Current();
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToObject");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
@@ -2634,12 +2634,12 @@
}
-Local<Boolean> Value::ToBoolean() const {
+Local<Boolean> Value::ToBoolean(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
if (obj->IsBoolean()) {
return ToApiHandle<Boolean>(obj);
} else {
- i::Isolate* isolate = i::Isolate::Current();
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToBoolean");
ENTER_V8(isolate);
i::Handle<i::Object> val =
@@ -2649,13 +2649,13 @@
}
-Local<Number> Value::ToNumber() const {
+Local<Number> Value::ToNumber(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> num;
if (obj->IsNumber()) {
num = obj;
} else {
- i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToNumber");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
@@ -2667,13 +2667,13 @@
}
-Local<Integer> Value::ToInteger() const {
+Local<Integer> Value::ToInteger(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> num;
if (obj->IsSmi()) {
num = obj;
} else {
- i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToInteger");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
@@ -2935,13 +2935,13 @@
}
-Local<Int32> Value::ToInt32() const {
+Local<Int32> Value::ToInt32(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> num;
if (obj->IsSmi()) {
num = obj;
} else {
- i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToInt32");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
@@ -2952,13 +2952,13 @@
}
-Local<Uint32> Value::ToUint32() const {
+Local<Uint32> Value::ToUint32(Isolate* v8_isolate) const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::Object> num;
if (obj->IsSmi()) {
num = obj;
} else {
- i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "ToUInt32");
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
@@ -6916,7 +6916,7 @@
ENTER_V8(isolate);
i::HandleScope scope(isolate);
TryCatch try_catch;
- Handle<String> str = obj->ToString();
+ Handle<String> str =
obj->ToString(reinterpret_cast<v8::Isolate*>(isolate));
if (str.IsEmpty()) return;
i::Handle<i::String> i_str = Utils::OpenHandle(*str);
length_ = v8::Utf8Length(*i_str, isolate);
@@ -6937,7 +6937,7 @@
ENTER_V8(isolate);
i::HandleScope scope(isolate);
TryCatch try_catch;
- Handle<String> str = obj->ToString();
+ Handle<String> str =
obj->ToString(reinterpret_cast<v8::Isolate*>(isolate));
if (str.IsEmpty()) return;
length_ = str->Length();
str_ = i::NewArray<uint16_t>(length_ + 1);
=======================================
--- /branches/bleeding_edge/src/d8-debug.cc Tue Jun 3 08:12:43 2014 UTC
+++ /branches/bleeding_edge/src/d8-debug.cc Mon Oct 27 09:02:49 2014 UTC
@@ -124,7 +124,7 @@
printf("%s\n", *text_str);
}
running =
response_details->Get(String::NewFromUtf8(isolate, "running"))
- ->ToBoolean()
+ ->ToBoolean(isolate)
->Value();
}
}
=======================================
--- /branches/bleeding_edge/src/d8.cc Wed Oct 22 15:30:50 2014 UTC
+++ /branches/bleeding_edge/src/d8.cc Mon Oct 27 09:02:49 2014 UTC
@@ -186,7 +186,7 @@
int name_length = 0;
uint16_t* name_buffer = NULL;
if (name->IsString()) {
- Local<String> name_string = name->ToString();
+ Local<String> name_string = Local<String>::Cast(name);
name_length = name_string->Length();
name_buffer = new uint16_t[name_length];
name_string->Write(name_buffer, 0, name_length);
@@ -410,7 +410,7 @@
Throw(args.GetIsolate(), "Invalid argument");
return;
}
- int index = data->RealmFind(args[0]->ToObject()->CreationContext());
+ int index =
data->RealmFind(args[0]->ToObject(isolate)->CreationContext());
if (index == -1) return;
args.GetReturnValue().Set(index);
}
@@ -480,7 +480,7 @@
Throw(args.GetIsolate(), "Invalid argument");
return;
}
- ScriptCompiler::Source script_source(args[1]->ToString());
+ ScriptCompiler::Source script_source(args[1]->ToString(isolate));
Handle<UnboundScript> script = ScriptCompiler::CompileUnbound(
isolate, &script_source);
if (script.IsEmpty()) return;
@@ -526,7 +526,7 @@
// Explicitly catch potential exceptions in toString().
v8::TryCatch try_catch;
- Handle<String> str_obj = args[i]->ToString();
+ Handle<String> str_obj = args[i]->ToString(args.GetIsolate());
if (try_catch.HasCaught()) {
try_catch.ReThrow();
return;
=======================================
--- /branches/bleeding_edge/src/extensions/statistics-extension.cc Mon Aug
4 11:34:54 2014 UTC
+++ /branches/bleeding_edge/src/extensions/statistics-extension.cc Mon Oct
27 09:02:49 2014 UTC
@@ -53,7 +53,8 @@
Heap* heap = isolate->heap();
if (args.Length() > 0) { // GC if first argument evaluates to true.
- if (args[0]->IsBoolean() && args[0]->ToBoolean()->Value()) {
+ if (args[0]->IsBoolean() &&
+ args[0]->ToBoolean(args.GetIsolate())->Value()) {
heap->CollectAllGarbage(Heap::kNoGCFlags, "counters extension");
}
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.