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:
parent
66d63594bc
commit
aee76a059a
12
src/api.cc
12
src/api.cc
@ -2036,10 +2036,10 @@ static i::Handle<i::Object> CallV8HeapFunction(const char* name,
|
||||
i::Isolate* isolate = i::Isolate::Current();
|
||||
i::Handle<i::String> fmt_str =
|
||||
isolate->factory()->InternalizeUtf8String(name);
|
||||
i::Object* object_fun =
|
||||
isolate->js_builtins_object()->GetPropertyNoExceptionThrown(*fmt_str);
|
||||
i::Handle<i::JSFunction> fun =
|
||||
i::Handle<i::JSFunction>(i::JSFunction::cast(object_fun));
|
||||
i::Handle<i::Object> object_fun =
|
||||
i::GlobalObject::GetPropertyNoExceptionThrown(
|
||||
isolate->js_builtins_object(), fmt_str);
|
||||
i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(object_fun);
|
||||
i::Handle<i::Object> value = i::Execution::Call(
|
||||
isolate, fun, recv, argc, argv, has_pending_exception);
|
||||
return value;
|
||||
@ -2484,8 +2484,8 @@ static i::Object* LookupBuiltin(i::Isolate* isolate,
|
||||
const char* builtin_name) {
|
||||
i::Handle<i::String> string =
|
||||
isolate->factory()->InternalizeUtf8String(builtin_name);
|
||||
i::Handle<i::JSBuiltinsObject> builtins = isolate->js_builtins_object();
|
||||
return builtins->GetPropertyNoExceptionThrown(*string);
|
||||
return *i::GlobalObject::GetPropertyNoExceptionThrown(
|
||||
isolate->js_builtins_object(), string);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1515,13 +1515,12 @@ bool Genesis::CompileScriptCached(Isolate* isolate,
|
||||
}
|
||||
|
||||
|
||||
#define INSTALL_NATIVE(Type, name, var) \
|
||||
Handle<String> var##_name = \
|
||||
factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \
|
||||
Object* var##_native = \
|
||||
native_context()->builtins()->GetPropertyNoExceptionThrown( \
|
||||
*var##_name); \
|
||||
native_context()->set_##var(Type::cast(var##_native));
|
||||
#define INSTALL_NATIVE(Type, name, var) \
|
||||
Handle<String> var##_name = \
|
||||
factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \
|
||||
Handle<Object> var##_native = GlobalObject::GetPropertyNoExceptionThrown( \
|
||||
handle(native_context()->builtins()), var##_name); \
|
||||
native_context()->set_##var(Type::cast(*var##_native));
|
||||
|
||||
|
||||
void Genesis::InstallNativeFunctions() {
|
||||
@ -2054,8 +2053,9 @@ static void InstallBuiltinFunctionId(Handle<JSObject> holder,
|
||||
BuiltinFunctionId id) {
|
||||
Factory* factory = holder->GetIsolate()->factory();
|
||||
Handle<String> name = factory->InternalizeUtf8String(function_name);
|
||||
Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked();
|
||||
Handle<JSFunction> function(JSFunction::cast(function_object));
|
||||
Handle<Object> function_object = Object::GetProperty(holder, name);
|
||||
ASSERT(!function_object.is_null());
|
||||
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
|
||||
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);
|
||||
Handle<String> name =
|
||||
factory()->InternalizeUtf8String(Builtins::GetName(id));
|
||||
Object* function_object = builtins->GetPropertyNoExceptionThrown(*name);
|
||||
Handle<JSFunction> function
|
||||
= Handle<JSFunction>(JSFunction::cast(function_object));
|
||||
Handle<Object> function_object =
|
||||
GlobalObject::GetPropertyNoExceptionThrown(builtins, name);
|
||||
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
|
||||
builtins->set_javascript_builtin(id, *function);
|
||||
if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) {
|
||||
return false;
|
||||
|
23
src/debug.cc
23
src/debug.cc
@ -1116,10 +1116,10 @@ bool Debug::CheckBreakPoint(Handle<Object> break_point_object) {
|
||||
Handle<String> is_break_point_triggered_string =
|
||||
factory->InternalizeOneByteString(
|
||||
STATIC_ASCII_VECTOR("IsBreakPointTriggered"));
|
||||
Handle<GlobalObject> debug_global(debug_context()->global_object());
|
||||
Handle<JSFunction> check_break_point =
|
||||
Handle<JSFunction>(JSFunction::cast(
|
||||
debug_context()->global_object()->GetPropertyNoExceptionThrown(
|
||||
*is_break_point_triggered_string)));
|
||||
Handle<JSFunction>::cast(GlobalObject::GetPropertyNoExceptionThrown(
|
||||
debug_global, is_break_point_triggered_string));
|
||||
|
||||
// Get the break id as an object.
|
||||
Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id());
|
||||
@ -2463,9 +2463,8 @@ void Debug::ClearMirrorCache() {
|
||||
// Clear the mirror cache.
|
||||
Handle<String> function_name = isolate_->factory()->InternalizeOneByteString(
|
||||
STATIC_ASCII_VECTOR("ClearMirrorCache"));
|
||||
Handle<Object> fun(
|
||||
isolate_->global_object()->GetPropertyNoExceptionThrown(*function_name),
|
||||
isolate_);
|
||||
Handle<Object> fun = GlobalObject::GetPropertyNoExceptionThrown(
|
||||
isolate_->global_object(), function_name);
|
||||
ASSERT(fun->IsJSFunction());
|
||||
bool caught_exception;
|
||||
Execution::TryCall(Handle<JSFunction>::cast(fun),
|
||||
@ -2601,9 +2600,8 @@ Handle<Object> Debugger::MakeJSObject(Vector<const char> constructor_name,
|
||||
Handle<String> constructor_str =
|
||||
isolate_->factory()->InternalizeUtf8String(constructor_name);
|
||||
ASSERT(!constructor_str.is_null());
|
||||
Handle<Object> constructor(
|
||||
isolate_->global_object()->GetPropertyNoExceptionThrown(*constructor_str),
|
||||
isolate_);
|
||||
Handle<Object> constructor = GlobalObject::GetPropertyNoExceptionThrown(
|
||||
isolate_->global_object(), constructor_str);
|
||||
ASSERT(constructor->IsJSFunction());
|
||||
if (!constructor->IsJSFunction()) {
|
||||
*caught_exception = true;
|
||||
@ -2833,11 +2831,10 @@ void Debugger::OnAfterCompile(Handle<Script> script,
|
||||
Handle<String> update_script_break_points_string =
|
||||
isolate_->factory()->InternalizeOneByteString(
|
||||
STATIC_ASCII_VECTOR("UpdateScriptBreakPoints"));
|
||||
Handle<GlobalObject> debug_global(debug->debug_context()->global_object());
|
||||
Handle<Object> update_script_break_points =
|
||||
Handle<Object>(
|
||||
debug->debug_context()->global_object()->GetPropertyNoExceptionThrown(
|
||||
*update_script_break_points_string),
|
||||
isolate_);
|
||||
GlobalObject::GetPropertyNoExceptionThrown(
|
||||
debug_global, update_script_break_points_string);
|
||||
if (!update_script_break_points->IsJSFunction()) {
|
||||
return;
|
||||
}
|
||||
|
@ -1128,9 +1128,8 @@ Handle<Object> Factory::NewError(const char* maker,
|
||||
const char* message,
|
||||
Handle<JSArray> args) {
|
||||
Handle<String> make_str = InternalizeUtf8String(maker);
|
||||
Handle<Object> fun_obj(
|
||||
isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str),
|
||||
isolate());
|
||||
Handle<Object> fun_obj = GlobalObject::GetPropertyNoExceptionThrown(
|
||||
isolate()->js_builtins_object(), make_str);
|
||||
// If the builtins haven't been properly configured yet this error
|
||||
// constructor may not have been defined. Bail out.
|
||||
if (!fun_obj->IsJSFunction()) {
|
||||
@ -1160,9 +1159,9 @@ Handle<Object> Factory::NewError(Handle<String> message) {
|
||||
Handle<Object> Factory::NewError(const char* constructor,
|
||||
Handle<String> message) {
|
||||
Handle<String> constr = InternalizeUtf8String(constructor);
|
||||
Handle<JSFunction> fun = Handle<JSFunction>(
|
||||
JSFunction::cast(isolate()->js_builtins_object()->
|
||||
GetPropertyNoExceptionThrown(*constr)));
|
||||
Handle<JSFunction> fun = Handle<JSFunction>::cast(
|
||||
GlobalObject::GetPropertyNoExceptionThrown(
|
||||
isolate()->js_builtins_object(), constr));
|
||||
Handle<Object> argv[] = { message };
|
||||
|
||||
// Invoke the JavaScript factory method. If an exception is thrown while
|
||||
|
@ -1046,15 +1046,17 @@ bool Isolate::ShouldReportException(bool* can_be_caught_externally,
|
||||
bool Isolate::IsErrorObject(Handle<Object> obj) {
|
||||
if (!obj->IsJSObject()) return false;
|
||||
|
||||
String* error_key =
|
||||
*(factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("$Error")));
|
||||
Object* error_constructor =
|
||||
js_builtins_object()->GetPropertyNoExceptionThrown(error_key);
|
||||
Handle<String> error_key =
|
||||
factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("$Error"));
|
||||
Handle<Object> error_constructor = GlobalObject::GetPropertyNoExceptionThrown(
|
||||
js_builtins_object(), error_key);
|
||||
|
||||
DisallowHeapAllocation no_gc;
|
||||
for (Object* prototype = *obj; !prototype->IsNull();
|
||||
prototype = prototype->GetPrototype(this)) {
|
||||
if (!prototype->IsJSObject()) return false;
|
||||
if (JSObject::cast(prototype)->map()->constructor() == error_constructor) {
|
||||
if (JSObject::cast(prototype)->map()->constructor() ==
|
||||
*error_constructor) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -154,11 +154,9 @@ Handle<String> MessageHandler::GetMessage(Isolate* isolate,
|
||||
Factory* factory = isolate->factory();
|
||||
Handle<String> fmt_str =
|
||||
factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("FormatMessage"));
|
||||
Handle<JSFunction> fun =
|
||||
Handle<JSFunction>(
|
||||
JSFunction::cast(
|
||||
isolate->js_builtins_object()->
|
||||
GetPropertyNoExceptionThrown(*fmt_str)));
|
||||
Handle<JSFunction> fun = Handle<JSFunction>::cast(
|
||||
GlobalObject::GetPropertyNoExceptionThrown(
|
||||
isolate->js_builtins_object(), fmt_str));
|
||||
Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data);
|
||||
Handle<Object> argv[] = { Handle<Object>(message->type(), isolate),
|
||||
Handle<Object>(message->arguments(), isolate) };
|
||||
|
@ -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) {
|
||||
if (other == this) return true;
|
||||
if ((this->IsInternalizedString() && other->IsInternalizedString()) ||
|
||||
|
@ -7776,10 +7776,9 @@ class GlobalObject: public JSObject {
|
||||
// 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
|
||||
// on the object.
|
||||
Object* GetPropertyNoExceptionThrown(Name* key) {
|
||||
Object* answer = GetProperty(key)->ToObjectUnchecked();
|
||||
return answer;
|
||||
}
|
||||
static inline Handle<Object> GetPropertyNoExceptionThrown(
|
||||
Handle<GlobalObject> global,
|
||||
Handle<Name> name);
|
||||
|
||||
// Casting.
|
||||
static inline GlobalObject* cast(Object* obj);
|
||||
|
@ -6045,14 +6045,16 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) {
|
||||
return frame->GetParameter(index);
|
||||
}
|
||||
|
||||
HandleScope scope(isolate);
|
||||
if (args[0]->IsSymbol()) {
|
||||
// Lookup in the initial Object.prototype object.
|
||||
return isolate->initial_object_prototype()->GetProperty(
|
||||
Symbol::cast(args[0]));
|
||||
Handle<Object> result = Object::GetProperty(
|
||||
isolate->initial_object_prototype(), args.at<Symbol>(0));
|
||||
RETURN_IF_EMPTY_HANDLE(isolate, result);
|
||||
return *result;
|
||||
}
|
||||
|
||||
// Convert the key to a string.
|
||||
HandleScope scope(isolate);
|
||||
bool exception = false;
|
||||
Handle<Object> converted =
|
||||
Execution::ToString(isolate, args.at<Object>(0), &exception);
|
||||
@ -6084,7 +6086,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) {
|
||||
}
|
||||
|
||||
// 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
|
||||
// GetProperty function.
|
||||
MaybeObject* value = object->GetProperty(*name);
|
||||
return MakePair(value, *receiver_handle);
|
||||
Handle<Object> value = Object::GetProperty(object, name);
|
||||
RETURN_IF_EMPTY_HANDLE_VALUE(
|
||||
isolate, value, MakePair(Failure::Exception(), NULL));
|
||||
return MakePair(*value, *receiver_handle);
|
||||
}
|
||||
|
||||
if (throw_error) {
|
||||
|
@ -36,11 +36,12 @@
|
||||
|
||||
using namespace v8::internal;
|
||||
|
||||
static MaybeObject* GetGlobalProperty(const char* name) {
|
||||
static Handle<Object> GetGlobalProperty(const char* name) {
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
Handle<String> internalized_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());
|
||||
Execution::Call(isolate, fun, global, 0, NULL, &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());
|
||||
Execution::Call(isolate, fun, global, 0, NULL, &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());
|
||||
Execution::Call(isolate, fun, global, 0, NULL, &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());
|
||||
Execution::Call(isolate, fun, global, 0, NULL, &has_pending_exception);
|
||||
CHECK(!has_pending_exception);
|
||||
return GetGlobalProperty("result")->ToObjectChecked()->Number();
|
||||
return GetGlobalProperty("result")->Number();
|
||||
}
|
||||
|
||||
|
||||
@ -204,7 +205,7 @@ TEST(Stuff) {
|
||||
Execution::Call(
|
||||
CcTest::i_isolate(), fun, global, 0, NULL, &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);
|
||||
CHECK(!has_pending_exception);
|
||||
|
||||
Object* foo_string = isolate->factory()->InternalizeOneByteString(
|
||||
STATIC_ASCII_VECTOR("foo"))->ToObjectChecked();
|
||||
MaybeObject* fun1_object = isolate->context()->global_object()->
|
||||
GetProperty(String::cast(foo_string));
|
||||
Handle<Object> fun1(fun1_object->ToObjectChecked(), isolate);
|
||||
Handle<String> foo_string = isolate->factory()->InternalizeOneByteString(
|
||||
STATIC_ASCII_VECTOR("foo"));
|
||||
Handle<Object> fun1 = Object::GetProperty(
|
||||
isolate->global_object(), foo_string);
|
||||
CHECK(fun1->IsJSFunction());
|
||||
|
||||
Handle<Object> argv[] = { isolate->factory()->InternalizeOneByteString(
|
||||
|
@ -293,8 +293,8 @@ TEST(GarbageCollection) {
|
||||
JSReceiver::SetProperty(
|
||||
obj, prop_namex, twenty_four, NONE, SLOPPY).Check();
|
||||
|
||||
CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name));
|
||||
CHECK_EQ(Smi::FromInt(24), obj->GetProperty(*prop_namex));
|
||||
CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(obj, prop_name));
|
||||
CHECK_EQ(Smi::FromInt(24), *Object::GetProperty(obj, prop_namex));
|
||||
}
|
||||
|
||||
heap->CollectGarbage(NEW_SPACE);
|
||||
@ -302,10 +302,9 @@ TEST(GarbageCollection) {
|
||||
// Function should be alive.
|
||||
CHECK(JSReceiver::HasLocalProperty(global, name));
|
||||
// Check function is retained.
|
||||
Object* func_value = CcTest::i_isolate()->context()->global_object()->
|
||||
GetProperty(*name)->ToObjectChecked();
|
||||
Handle<Object> func_value = Object::GetProperty(global, name);
|
||||
CHECK(func_value->IsJSFunction());
|
||||
Handle<JSFunction> function(JSFunction::cast(func_value));
|
||||
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
|
||||
|
||||
{
|
||||
HandleScope inner_scope(isolate);
|
||||
@ -320,12 +319,9 @@ TEST(GarbageCollection) {
|
||||
heap->CollectGarbage(NEW_SPACE);
|
||||
|
||||
CHECK(JSReceiver::HasLocalProperty(global, obj_name));
|
||||
CHECK(CcTest::i_isolate()->context()->global_object()->
|
||||
GetProperty(*obj_name)->ToObjectChecked()->IsJSObject());
|
||||
Object* obj = CcTest::i_isolate()->context()->global_object()->
|
||||
GetProperty(*obj_name)->ToObjectChecked();
|
||||
JSObject* js_obj = JSObject::cast(obj);
|
||||
CHECK_EQ(Smi::FromInt(23), js_obj->GetProperty(*prop_name));
|
||||
Handle<Object> obj = Object::GetProperty(global, obj_name);
|
||||
CHECK(obj->IsJSObject());
|
||||
CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(obj, prop_name));
|
||||
}
|
||||
|
||||
|
||||
@ -649,11 +645,11 @@ TEST(FunctionAllocation) {
|
||||
Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
|
||||
Handle<JSObject> obj = factory->NewJSObject(function);
|
||||
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.
|
||||
JSReceiver::SetProperty(
|
||||
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();
|
||||
|
||||
v8::HandleScope sc(CcTest::isolate());
|
||||
String* object_string = String::cast(CcTest::heap()->Object_string());
|
||||
Object* raw_object = CcTest::i_isolate()->context()->global_object()->
|
||||
GetProperty(object_string)->ToObjectChecked();
|
||||
JSFunction* object_function = JSFunction::cast(raw_object);
|
||||
Handle<JSFunction> constructor(object_function);
|
||||
Handle<String> object_string(String::cast(CcTest::heap()->Object_string()));
|
||||
Handle<Object> object =
|
||||
Object::GetProperty(CcTest::i_isolate()->global_object(), object_string);
|
||||
Handle<JSFunction> constructor = Handle<JSFunction>::cast(object);
|
||||
Handle<JSObject> obj = factory->NewJSObject(constructor);
|
||||
Handle<String> first = factory->InternalizeUtf8String("first");
|
||||
Handle<String> second = factory->InternalizeUtf8String("second");
|
||||
@ -747,7 +742,7 @@ TEST(JSObjectMaps) {
|
||||
// Set a propery
|
||||
Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
|
||||
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(*initial_map != obj->map());
|
||||
@ -761,10 +756,9 @@ TEST(JSArray) {
|
||||
|
||||
v8::HandleScope sc(CcTest::isolate());
|
||||
Handle<String> name = factory->InternalizeUtf8String("Array");
|
||||
Object* raw_object = CcTest::i_isolate()->context()->global_object()->
|
||||
GetProperty(*name)->ToObjectChecked();
|
||||
Handle<JSFunction> function = Handle<JSFunction>(
|
||||
JSFunction::cast(raw_object));
|
||||
Handle<Object> fun_obj =
|
||||
Object::GetProperty(CcTest::i_isolate()->global_object(), name);
|
||||
Handle<JSFunction> function = Handle<JSFunction>::cast(fun_obj);
|
||||
|
||||
// Allocate the object.
|
||||
Handle<JSObject> object = factory->NewJSObject(function);
|
||||
@ -809,11 +803,10 @@ TEST(JSObjectCopy) {
|
||||
Factory* factory = isolate->factory();
|
||||
|
||||
v8::HandleScope sc(CcTest::isolate());
|
||||
String* object_string = String::cast(CcTest::heap()->Object_string());
|
||||
Object* raw_object = CcTest::i_isolate()->context()->global_object()->
|
||||
GetProperty(object_string)->ToObjectChecked();
|
||||
JSFunction* object_function = JSFunction::cast(raw_object);
|
||||
Handle<JSFunction> constructor(object_function);
|
||||
Handle<String> object_string(String::cast(CcTest::heap()->Object_string()));
|
||||
Handle<Object> object =
|
||||
Object::GetProperty(CcTest::i_isolate()->global_object(), object_string);
|
||||
Handle<JSFunction> constructor = Handle<JSFunction>::cast(object);
|
||||
Handle<JSObject> obj = factory->NewJSObject(constructor);
|
||||
Handle<String> first = factory->InternalizeUtf8String("first");
|
||||
Handle<String> second = factory->InternalizeUtf8String("second");
|
||||
@ -836,8 +829,10 @@ TEST(JSObjectCopy) {
|
||||
CHECK_EQ(*i::Object::GetElement(isolate, obj, 1),
|
||||
*i::Object::GetElement(isolate, clone, 1));
|
||||
|
||||
CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first));
|
||||
CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second));
|
||||
CHECK_EQ(*Object::GetProperty(obj, first),
|
||||
*Object::GetProperty(clone, first));
|
||||
CHECK_EQ(*Object::GetProperty(obj, second),
|
||||
*Object::GetProperty(clone, second));
|
||||
|
||||
// Flip the values.
|
||||
JSReceiver::SetProperty(clone, first, two, NONE, SLOPPY).Check();
|
||||
@ -851,8 +846,10 @@ TEST(JSObjectCopy) {
|
||||
CHECK_EQ(*i::Object::GetElement(isolate, obj, 0),
|
||||
*i::Object::GetElement(isolate, clone, 1));
|
||||
|
||||
CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first));
|
||||
CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second));
|
||||
CHECK_EQ(*Object::GetProperty(obj, 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.
|
||||
Object* func_value = CcTest::i_isolate()->context()->global_object()->
|
||||
GetProperty(*foo_name)->ToObjectChecked();
|
||||
Handle<Object> func_value =
|
||||
Object::GetProperty(CcTest::i_isolate()->global_object(), foo_name);
|
||||
CHECK(func_value->IsJSFunction());
|
||||
Handle<JSFunction> function(JSFunction::cast(func_value));
|
||||
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
|
||||
CHECK(function->shared()->is_compiled());
|
||||
|
||||
// The code will survive at least two GCs.
|
||||
@ -1104,7 +1101,7 @@ TEST(TestCodeFlushingPreAged) {
|
||||
i::FLAG_allow_natives_syntax = true;
|
||||
i::FLAG_optimize_for_size = true;
|
||||
CcTest::InitializeVM();
|
||||
Isolate* isolate = Isolate::Current();
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
Factory* factory = isolate->factory();
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
const char* source = "function foo() {"
|
||||
@ -1121,10 +1118,10 @@ TEST(TestCodeFlushingPreAged) {
|
||||
}
|
||||
|
||||
// Check function is compiled.
|
||||
Object* func_value = Isolate::Current()->context()->global_object()->
|
||||
GetProperty(*foo_name)->ToObjectChecked();
|
||||
Handle<Object> func_value =
|
||||
Object::GetProperty(isolate->global_object(), foo_name);
|
||||
CHECK(func_value->IsJSFunction());
|
||||
Handle<JSFunction> function(JSFunction::cast(func_value));
|
||||
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
|
||||
CHECK(function->shared()->is_compiled());
|
||||
|
||||
// The code has been run so will survive at least one GC.
|
||||
@ -1186,10 +1183,10 @@ TEST(TestCodeFlushingIncremental) {
|
||||
}
|
||||
|
||||
// Check function is compiled.
|
||||
Object* func_value = CcTest::i_isolate()->context()->global_object()->
|
||||
GetProperty(*foo_name)->ToObjectChecked();
|
||||
Handle<Object> func_value =
|
||||
Object::GetProperty(isolate->global_object(), foo_name);
|
||||
CHECK(func_value->IsJSFunction());
|
||||
Handle<JSFunction> function(JSFunction::cast(func_value));
|
||||
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
|
||||
CHECK(function->shared()->is_compiled());
|
||||
|
||||
// The code will survive at least two GCs.
|
||||
@ -1263,15 +1260,15 @@ TEST(TestCodeFlushingIncrementalScavenge) {
|
||||
}
|
||||
|
||||
// Check functions are compiled.
|
||||
Object* func_value = CcTest::i_isolate()->context()->global_object()->
|
||||
GetProperty(*foo_name)->ToObjectChecked();
|
||||
Handle<Object> func_value =
|
||||
Object::GetProperty(isolate->global_object(), foo_name);
|
||||
CHECK(func_value->IsJSFunction());
|
||||
Handle<JSFunction> function(JSFunction::cast(func_value));
|
||||
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
|
||||
CHECK(function->shared()->is_compiled());
|
||||
Object* func_value2 = CcTest::i_isolate()->context()->global_object()->
|
||||
GetProperty(*bar_name)->ToObjectChecked();
|
||||
Handle<Object> func_value2 =
|
||||
Object::GetProperty(isolate->global_object(), bar_name);
|
||||
CHECK(func_value2->IsJSFunction());
|
||||
Handle<JSFunction> function2(JSFunction::cast(func_value2));
|
||||
Handle<JSFunction> function2 = Handle<JSFunction>::cast(func_value2);
|
||||
CHECK(function2->shared()->is_compiled());
|
||||
|
||||
// Clear references to functions so that one of them can die.
|
||||
@ -1325,10 +1322,10 @@ TEST(TestCodeFlushingIncrementalAbort) {
|
||||
}
|
||||
|
||||
// Check function is compiled.
|
||||
Object* func_value = CcTest::i_isolate()->context()->global_object()->
|
||||
GetProperty(*foo_name)->ToObjectChecked();
|
||||
Handle<Object> func_value =
|
||||
Object::GetProperty(isolate->global_object(), foo_name);
|
||||
CHECK(func_value->IsJSFunction());
|
||||
Handle<JSFunction> function(JSFunction::cast(func_value));
|
||||
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
|
||||
CHECK(function->shared()->is_compiled());
|
||||
|
||||
// The code will survive at least two GCs.
|
||||
|
@ -128,6 +128,7 @@ TEST(MarkCompactCollector) {
|
||||
CcTest::InitializeVM();
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
Heap* heap = isolate->heap();
|
||||
Factory* factory = isolate->factory();
|
||||
|
||||
v8::HandleScope sc(CcTest::isolate());
|
||||
Handle<GlobalObject> global(isolate->context()->global_object());
|
||||
@ -143,70 +144,57 @@ TEST(MarkCompactCollector) {
|
||||
maybe_array = heap->AllocateFixedArray(ARRAY_SIZE);
|
||||
} while (maybe_array->ToObject(&array));
|
||||
heap->CollectGarbage(NEW_SPACE, "trigger 2");
|
||||
|
||||
array = heap->AllocateFixedArray(ARRAY_SIZE)->ToObjectChecked();
|
||||
heap->AllocateFixedArray(ARRAY_SIZE)->ToObjectChecked();
|
||||
|
||||
// keep allocating maps until it fails
|
||||
Object* mapp;
|
||||
MaybeObject* maybe_mapp;
|
||||
Object* map;
|
||||
MaybeObject* maybe_map;
|
||||
do {
|
||||
maybe_mapp = heap->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
|
||||
} while (maybe_mapp->ToObject(&mapp));
|
||||
maybe_map = heap->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
|
||||
} while (maybe_map->ToObject(&map));
|
||||
heap->CollectGarbage(MAP_SPACE, "trigger 3");
|
||||
mapp = heap->AllocateMap(JS_OBJECT_TYPE,
|
||||
JSObject::kHeaderSize)->ToObjectChecked();
|
||||
heap->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize)->ToObjectChecked();
|
||||
|
||||
// allocate a garbage
|
||||
String* func_name = String::cast(
|
||||
heap->InternalizeUtf8String("theFunction")->ToObjectChecked());
|
||||
SharedFunctionInfo* function_share = SharedFunctionInfo::cast(
|
||||
heap->AllocateSharedFunctionInfo(func_name)->ToObjectChecked());
|
||||
JSFunction* function = JSFunction::cast(
|
||||
heap->AllocateFunction(*isolate->sloppy_function_map(),
|
||||
function_share,
|
||||
heap->undefined_value())->ToObjectChecked());
|
||||
Map* initial_map =
|
||||
Map::cast(heap->AllocateMap(JS_OBJECT_TYPE,
|
||||
JSObject::kHeaderSize)->ToObjectChecked());
|
||||
function->set_initial_map(initial_map);
|
||||
JSReceiver::SetProperty(
|
||||
global, handle(func_name), handle(function), NONE, SLOPPY).Check();
|
||||
{ HandleScope scope(isolate);
|
||||
// allocate a garbage
|
||||
Handle<String> func_name = factory->InternalizeUtf8String("theFunction");
|
||||
Handle<JSFunction> function = factory->NewFunction(
|
||||
func_name, factory->undefined_value());
|
||||
Handle<Map> initial_map = factory->NewMap(
|
||||
JS_OBJECT_TYPE, JSObject::kHeaderSize);
|
||||
function->set_initial_map(*initial_map);
|
||||
JSReceiver::SetProperty(global, func_name, function, NONE, SLOPPY).Check();
|
||||
|
||||
factory->NewJSObject(function);
|
||||
}
|
||||
|
||||
JSObject* obj = JSObject::cast(
|
||||
heap->AllocateJSObject(function)->ToObjectChecked());
|
||||
heap->CollectGarbage(OLD_POINTER_SPACE, "trigger 4");
|
||||
|
||||
func_name = String::cast(
|
||||
heap->InternalizeUtf8String("theFunction")->ToObjectChecked());
|
||||
CHECK(JSReceiver::HasLocalProperty(global, handle(func_name)));
|
||||
Object* func_value = isolate->context()->global_object()->
|
||||
GetProperty(func_name)->ToObjectChecked();
|
||||
CHECK(func_value->IsJSFunction());
|
||||
function = JSFunction::cast(func_value);
|
||||
{ HandleScope scope(isolate);
|
||||
Handle<String> func_name = factory->InternalizeUtf8String("theFunction");
|
||||
CHECK(JSReceiver::HasLocalProperty(global, func_name));
|
||||
Handle<Object> func_value = Object::GetProperty(global, func_name);
|
||||
CHECK(func_value->IsJSFunction());
|
||||
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
|
||||
Handle<JSObject> obj = factory->NewJSObject(function);
|
||||
|
||||
obj = JSObject::cast(heap->AllocateJSObject(function)->ToObjectChecked());
|
||||
String* obj_name =
|
||||
String::cast(heap->InternalizeUtf8String("theObject")->ToObjectChecked());
|
||||
JSReceiver::SetProperty(
|
||||
global, handle(obj_name), handle(obj), 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();
|
||||
Handle<String> obj_name = factory->InternalizeUtf8String("theObject");
|
||||
JSReceiver::SetProperty(global, obj_name, obj, NONE, SLOPPY).Check();
|
||||
Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
|
||||
Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
|
||||
JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, SLOPPY).Check();
|
||||
}
|
||||
|
||||
heap->CollectGarbage(OLD_POINTER_SPACE, "trigger 5");
|
||||
|
||||
obj_name =
|
||||
String::cast(heap->InternalizeUtf8String("theObject")->ToObjectChecked());
|
||||
CHECK(JSReceiver::HasLocalProperty(global, handle(obj_name)));
|
||||
CHECK(isolate->context()->global_object()->
|
||||
GetProperty(obj_name)->ToObjectChecked()->IsJSObject());
|
||||
obj = JSObject::cast(isolate->context()->global_object()->
|
||||
GetProperty(obj_name)->ToObjectChecked());
|
||||
prop_name =
|
||||
String::cast(heap->InternalizeUtf8String("theSlot")->ToObjectChecked());
|
||||
CHECK(obj->GetProperty(prop_name) == Smi::FromInt(23));
|
||||
{ HandleScope scope(isolate);
|
||||
Handle<String> obj_name = factory->InternalizeUtf8String("theObject");
|
||||
CHECK(JSReceiver::HasLocalProperty(global, obj_name));
|
||||
Handle<Object> object = Object::GetProperty(global, obj_name);
|
||||
CHECK(object->IsJSObject());
|
||||
Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
|
||||
CHECK_EQ(*Object::GetProperty(object, prop_name), Smi::FromInt(23));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user