Reviewers: Michael Starzinger,
Message:
ptal
note: this has to wait for chrome and blink patches to land
Description:
remove Local::New with no isolate parameter
[email protected]
BUG=
Please review this at https://chromiumcodereview.appspot.com/24550006/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+31, -42 lines):
M include/v8.h
M src/api.cc
M test/cctest/test-accessors.cc
M test/cctest/test-api.cc
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
adc7a66213b497e520335e202d9e24929547a24d..ba02e918d4c18ba184418e2a51840b61c2e6f5ef
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -377,7 +377,6 @@ template <class T> class Local : public Handle<T> {
* The referee is kept alive by the local handle even when
* the original handle is destroyed/disposed.
*/
- V8_INLINE static Local<T> New(Handle<T> that);
V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that);
template<class M>
V8_INLINE static Local<T> New(Isolate* isolate,
@@ -784,16 +783,16 @@ class V8_EXPORT HandleScope {
*/
static int NumberOfHandles();
+ private:
/**
* Creates a new handle with the given value.
*/
- static internal::Object** CreateHandle(internal::Object* value);
static internal::Object** CreateHandle(internal::Isolate* isolate,
internal::Object* value);
- // Faster version, uses HeapObject to obtain the current Isolate.
- static internal::Object** CreateHandle(internal::HeapObject* value);
+ // Uses HeapObject to obtain the current Isolate.
+ static internal::Object** CreateHandle(internal::HeapObject* heap_object,
+ internal::Object* value);
- private:
// Make it hard to create heap-allocated or illegal handle scopes by
// disallowing certain operations.
HandleScope(const HandleScope&);
@@ -827,6 +826,10 @@ class V8_EXPORT HandleScope {
internal::Object** RawClose(internal::Object** value);
friend class ImplementationUtilities;
+ template<class F> friend class Handle;
+ template<class F> friend class Local;
+ friend class Object;
+ friend class Context;
};
@@ -5544,19 +5547,6 @@ Local<T>::Local() : Handle<T>() { }
template <class T>
-Local<T> Local<T>::New(Handle<T> that) {
- if (that.IsEmpty()) return Local<T>();
- T* that_ptr = *that;
- internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
- if (internal::Internals::CanCastToHeapObject(that_ptr)) {
- return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
- reinterpret_cast<internal::HeapObject*>(*p))));
- }
- return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p)));
-}
-
-
-template <class T>
Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) {
return New(isolate, that.val_);
}
@@ -5992,6 +5982,7 @@ void Template::Set(const char* name, v8::Handle<Data>
value) {
Local<Value> Object::GetInternalField(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Object O;
+ typedef internal::HeapObject HO;
typedef internal::Internals I;
O* obj = *reinterpret_cast<O**>(this);
// Fast path: If the object is a plain JSObject, which is the common
case, we
@@ -5999,7 +5990,7 @@ Local<Value> Object::GetInternalField(int index) {
if (I::GetInstanceType(obj) == I::kJSObjectType) {
int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize *
index);
O* value = I::ReadField<O*>(obj, offset);
- O** result = HandleScope::CreateHandle(value);
+ O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj),
value);
return Local<Value>(reinterpret_cast<Value*>(result));
}
#endif
@@ -6451,8 +6442,11 @@ void* Isolate::GetData() {
Local<Value> Context::GetEmbedderData(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Object O;
+ typedef internal::HeapObject HO;
typedef internal::Internals I;
- O** result = HandleScope::CreateHandle(I::ReadEmbedderData<O*>(this,
index));
+ HO* context = *reinterpret_cast<HO**>(this);
+ O** result =
+ HandleScope::CreateHandle(context, I::ReadEmbedderData<O*>(this,
index));
return Local<Value>(reinterpret_cast<Value*>(result));
#else
return SlowGetEmbedderData(index);
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
07a249c8b403c88dae0f29328261a2c53cf49497..589cbdbd0986e2a51dc2e3f84b9f010e1f35466b
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -689,21 +689,16 @@ int HandleScope::NumberOfHandles() {
}
-i::Object** HandleScope::CreateHandle(i::Object* value) {
- return i::HandleScope::CreateHandle(i::Isolate::Current(), value);
-}
-
-
i::Object** HandleScope::CreateHandle(i::Isolate* isolate, i::Object*
value) {
- ASSERT(isolate == i::Isolate::Current());
return i::HandleScope::CreateHandle(isolate, value);
}
-i::Object** HandleScope::CreateHandle(i::HeapObject* value) {
- ASSERT(value->IsHeapObject());
+i::Object** HandleScope::CreateHandle(i::HeapObject* heap_object,
+ i::Object* value) {
+ ASSERT(heap_object->IsHeapObject());
return reinterpret_cast<i::Object**>(
- i::HandleScope::CreateHandle(value->GetIsolate(), value));
+ i::HandleScope::CreateHandle(heap_object->GetIsolate(), value));
}
@@ -1921,8 +1916,9 @@ v8::TryCatch::TryCatch()
v8::TryCatch::~TryCatch() {
ASSERT(isolate_ == i::Isolate::Current());
if (rethrow_) {
- v8::HandleScope scope(reinterpret_cast<Isolate*>(isolate_));
- v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception());
+ v8::Isolate* isolate = reinterpret_cast<Isolate*>(isolate_);
+ v8::HandleScope scope(isolate);
+ v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(isolate,
Exception());
if (HasCaught() && capture_message_) {
// If an exception was caught and rethrow_ is indicated, the saved
// message, script, and location need to be restored to Isolate TLS
Index: test/cctest/test-accessors.cc
diff --git a/test/cctest/test-accessors.cc b/test/cctest/test-accessors.cc
index
9007f1482d345afa9a4f081d0d3c0ffde94f9d27..df4937ee28367a0c288b0f419a5143ab370f9b70
100644
--- a/test/cctest/test-accessors.cc
+++ b/test/cctest/test-accessors.cc
@@ -507,7 +507,7 @@ THREADED_TEST(StackIteration) {
static void AllocateHandles(Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>&
info) {
for (int i = 0; i < i::kHandleBlockSize + 1; i++) {
- v8::Local<v8::Value>::New(name);
+ v8::Local<v8::Value>::New(info.GetIsolate(), name);
}
info.GetReturnValue().Set(v8::Integer::New(100));
}
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
1b44c5b178e5f75e1e7402d41477c153bcc61993..0d01b0b6ce625dbe0873cf92b036a470840d8870
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -3257,7 +3257,7 @@ THREADED_TEST(ClearAndLeakGlobal) {
THREADED_TEST(GlobalHandleUpcast) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
- v8::Local<String> local = v8::Local<String>::New(v8_str("str"));
+ v8::Local<String> local = v8::Local<String>::New(isolate, v8_str("str"));
v8::Persistent<String> global_string(isolate, local);
v8::Persistent<Value>& global_value =
v8::Persistent<Value>::Cast(global_string);
@@ -3307,10 +3307,8 @@ THREADED_TEST(HandleEquality) {
THREADED_TEST(LocalHandle) {
v8::HandleScope scope(CcTest::isolate());
- v8::Local<String> local = v8::Local<String>::New(v8_str("str"));
- CHECK_EQ(local->Length(), 3);
-
- local = v8::Local<String>::New(CcTest::isolate(), v8_str("str"));
+ v8::Local<String> local
+ = v8::Local<String>::New(CcTest::isolate(), v8_str("str"));
CHECK_EQ(local->Length(), 3);
}
@@ -12509,13 +12507,14 @@ void ApiTestFuzzer::CallTest() {
static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) {
- CHECK(v8::Locker::IsLocked(args.GetIsolate()));
+ v8::Isolate* isolate = args.GetIsolate();
+ CHECK(v8::Locker::IsLocked(isolate));
ApiTestFuzzer::Fuzz();
- v8::Unlocker unlocker(args.GetIsolate());
+ v8::Unlocker unlocker(isolate);
const char* code = "throw 7;";
{
- v8::Locker nested_locker(args.GetIsolate());
- v8::HandleScope scope(args.GetIsolate());
+ v8::Locker nested_locker(isolate);
+ v8::HandleScope scope(isolate);
v8::Handle<Value> exception;
{ v8::TryCatch try_catch;
v8::Handle<Value> value = CompileRun(code);
@@ -12524,7 +12523,7 @@ static void ThrowInJS(const
v8::FunctionCallbackInfo<v8::Value>& args) {
// Make sure to wrap the exception in a new handle because
// the handle returned from the TryCatch is destroyed
// when the TryCatch is destroyed.
- exception = Local<Value>::New(try_catch.Exception());
+ exception = Local<Value>::New(isolate, try_catch.Exception());
}
args.GetIsolate()->ThrowException(exception);
}
--
--
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/groups/opt_out.