Remove calls to non-handlified version of GetProperty(name).

R=ishell@chromium.org

Review URL: https://codereview.chromium.org/229973004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20611 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2014-04-09 12:21:47 +00:00
parent 66d63594bc
commit aee76a059a
12 changed files with 168 additions and 172 deletions

View File

@ -2036,10 +2036,10 @@ static i::Handle<i::Object> CallV8HeapFunction(const char* name,
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
i::Handle<i::String> fmt_str = i::Handle<i::String> fmt_str =
isolate->factory()->InternalizeUtf8String(name); isolate->factory()->InternalizeUtf8String(name);
i::Object* object_fun = i::Handle<i::Object> object_fun =
isolate->js_builtins_object()->GetPropertyNoExceptionThrown(*fmt_str); i::GlobalObject::GetPropertyNoExceptionThrown(
i::Handle<i::JSFunction> fun = isolate->js_builtins_object(), fmt_str);
i::Handle<i::JSFunction>(i::JSFunction::cast(object_fun)); i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(object_fun);
i::Handle<i::Object> value = i::Execution::Call( i::Handle<i::Object> value = i::Execution::Call(
isolate, fun, recv, argc, argv, has_pending_exception); isolate, fun, recv, argc, argv, has_pending_exception);
return value; return value;
@ -2484,8 +2484,8 @@ static i::Object* LookupBuiltin(i::Isolate* isolate,
const char* builtin_name) { const char* builtin_name) {
i::Handle<i::String> string = i::Handle<i::String> string =
isolate->factory()->InternalizeUtf8String(builtin_name); isolate->factory()->InternalizeUtf8String(builtin_name);
i::Handle<i::JSBuiltinsObject> builtins = isolate->js_builtins_object(); return *i::GlobalObject::GetPropertyNoExceptionThrown(
return builtins->GetPropertyNoExceptionThrown(*string); isolate->js_builtins_object(), string);
} }

View File

