From 80a974ba00f83f941e80c983e201bea0794f17e0 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Fri, 11 Apr 2014 12:47:34 +0000 Subject: [PATCH] Reland "Handlify GetProperty." R=ishell@chromium.org Review URL: https://codereview.chromium.org/235083002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20689 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/api.cc | 20 +-- src/bootstrapper.cc | 16 +-- src/debug.cc | 16 +-- src/execution.cc | 5 +- src/factory.cc | 11 +- src/handles.cc | 4 +- src/i18n.cc | 6 +- src/isolate.cc | 8 +- src/liveedit.cc | 30 ++--- src/liveedit.h | 8 +- src/log.cc | 4 +- src/messages.cc | 5 +- src/objects-inl.h | 54 +++++--- src/objects.cc | 262 ++++++++++++--------------------------- src/objects.h | 52 +++----- src/runtime.cc | 23 ++-- test/cctest/test-api.cc | 2 +- test/cctest/test-compiler.cc | 6 +- test/cctest/test-heap.cc | 66 +++++----- test/cctest/test-mark-compact.cc | 9 +- 20 files changed, 258 insertions(+), 349 deletions(-) diff --git a/src/api.cc b/src/api.cc index e9bc470..d682078 100644 --- a/src/api.cc +++ b/src/api.cc @@ -1902,8 +1902,10 @@ v8::Local v8::TryCatch::StackTrace() const { i::Handle obj(i::JSObject::cast(raw_obj), isolate_); i::Handle name = isolate_->factory()->stack_string(); if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local(); - i::Handle value = i::Object::GetProperty(obj, name); - if (value.is_null()) return v8::Local(); + i::Handle value; + if (!i::Object::GetProperty(obj, name).ToHandle(&value)) { + return v8::Local(); + } return v8::Utils::ToLocal(scope.CloseAndEscape(value)); } else { return v8::Local(); @@ -1998,8 +2000,8 @@ MUST_USE_RESULT static i::MaybeHandle CallV8HeapFunction( i::Handle fmt_str = isolate->factory()->InternalizeUtf8String(name); i::Handle object_fun = - i::GlobalObject::GetPropertyNoExceptionThrown( - isolate->js_builtins_object(), fmt_str); + i::Object::GetProperty( + isolate->js_builtins_object(), fmt_str).ToHandleChecked(); i::Handle fun = i::Handle::cast(object_fun); return i::Execution::Call(isolate, fun, recv, argc, argv); } @@ -2129,7 +2131,7 @@ Local StackTrace::GetFrame(uint32_t index) const { EscapableHandleScope scope(reinterpret_cast(isolate)); i::Handle self = Utils::OpenHandle(this); i::Handle obj = - i::Object::GetElementNoExceptionThrown(isolate, self, index); + i::Object::GetElement(isolate, self, index).ToHandleChecked(); i::Handle jsobj = i::Handle::cast(obj); return scope.Escape(Utils::StackFrameToLocal(jsobj)); } @@ -2444,8 +2446,8 @@ static i::Object* LookupBuiltin(i::Isolate* isolate, const char* builtin_name) { i::Handle string = isolate->factory()->InternalizeUtf8String(builtin_name); - return *i::GlobalObject::GetPropertyNoExceptionThrown( - isolate->js_builtins_object(), string); + return *i::Object::GetProperty( + isolate->js_builtins_object(), string).ToHandleChecked(); } @@ -6958,8 +6960,8 @@ Local Debug::GetMirror(v8::Handle obj) { isolate_debug->debug_context()->global_object()); i::Handle name = isolate->factory()->InternalizeOneByteString( STATIC_ASCII_VECTOR("MakeMirror")); - i::Handle fun_obj = i::Object::GetProperty(debug, name); - ASSERT(!fun_obj.is_null()); + i::Handle fun_obj = + i::Object::GetProperty(debug, name).ToHandleChecked(); i::Handle fun = i::Handle::cast(fun_obj); v8::Handle v8_fun = Utils::ToLocal(fun); const int kArgc = 1; diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index b8a930a..ba08aad 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -1497,9 +1497,9 @@ bool Genesis::CompileScriptCached(Isolate* isolate, #define INSTALL_NATIVE(Type, name, var) \ Handle var##_name = \ - factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \ - Handle var##_native = GlobalObject::GetPropertyNoExceptionThrown( \ - handle(native_context()->builtins()), var##_name); \ + factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \ + Handle var##_native = Object::GetProperty( \ + handle(native_context()->builtins()), var##_name).ToHandleChecked(); \ native_context()->set_##var(Type::cast(*var##_native)); @@ -1868,7 +1868,7 @@ bool Genesis::InstallNatives() { { Handle key = factory()->function_class_string(); Handle function = Handle::cast(Object::GetProperty( - isolate()->global_object(), key)); + isolate()->global_object(), key).ToHandleChecked()); Handle proto = Handle(JSObject::cast(function->instance_prototype())); @@ -2014,7 +2014,7 @@ static Handle ResolveBuiltinIdHolder( Handle property_string = factory->InternalizeUtf8String(property); ASSERT(!property_string.is_null()); Handle function = Handle::cast( - Object::GetProperty(global, property_string)); + Object::GetProperty(global, property_string).ToHandleChecked()); return Handle(JSObject::cast(function->prototype())); } @@ -2024,8 +2024,8 @@ static void InstallBuiltinFunctionId(Handle holder, BuiltinFunctionId id) { Factory* factory = holder->GetIsolate()->factory(); Handle name = factory->InternalizeUtf8String(function_name); - Handle function_object = Object::GetProperty(holder, name); - ASSERT(!function_object.is_null()); + Handle function_object = + Object::GetProperty(holder, name).ToHandleChecked(); Handle function = Handle::cast(function_object); function->shared()->set_function_data(Smi::FromInt(id)); } @@ -2321,7 +2321,7 @@ bool Genesis::InstallJSBuiltins(Handle builtins) { Handle name = factory()->InternalizeUtf8String(Builtins::GetName(id)); Handle function_object = - GlobalObject::GetPropertyNoExceptionThrown(builtins, name); + Object::GetProperty(builtins, name).ToHandleChecked(); Handle function = Handle::cast(function_object); builtins->set_javascript_builtin(id, *function); if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) { diff --git a/src/debug.cc b/src/debug.cc index a1a648b..41c608a 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -1118,8 +1118,8 @@ bool Debug::CheckBreakPoint(Handle break_point_object) { STATIC_ASCII_VECTOR("IsBreakPointTriggered")); Handle debug_global(debug_context()->global_object()); Handle check_break_point = - Handle::cast(GlobalObject::GetPropertyNoExceptionThrown( - debug_global, is_break_point_triggered_string)); + Handle::cast(Object::GetProperty( + debug_global, is_break_point_triggered_string).ToHandleChecked()); // Get the break id as an object. Handle break_id = factory->NewNumberFromInt(Debug::break_id()); @@ -2459,8 +2459,8 @@ void Debug::ClearMirrorCache() { // Clear the mirror cache. Handle function_name = isolate_->factory()->InternalizeOneByteString( STATIC_ASCII_VECTOR("ClearMirrorCache")); - Handle fun = GlobalObject::GetPropertyNoExceptionThrown( - isolate_->global_object(), function_name); + Handle fun = Object::GetProperty( + isolate_->global_object(), function_name).ToHandleChecked(); ASSERT(fun->IsJSFunction()); Execution::TryCall( Handle::cast(fun), @@ -2597,8 +2597,8 @@ MaybeHandle Debugger::MakeJSObject( Handle constructor_str = isolate_->factory()->InternalizeUtf8String(constructor_name); ASSERT(!constructor_str.is_null()); - Handle constructor = GlobalObject::GetPropertyNoExceptionThrown( - isolate_->global_object(), constructor_str); + Handle constructor = Object::GetProperty( + isolate_->global_object(), constructor_str).ToHandleChecked(); ASSERT(constructor->IsJSFunction()); if (!constructor->IsJSFunction()) return MaybeHandle(); return Execution::TryCall( @@ -2788,8 +2788,8 @@ void Debugger::OnAfterCompile(Handle