@ -1515,13 +1515,12 @@ bool Genesis::CompileScriptCached(Isolate* isolate,
} }
#define INSTALL_NATIVE(Type, name, var) \ #define INSTALL_NATIVE(Type, name, var) \
Handle<String> var##_name = \ Handle<String> var##_name = \
factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \ factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \
Object* var##_native = \ Handle<Object> var##_native = GlobalObject::GetPropertyNoExceptionThrown( \
native_context()->builtins()->GetPropertyNoExceptionThrown( \ handle(native_context()->builtins()), var##_name); \
*var##_name); \ native_context()->set_##var(Type::cast(*var##_native));
native_context()->set_##var(Type::cast(var##_native));
void Genesis::InstallNativeFunctions() { void Genesis::InstallNativeFunctions() {
@ -2054,8 +2053,9 @@ static void InstallBuiltinFunctionId(Handle<JSObject> holder,
BuiltinFunctionId id) { BuiltinFunctionId id) {
Factory* factory = holder->GetIsolate()->factory(); Factory* factory = holder->GetIsolate()->factory();
Handle<String> name = factory->InternalizeUtf8String(function_name); Handle<String> name = factory->InternalizeUtf8String(function_name);
Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked(); Handle<Object> function_object = Object::GetProperty(holder, name);
Handle<JSFunction> function(JSFunction::cast(function_object)); ASSERT(!function_object.is_null());
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
function->shared()->set_function_data(Smi::FromInt(id)); function->shared()->set_function_data(Smi::FromInt(id));
} }
@ -2349,9 +2349,9 @@ bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i);
Handle<String> name = Handle<String> name =
factory()->InternalizeUtf8String(Builtins::GetName(id)); factory()->InternalizeUtf8String(Builtins::GetName(id));
Object* function_object = builtins->GetPropertyNoExceptionThrown(*name); Handle<Object> function_object =
Handle<JSFunction> function GlobalObject::GetPropertyNoExceptionThrown(builtins, name);
= Handle<JSFunction>(JSFunction::cast(function_object)); Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
builtins->set_javascript_builtin(id, *function); builtins->set_javascript_builtin(id, *function);
if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) { if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) {
return false; return false;

View File

@ -1116,10 +1116,10 @@ bool Debug::CheckBreakPoint(Handle<Object> break_point_object) {
Handle<String> is_break_point_triggered_string = Handle<String> is_break_point_triggered_string =
factory->InternalizeOneByteString( factory->InternalizeOneByteString(
STATIC_ASCII_VECTOR("IsBreakPointTriggered")); STATIC_ASCII_VECTOR("IsBreakPointTriggered"));
Handle<GlobalObject> debug_global(debug_context()->global_object());
Handle<JSFunction> check_break_point = Handle<JSFunction> check_break_point =
Handle<JSFunction>(JSFunction::cast( Handle<JSFunction>::cast(GlobalObject::GetPropertyNoExceptionThrown(
debug_context()->global_object()->GetPropertyNoExceptionThrown( debug_global, is_break_point_triggered_string));
*is_break_point_triggered_string)));
// Get the break id as an object. // Get the break id as an object.
Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id()); Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id());
@ -2463,9 +2463,8 @@ void Debug::ClearMirrorCache() {
// Clear the mirror cache. // Clear the mirror cache.
Handle<String> function_name = isolate_->factory()->InternalizeOneByteString( Handle<String> function_name = isolate_->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("ClearMirrorCache")); STATIC_ASCII_VECTOR("ClearMirrorCache"));
Handle<Object> fun( Handle<Object> fun = GlobalObject::GetPropertyNoExceptionThrown(
isolate_->global_object()->GetPropertyNoExceptionThrown(*function_name), isolate_->global_object(), function_name);
isolate_);
ASSERT(fun->IsJSFunction()); ASSERT(fun->IsJSFunction());
bool caught_exception; bool caught_exception;
Execution::TryCall(Handle<JSFunction>::cast(fun), Execution::TryCall(Handle<JSFunction>::cast(fun),
@ -2601,9 +2600,8 @@ Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name,
Handle<String> constructor_str = Handle<String> constructor_str =
isolate_->factory()->InternalizeUtf8String(constructor_name); isolate_->factory()->InternalizeUtf8String(constructor_name);
ASSERT(!constructor_str.is_null()); ASSERT(!constructor_str.is_null());
Handle<Object> constructor( Handle<Object> constructor = GlobalObject::GetPropertyNoExceptionThrown(
isolate_->global_object()->GetPropertyNoExceptionThrown(*constructor_str), isolate_->global_object(), constructor_str);
isolate_);
ASSERT(constructor->IsJSFunction()); ASSERT(constructor->IsJSFunction());
if (!constructor->IsJSFunction()) { if (!constructor->IsJSFunction()) {
*caught_exception = true; *caught_exception = true;
@ -2833,11 +2831,10 @@ void Debugger::OnAfterCompile(Handle<Script> script,
Handle<String> update_script_break_points_string = Handle<String> update_script_break_points_string =
isolate_->factory()->InternalizeOneByteString( isolate_->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("UpdateScriptBreakPoints")); STATIC_ASCII_VECTOR("UpdateScriptBreakPoints"));
Handle<GlobalObject> debug_global(debug->debug_context()->global_object());
Handle<Object> update_script_break_points = Handle<Object> update_script_break_points =
Handle<Object>( GlobalObject::GetPropertyNoExceptionThrown(
debug->debug_context()->global_object()->GetPropertyNoExceptionThrown( debug_global, update_script_break_points_string);
*update_script_break_points_string),
isolate_);
if (!update_script_break_points->IsJSFunction()) { if (!update_script_break_points->IsJSFunction()) {
return; return;
} }

View File

@ -1128,9 +1128,8 @@ Handle<Object> Factory::NewError(const char* maker,
const char* message, const char* message,
Handle<JSArray> args) { Handle<JSArray> args) {
Handle<String> make_str = InternalizeUtf8String(maker); Handle<String> make_str = InternalizeUtf8String(maker);
Handle<Object> fun_obj( Handle<Object> fun_obj = GlobalObject::GetPropertyNoExceptionThrown(
isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str), isolate()->js_builtins_object(), make_str);
isolate());
// If the builtins haven't been properly configured yet this error // If the builtins haven't been properly configured yet this error
// constructor may not have been defined. Bail out. // constructor may not have been defined. Bail out.
if (!fun_obj->IsJSFunction()) { if (!fun_obj->IsJSFunction()) {
@ -1160,9 +1159,9 @@ Handle<Object> Factory::NewError(Handle<String> message) {
Handle<Object> Factory::NewError(const char* constructor, Handle<Object> Factory::NewError(const char* constructor,
Handle<String> message) { Handle<String> message) {
Handle<String> constr = InternalizeUtf8String(constructor); Handle<String> constr = InternalizeUtf8String(constructor);
Handle<JSFunction> fun = Handle<JSFunction>( Handle<JSFunction> fun = Handle<JSFunction>::cast(
JSFunction::cast(isolate()->js_builtins_object()-> GlobalObject::GetPropertyNoExceptionThrown(
GetPropertyNoExceptionThrown(*constr))); isolate()->js_builtins_object(), constr));
Handle<Object> argv[] = { message }; Handle<Object> argv[] = { message };
// Invoke the JavaScript factory method. If an exception is thrown while // Invoke the JavaScript factory method. If an exception is thrown while

View File

@ -1046,15 +1046,17 @@ bool Isolate::ShouldReportException(bool* can_be_caught_externally,
bool Isolate::IsErrorObject(Handle<Object> obj) { bool Isolate::IsErrorObject(Handle<Object> obj) {
if (!obj->IsJSObject()) return false; if (!obj->IsJSObject()) return false;
String* error_key = Handle<String> error_key =
*(factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("$Error"))); factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("$Error"));
Object* error_constructor = Handle<Object> error_constructor = GlobalObject::GetPropertyNoExceptionThrown(
js_builtins_object()->GetPropertyNoExceptionThrown(error_key); js_builtins_object(), error_key);
DisallowHeapAllocation no_gc;
for (Object* prototype = *obj; !prototype->IsNull(); for (Object* prototype = *obj; !prototype->IsNull();
prototype = prototype->GetPrototype(this)) { prototype = prototype->GetPrototype(this)) {
if (!prototype->IsJSObject()) return false; if (!prototype->IsJSObject()) return false;
if (JSObject::cast(prototype)->map()->constructor() == error_constructor) { if (JSObject::cast(prototype)->map()->constructor() ==
*error_constructor) {
return true; return true;
} }
} }

View File

@ -154,11 +154,9 @@ Handle<String> MessageHandler::GetMessage(Isolate* isolate,
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
Handle<String> fmt_str = Handle<String> fmt_str =
factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("FormatMessage")); factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("FormatMessage"));
Handle<JSFunction> fun = Handle<JSFunction> fun = Handle<JSFunction>::cast(
Handle<JSFunction>( GlobalObject::GetPropertyNoExceptionThrown(
JSFunction::cast( isolate->js_builtins_object(), fmt_str));
isolate->js_builtins_object()->
GetPropertyNoExceptionThrown(*fmt_str)));
Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data); Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data);
Handle<Object> argv[] = { Handle<Object>(message->type(), isolate), Handle<Object> argv[] = { Handle<Object>(message->type(), isolate),
Handle<Object>(message->arguments(), isolate) }; Handle<Object>(message->arguments(), isolate) };

View File

@ -3070,6 +3070,15 @@ void Name::set_hash_field(uint32_t value) {
} }
Handle<Object> GlobalObject::GetPropertyNoExceptionThrown(
Handle<GlobalObject> global,
Handle<Name> name) {
Handle<Object> result = Object::GetProperty(global, name);
CHECK_NOT_EMPTY_HANDLE(name->GetIsolate(), result);
return result;
}
bool Name::Equals(Name* other) { bool Name::Equals(Name* other) {
if (other == this) return true; if (other == this) return true;
if ((this->IsInternalizedString() && other->IsInternalizedString()) || if ((this->IsInternalizedString() && other->IsInternalizedString()) ||

View File

@ -7776,10 +7776,9 @@ class GlobalObject: public JSObject {
// by throwing an exception. This is for the debug and builtins global // by throwing an exception. This is for the debug and builtins global
// objects, where it is known which properties can be expected to be present // objects, where it is known which properties can be expected to be present
// on the object. // on the object.
Object* GetPropertyNoExceptionThrown(Name* key) { static inline Handle<Object> GetPropertyNoExceptionThrown(
Object* answer = GetProperty(key)->ToObjectUnchecked(); Handle<GlobalObject> global,
return answer; Handle<Name> name);
}
// Casting. // Casting.
static inline GlobalObject* cast(Object* obj); static inline GlobalObject* cast(Object* obj);

View File

@ -6045,14 +6045,16 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) {
return frame->GetParameter(index); return frame->GetParameter(index);
} }
HandleScope scope(isolate);
if (args[0]->IsSymbol()) { if (args[0]->IsSymbol()) {
// Lookup in the initial Object.prototype object. // Lookup in the initial Object.prototype object.
return isolate->initial_object_prototype()->GetProperty( Handle<Object> result = Object::GetProperty(
Symbol::cast(args[0])); isolate->initial_object_prototype(), args.at<Symbol>(0));
RETURN_IF_EMPTY_HANDLE(isolate, result);
return *result;
} }
// Convert the key to a string. // Convert the key to a string.
HandleScope scope(isolate);
bool exception = false; bool exception = false;
Handle<Object> converted = Handle<Object> converted =
Execution::ToString(isolate, args.at<Object>(0), &exception); Execution::ToString(isolate, args.at<Object>(0), &exception);
@ -6084,7 +6086,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) {
} }
// Lookup in the initial Object.prototype object. // Lookup in the initial Object.prototype object.
return isolate->initial_object_prototype()->GetProperty(*key); Handle<Object> result = Object::GetProperty(
isolate->initial_object_prototype(), key);
RETURN_IF_EMPTY_HANDLE(isolate, result);
return *result;
} }
@ -9327,8 +9332,10 @@ static ObjectPair LoadContextSlotHelper(Arguments args,
// No need to unhole the value here. This is taken care of by the // No need to unhole the value here. This is taken care of by the
// GetProperty function. // GetProperty function.
MaybeObject* value = object->GetProperty(*name); Handle<Object> value = Object::GetProperty(object, name);
return MakePair(value, *receiver_handle); RETURN_IF_EMPTY_HANDLE_VALUE(
isolate, value, MakePair(Failure::Exception(), NULL));
return MakePair(*value, *receiver_handle);
} }
if (throw_error) { if (throw_error) {

View File

@ -36,11 +36,12 @@
using namespace v8::internal; using namespace v8::internal;
static MaybeObject* GetGlobalProperty(const char* name) { static Handle<Object> GetGlobalProperty(const char* name) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Handle<String> internalized_name = Handle<String> internalized_name =
isolate->factory()->InternalizeUtf8String(name); isolate->factory()->InternalizeUtf8String(name);
return isolate->context()->global_object()->GetProperty(*internalized_name); return GlobalObject::GetPropertyNoExceptionThrown(
isolate->global_object(), internalized_name);
} }
@ -85,7 +86,7 @@ static double Inc(Isolate* isolate, int x) {
Handle<JSObject> global(isolate->context()->global_object()); Handle<JSObject> global(isolate->context()->global_object());
Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception); Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception);
CHECK(!has_pending_exception); CHECK(!has_pending_exception);
return GetGlobalProperty("result")->ToObjectChecked()->Number(); return GetGlobalProperty("result")->Number();
} }
@ -106,7 +107,7 @@ static double Add(Isolate* isolate, int x, int y) {
Handle<JSObject> global(isolate->context()->global_object()); Handle<JSObject> global(isolate->context()->global_object());
Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception); Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception);
CHECK(!has_pending_exception); CHECK(!has_pending_exception);
return GetGlobalProperty("result")->ToObjectChecked()->Number(); return GetGlobalProperty("result")->Number();
} }
@ -126,7 +127,7 @@ static double Abs(Isolate* isolate, int x) {
Handle<JSObject> global(isolate->context()->global_object()); Handle<JSObject> global(isolate->context()->global_object());
Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception); Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception);
CHECK(!has_pending_exception); CHECK(!has_pending_exception);
return GetGlobalProperty("result")->ToObjectChecked()->Number(); return GetGlobalProperty("result")->Number();
} }
@ -147,7 +148,7 @@ static double Sum(Isolate* isolate, int n) {
Handle<JSObject> global(isolate->context()->global_object()); Handle<JSObject> global(isolate->context()->global_object());
Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception); Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception);
CHECK(!has_pending_exception); CHECK(!has_pending_exception);
return GetGlobalProperty("result")->ToObjectChecked()->Number(); return GetGlobalProperty("result")->Number();
} }
@ -204,7 +205,7 @@ TEST(Stuff) {
Execution::Call( Execution::Call(
CcTest::i_isolate(), fun, global, 0, NULL, &has_pending_exception); CcTest::i_isolate(), fun, global, 0, NULL, &has_pending_exception);
CHECK(!has_pending_exception); CHECK(!has_pending_exception);
CHECK_EQ(511.0, GetGlobalProperty("r")->ToObjectChecked()->Number()); CHECK_EQ(511.0, GetGlobalProperty("r")->Number());
} }
@ -250,11 +251,10 @@ TEST(C2JSFrames) {
isolate, fun0, global, 0, NULL, &has_pending_exception); isolate, fun0, global, 0, NULL, &has_pending_exception);
CHECK(!has_pending_exception); CHECK(!has_pending_exception);
Object* foo_string = isolate->factory()->InternalizeOneByteString( Handle<String> foo_string = isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("foo"))->ToObjectChecked(); STATIC_ASCII_VECTOR("foo"));
MaybeObject* fun1_object = isolate->context()->global_object()-> Handle<Object> fun1 = Object::GetProperty(
GetProperty(String::cast(foo_string)); isolate->global_object(), foo_string);
Handle<Object> fun1(fun1_object->ToObjectChecked(), isolate);
CHECK(fun1->IsJSFunction()); CHECK(fun1->IsJSFunction());
Handle<Object> argv[] = { isolate->factory()->InternalizeOneByteString( Handle<Object> argv[] = { isolate->factory()->InternalizeOneByteString(

View File

@ -293,8 +293,8 @@ TEST(GarbageCollection) {
JSReceiver::SetProperty( JSReceiver::SetProperty(
obj, prop_namex, twenty_four, NONE, SLOPPY).Check(); obj, prop_namex, twenty_four, NONE, SLOPPY).Check();
CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(obj, prop_name));
CHECK_EQ(Smi::FromInt(24), obj->GetProperty(*prop_namex)); CHECK_EQ(Smi::FromInt(24), *Object::GetProperty(obj, prop_namex));
} }
heap->CollectGarbage(NEW_SPACE); heap->CollectGarbage(NEW_SPACE);
@ -302,10 +302,9 @@ TEST(GarbageCollection) {
// Function should be alive. // Function should be alive.
CHECK(JSReceiver::HasLocalProperty(global, name)); CHECK(JSReceiver::HasLocalProperty(global, name));
// Check function is retained. // Check function is retained.
Object* func_value = CcTest::i_isolate()->context()->global_object()-> Handle<Object> func_value = Object::GetProperty(global, name);
GetProperty(*name)->ToObjectChecked();
CHECK(func_value->IsJSFunction()); CHECK(func_value->IsJSFunction());
Handle<JSFunction> function(JSFunction::cast(func_value)); Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
{ {
HandleScope inner_scope(isolate); HandleScope inner_scope(isolate);
@ -320,12 +319,9 @@ TEST(GarbageCollection) {
heap->CollectGarbage(NEW_SPACE); heap->CollectGarbage(NEW_SPACE);
CHECK(JSReceiver::HasLocalProperty(global, obj_name)); CHECK(JSReceiver::HasLocalProperty(global, obj_name));
CHECK(CcTest::i_isolate()->context()->global_object()-> Handle<Object> obj = Object::GetProperty(global, obj_name);
GetProperty(*obj_name)->ToObjectChecked()->IsJSObject()); CHECK(obj->IsJSObject());
Object* obj = CcTest::i_isolate()->context()->global_object()-> CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(obj, prop_name));
GetProperty(*obj_name)->ToObjectChecked();
JSObject* js_obj = JSObject::cast(obj);
CHECK_EQ(Smi::FromInt(23), js_obj->GetProperty(*prop_name));
} }
@ -649,11 +645,11 @@ TEST(FunctionAllocation) {
Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
Handle<JSObject> obj = factory->NewJSObject(function); Handle<JSObject> obj = factory->NewJSObject(function);
JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check(); JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check();
CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(obj, prop_name));
// Check that we can add properties to function objects. // Check that we can add properties to function objects.
JSReceiver::SetProperty( JSReceiver::SetProperty(
function, prop_name, twenty_four, NONE, SLOPPY).Check(); function, prop_name, twenty_four, NONE, SLOPPY).Check();
CHECK_EQ(Smi::FromInt(24), function->GetProperty(*prop_name)); CHECK_EQ(Smi::FromInt(24), *Object::GetProperty(function, prop_name));
} }
@ -663,11 +659,10 @@ TEST(ObjectProperties) {
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate()); v8::HandleScope sc(CcTest::isolate());
String* object_string = String::cast(CcTest::heap()->Object_string()); Handle<String> object_string(String::cast(CcTest::heap()->Object_string()));
Object* raw_object = CcTest::i_isolate()->context()->global_object()-> Handle<Object> object =
GetProperty(object_string)->ToObjectChecked(); Object::GetProperty(CcTest::i_isolate()->global_object(), object_string);
JSFunction* object_function = JSFunction::cast(raw_object); Handle<JSFunction> constructor = Handle<JSFunction>::cast(object);
Handle<JSFunction> constructor(object_function);
Handle<JSObject> obj = factory->NewJSObject(constructor); Handle<JSObject> obj = factory->NewJSObject(constructor);
Handle<String> first = factory->InternalizeUtf8String("first"); Handle<String> first = factory->InternalizeUtf8String("first");
Handle<String> second = factory->InternalizeUtf8String("second"); Handle<String> second = factory->InternalizeUtf8String("second");
@ -747,7 +742,7 @@ TEST(JSObjectMaps) {
// Set a propery // Set a propery
Handle<Smi> twenty_three(Smi::FromInt(23), isolate); Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check(); JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check();
CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(obj, prop_name));
// Check the map has changed // Check the map has changed
CHECK(*initial_map != obj->map()); CHECK(*initial_map != obj->map());
@ -761,10 +756,9 @@ TEST(JSArray) {
v8::HandleScope sc(CcTest::isolate()); v8::HandleScope sc(CcTest::isolate());
Handle<String> name = factory->InternalizeUtf8String("Array"); Handle<String> name = factory->InternalizeUtf8String("Array");
Object* raw_object = CcTest::i_isolate()->context()->global_object()-> Handle<Object> fun_obj =
GetProperty(*name)->ToObjectChecked(); Object::GetProperty(CcTest::i_isolate()->global_object(), name);
Handle<JSFunction> function = Handle<JSFunction>( Handle<JSFunction> function = Handle<JSFunction>::cast(fun_obj);
JSFunction::cast(raw_object));
// Allocate the object. // Allocate the object.
Handle<JSObject> object = factory->NewJSObject(function); Handle<JSObject> object = factory->NewJSObject(function);
@ -809,11 +803,10 @@ TEST(JSObjectCopy) {
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate()); v8::HandleScope sc(CcTest::isolate());
String* object_string = String::cast(CcTest::heap()->Object_string()); Handle<String> object_string(String::cast(CcTest::heap()->Object_string()));
Object* raw_object = CcTest::i_isolate()->context()->global_object()-> Handle<Object> object =
GetProperty(object_string)->ToObjectChecked(); Object::GetProperty(CcTest::i_isolate()->global_object(), object_string);
JSFunction* object_function = JSFunction::cast(raw_object); Handle<JSFunction> constructor = Handle<JSFunction>::cast(object);
Handle<JSFunction> constructor(object_function);
Handle<JSObject> obj = factory->NewJSObject(constructor); Handle<JSObject> obj = factory->NewJSObject(constructor);
Handle<String> first = factory->InternalizeUtf8String("first"); Handle<String> first = factory->InternalizeUtf8String("first");
Handle<String> second = factory->InternalizeUtf8String("second"); Handle<String> second = factory->InternalizeUtf8String("second");
@ -836,8 +829,10 @@ TEST(JSObjectCopy) {
CHECK_EQ(*i::Object::GetElement(isolate, obj, 1), CHECK_EQ(*i::Object::GetElement(isolate, obj, 1),
*i::Object::GetElement(isolate, clone, 1)); *i::Object::GetElement(isolate, clone, 1));
CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first)); CHECK_EQ(*Object::GetProperty(obj, first),
CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second)); *Object::GetProperty(clone, first));
CHECK_EQ(*Object::GetProperty(obj, second),
*Object::GetProperty(clone, second));
// Flip the values. // Flip the values.
JSReceiver::SetProperty(clone, first, two, NONE, SLOPPY).Check(); JSReceiver::SetProperty(clone, first, two, NONE, SLOPPY).Check();
@ -851,8 +846,10 @@ TEST(JSObjectCopy) {
CHECK_EQ(*i::Object::GetElement(isolate, obj, 0), CHECK_EQ(*i::Object::GetElement(isolate, obj, 0),
*i::Object::GetElement(isolate, clone, 1)); *i::Object::GetElement(isolate, clone, 1));
CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first)); CHECK_EQ(*Object::GetProperty(obj, second),
CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second)); *Object::GetProperty(clone, first));
CHECK_EQ(*Object::GetProperty(obj, first),
*Object::GetProperty(clone, second));
} }
@ -1071,10 +1068,10 @@ TEST(TestCodeFlushing) {
} }
// Check function is compiled. // Check function is compiled.
Object* func_value = CcTest::i_isolate()->context()->global_object()-> Handle<Object> func_value =
GetProperty(*foo_name)->ToObjectChecked(); Object::GetProperty(CcTest::i_isolate()->global_object(), foo_name);
CHECK(func_value->IsJSFunction()); CHECK(func_value->IsJSFunction());
Handle<JSFunction> function(JSFunction::cast(func_value)); Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
CHECK(function->shared()->is_compiled()); CHECK(function->shared()->is_compiled());
// The code will survive at least two GCs. // The code will survive at least two GCs.
@ -1104,7 +1101,7 @@ TEST(TestCodeFlushingPreAged) {
i::FLAG_allow_natives_syntax = true; i::FLAG_allow_natives_syntax = true;
i::FLAG_optimize_for_size = true; i::FLAG_optimize_for_size = true;
CcTest::InitializeVM(); CcTest::InitializeVM();
Isolate* isolate = Isolate::Current(); Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
const char* source = "function foo() {" const char* source = "function foo() {"
@ -1121,10 +1118,10 @@ TEST(TestCodeFlushingPreAged) {
} }
// Check function is compiled. // Check function is compiled.
Object* func_value = Isolate::Current()->context()->global_object()-> Handle<Object> func_value =
GetProperty(*foo_name)->ToObjectChecked(); Object::GetProperty(isolate->global_object(), foo_name);
CHECK(func_value->IsJSFunction()); CHECK(func_value->IsJSFunction());
Handle<JSFunction> function(JSFunction::cast(func_value)); Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
CHECK(function->shared()->is_compiled()); CHECK(function->shared()->is_compiled());
// The code has been run so will survive at least one GC. // The code has been run so will survive at least one GC.
@ -1186,10 +1183,10 @@ TEST(TestCodeFlushingIncremental) {
} }
// Check function is compiled. // Check function is compiled.
Object* func_value = CcTest::i_isolate()->context()->global_object()-> Handle<Object> func_value =
GetProperty(*foo_name)->ToObjectChecked(); Object::GetProperty(isolate->global_object(), foo_name);
CHECK(func_value->IsJSFunction()); CHECK(func_value->IsJSFunction());
Handle<JSFunction> function(JSFunction::cast(func_value)); Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
CHECK(function->shared()->is_compiled()); CHECK(function->shared()->is_compiled());
// The code will survive at least two GCs. // The code will survive at least two GCs.
@ -1263,15 +1260,15 @@ TEST(TestCodeFlushingIncrementalScavenge) {
} }
// Check functions are compiled. // Check functions are compiled.
Object* func_value = CcTest::i_isolate()->context()->global_object()-> Handle<Object> func_value =
GetProperty(*foo_name)->ToObjectChecked(); Object::GetProperty(isolate->global_object(), foo_name);
CHECK(func_value->IsJSFunction()); CHECK(func_value->IsJSFunction());
Handle<JSFunction> function(JSFunction::cast(func_value)); Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
CHECK(function->shared()->is_compiled()); CHECK(function->shared()->is_compiled());
Object* func_value2 = CcTest::i_isolate()->context()->global_object()-> Handle<Object> func_value2 =
GetProperty(*bar_name)->ToObjectChecked(); Object::GetProperty(isolate->global_object(), bar_name);
CHECK(func_value2->IsJSFunction()); CHECK(func_value2->IsJSFunction());
Handle<JSFunction> function2(JSFunction::cast(func_value2)); Handle<JSFunction> function2 = Handle<JSFunction>::cast(func_value2);
CHECK(function2->shared()->is_compiled()); CHECK(function2->shared()->is_compiled());
// Clear references to functions so that one of them can die. // Clear references to functions so that one of them can die.
@ -1325,10 +1322,10 @@ TEST(TestCodeFlushingIncrementalAbort) {
} }
// Check function is compiled. // Check function is compiled.
Object* func_value = CcTest::i_isolate()->context()->global_object()-> Handle<Object> func_value =
GetProperty(*foo_name)->ToObjectChecked(); Object::GetProperty(isolate->global_object(), foo_name);
CHECK(func_value->IsJSFunction()); CHECK(func_value->IsJSFunction());
Handle<JSFunction> function(JSFunction::cast(func_value)); Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
CHECK(function->shared()->is_compiled()); CHECK(function->shared()->is_compiled());
// The code will survive at least two GCs. // The code will survive at least two GCs.

View File

@ -128,6 +128,7 @@ TEST(MarkCompactCollector) {
CcTest::InitializeVM(); CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Heap* heap = isolate->heap(); Heap* heap = isolate->heap();
Factory* factory = isolate->factory();
v8::HandleScope sc(CcTest::isolate()); v8::HandleScope sc(CcTest::isolate());
Handle<GlobalObject> global(isolate->context()->global_object()); Handle<GlobalObject> global(isolate->context()->global_object());
@ -143,70 +144,57 @@ TEST(MarkCompactCollector) {
maybe_array = heap->AllocateFixedArray(ARRAY_SIZE); maybe_array = heap->AllocateFixedArray(ARRAY_SIZE);
} while (maybe_array->ToObject(&array)); } while (maybe_array->ToObject(&array));
heap->CollectGarbage(NEW_SPACE, "trigger 2"); heap->CollectGarbage(NEW_SPACE, "trigger 2");
heap->AllocateFixedArray(ARRAY_SIZE)->ToObjectChecked();
array = heap->AllocateFixedArray(ARRAY_SIZE)->ToObjectChecked();
// keep allocating maps until it fails // keep allocating maps until it fails
Object* mapp; Object* map;
MaybeObject* maybe_mapp; MaybeObject* maybe_map;
do { do {
maybe_mapp = heap->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); maybe_map = heap->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
} while (maybe_mapp->ToObject(&mapp)); } while (maybe_map->ToObject(&map));
heap->CollectGarbage(MAP_SPACE, "trigger 3"); heap->CollectGarbage(MAP_SPACE, "trigger 3");
mapp = heap->AllocateMap(JS_OBJECT_TYPE, heap->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize)->ToObjectChecked();
JSObject::kHeaderSize)->ToObjectChecked();
// allocate a garbage { HandleScope scope(isolate);
String* func_name = String::cast( // allocate a garbage
heap->InternalizeUtf8String("theFunction")->ToObjectChecked()); Handle<String> func_name = factory->InternalizeUtf8String("theFunction");
SharedFunctionInfo* function_share = SharedFunctionInfo::cast( Handle<JSFunction> function = factory->NewFunction(
heap->AllocateSharedFunctionInfo(func_name)->ToObjectChecked()); func_name, factory->undefined_value());
JSFunction* function = JSFunction::cast( Handle<Map> initial_map = factory->NewMap(
heap->AllocateFunction(*isolate->sloppy_function_map(), JS_OBJECT_TYPE, JSObject::kHeaderSize);
function_share, function->set_initial_map(*initial_map);
heap->undefined_value())->ToObjectChecked()); JSReceiver::SetProperty(global, func_name, function, NONE, SLOPPY).Check();
Map* initial_map =
Map::cast(heap->AllocateMap(JS_OBJECT_TYPE, factory->NewJSObject(function);
JSObject::kHeaderSize)->ToObjectChecked()); }
function->set_initial_map(initial_map);
JSReceiver::SetProperty(
global, handle(func_name), handle(function), NONE, SLOPPY).Check();
JSObject* obj = JSObject::cast(
heap->AllocateJSObject(function)->ToObjectChecked());
heap->CollectGarbage(OLD_POINTER_SPACE, "trigger 4"); heap->CollectGarbage(OLD_POINTER_SPACE, "trigger 4");
func_name = String::cast( { HandleScope scope(isolate);
heap->InternalizeUtf8String("theFunction")->ToObjectChecked()); Handle<String> func_name = factory->InternalizeUtf8String("theFunction");
CHECK(JSReceiver::HasLocalProperty(global, handle(func_name))); CHECK(JSReceiver::HasLocalProperty(global, func_name));
Object* func_value = isolate->context()->global_object()-> Handle<Object> func_value = Object::GetProperty(global, func_name);
GetProperty(func_name)->ToObjectChecked(); CHECK(func_value->IsJSFunction());
CHECK(func_value->IsJSFunction()); Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
function = JSFunction::cast(func_value); Handle<JSObject> obj = factory->NewJSObject(function);
obj = JSObject::cast(heap->AllocateJSObject(function)->ToObjectChecked()); Handle<String> obj_name = factory->InternalizeUtf8String("theObject");
String* obj_name = JSReceiver::SetProperty(global, obj_name, obj, NONE, SLOPPY).Check();
String::cast(heap->InternalizeUtf8String("theObject")->ToObjectChecked()); Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
JSReceiver::SetProperty( Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
global, handle(obj_name), handle(obj), NONE, SLOPPY).Check(); JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check();
String* prop_name = }
String::cast(heap->InternalizeUtf8String("theSlot")->ToObjectChecked());
Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
JSReceiver::SetProperty(
handle(obj), handle(prop_name), twenty_three, NONE, SLOPPY).Check();
heap->CollectGarbage(OLD_POINTER_SPACE, "trigger 5"); heap->CollectGarbage(OLD_POINTER_SPACE, "trigger 5");
obj_name = { HandleScope scope(isolate);
String::cast(heap->InternalizeUtf8String("theObject")->ToObjectChecked()); Handle<String> obj_name = factory->InternalizeUtf8String("theObject");
CHECK(JSReceiver::HasLocalProperty(global, handle(obj_name))); CHECK(JSReceiver::HasLocalProperty(global, obj_name));
CHECK(isolate->context()->global_object()-> Handle<Object> object = Object::GetProperty(global, obj_name);
GetProperty(obj_name)->ToObjectChecked()->IsJSObject()); CHECK(object->IsJSObject());
obj = JSObject::cast(isolate->context()->global_object()-> Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
GetProperty(obj_name)->ToObjectChecked()); CHECK_EQ(*Object::GetProperty(object, prop_name), Smi::FromInt(23));
prop_name = }
String::cast(heap->InternalizeUtf8String("theSlot")->ToObjectChecked());
CHECK(obj->GetProperty(prop_name) == Smi::FromInt(23));
} }