Handlify GetProperty.

R=ishell@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20682 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2014-04-11 11:26:22 +00:00
parent dd2af36493
commit a3d68ca64d
20 changed files with 257 additions and 350 deletions

View File

@ -1948,8 +1948,10 @@ v8::Local<Value> v8::TryCatch::StackTrace() const {
i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_);
i::Handle<i::String> name = isolate_->factory()->stack_string();
if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local<Value>();
i::Handle<i::Object> value = i::Object::GetProperty(obj, name);
if (value.is_null()) return v8::Local<Value>();
i::Handle<i::Object> value;
if (!i::Object::GetProperty(obj, name).ToHandle(&value)) {
return v8::Local<Value>();
}
return v8::Utils::ToLocal(scope.CloseAndEscape(value));
} else {
return v8::Local<Value>();
@ -2044,8 +2046,8 @@ MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction(
i::Handle<i::String> fmt_str =
isolate->factory()->InternalizeUtf8String(name);
i::Handle<i::Object> object_fun =
i::GlobalObject::GetPropertyNoExceptionThrown(
isolate->js_builtins_object(), fmt_str);
i::Object::GetProperty(
isolate->js_builtins_object(), fmt_str).ToHandleChecked();
i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(object_fun);
return i::Execution::Call(isolate, fun, recv, argc, argv);
}
@ -2175,7 +2177,7 @@ Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
i::Handle<i::JSArray> self = Utils::OpenHandle(this);
i::Handle<i::Object> obj =
i::Object::GetElementNoExceptionThrown(isolate, self, index);
i::Object::GetElement(isolate, self, index).ToHandleChecked();
i::Handle<i::JSObject> jsobj = i::Handle<i::JSObject>::cast(obj);
return scope.Escape(Utils::StackFrameToLocal(jsobj));
}
@ -2490,8 +2492,8 @@ static i::Object* LookupBuiltin(i::Isolate* isolate,
const char* builtin_name) {
i::Handle<i::String> 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();
}
@ -7004,8 +7006,8 @@ Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) {
isolate_debug->debug_context()->global_object());
i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("MakeMirror"));
i::Handle<i::Object> fun_obj = i::Object::GetProperty(debug, name);
ASSERT(!fun_obj.is_null());
i::Handle<i::Object> fun_obj =
i::Object::GetProperty(debug, name).ToHandleChecked();
i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj);
v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun);
const int kArgc = 1;

View File

@ -1515,9 +1515,9 @@ bool Genesis::CompileScriptCached(Isolate* isolate,
#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); \
factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \
Handle<Object> var##_native = Object::GetProperty( \
handle(native_context()->builtins()), var##_name).ToHandleChecked(); \
native_context()->set_##var(Type::cast(*var##_native));
@ -1893,7 +1893,7 @@ bool Genesis::InstallNatives() {
{ Handle<String> key = factory()->function_class_string();
Handle<JSFunction> function =
Handle<JSFunction>::cast(Object::GetProperty(
isolate()->global_object(), key));
isolate()->global_object(), key).ToHandleChecked());
Handle<JSObject> proto =
Handle<JSObject>(JSObject::cast(function->instance_prototype()));
@ -2042,7 +2042,7 @@ static Handle<JSObject> ResolveBuiltinIdHolder(
Handle<String> property_string = factory->InternalizeUtf8String(property);
ASSERT(!property_string.is_null());
Handle<JSFunction> function = Handle<JSFunction>::cast(
Object::GetProperty(global, property_string));
Object::GetProperty(global, property_string).ToHandleChecked());
return Handle<JSObject>(JSObject::cast(function->prototype()));
}
@ -2052,8 +2052,8 @@ static void InstallBuiltinFunctionId(Handle<JSObject> holder,
BuiltinFunctionId id) {
Factory* factory = holder->GetIsolate()->factory();
Handle<String> name = factory->InternalizeUtf8String(function_name);
Handle<Object> function_object = Object::GetProperty(holder, name);
ASSERT(!function_object.is_null());
Handle<Object> function_object =
Object::GetProperty(holder, name).ToHandleChecked();
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
function->shared()->set_function_data(Smi::FromInt(id));
}
@ -2349,7 +2349,7 @@ bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
Handle<String> name =
factory()->InternalizeUtf8String(Builtins::GetName(id));
Handle<Object> function_object =
GlobalObject::GetPropertyNoExceptionThrown(builtins, name);
Object::GetProperty(builtins, name).ToHandleChecked();
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
builtins->set_javascript_builtin(id, *function);
if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) {

View File

@ -1118,8 +1118,8 @@ bool Debug::CheckBreakPoint(Handle<Object> break_point_object) {
STATIC_ASCII_VECTOR("IsBreakPointTriggered"));
Handle<GlobalObject> debug_global(debug_context()->global_object());
Handle<JSFunction> check_break_point =
Handle<JSFunction>::cast(GlobalObject::GetPropertyNoExceptionThrown(
debug_global, is_break_point_triggered_string));
Handle<JSFunction>::cast(Object::GetProperty(
debug_global, is_break_point_triggered_string).ToHandleChecked());
// Get the break id as an object.
Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id());
@ -2459,8 +2459,8 @@ void Debug::ClearMirrorCache() {
// Clear the mirror cache.
Handle<String> function_name = isolate_->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("ClearMirrorCache"));
Handle<Object> fun = GlobalObject::GetPropertyNoExceptionThrown(
isolate_->global_object(), function_name);
Handle<Object> fun = Object::GetProperty(
isolate_->global_object(), function_name).ToHandleChecked();
ASSERT(fun->IsJSFunction());
Execution::TryCall(
Handle<JSFunction>::cast(fun),
@ -2597,8 +2597,8 @@ MaybeHandle<Object> Debugger::MakeJSObject(
Handle<String> constructor_str =
isolate_->factory()->InternalizeUtf8String(constructor_name);
ASSERT(!constructor_str.is_null());
Handle<Object> constructor = GlobalObject::GetPropertyNoExceptionThrown(
isolate_->global_object(), constructor_str);
Handle<Object> constructor = Object::GetProperty(
isolate_->global_object(), constructor_str).ToHandleChecked();
ASSERT(constructor->IsJSFunction());
if (!constructor->IsJSFunction()) return MaybeHandle<Object>();
return Execution::TryCall(
@ -2788,8 +2788,8 @@ void Debugger::OnAfterCompile(Handle<Script> script,
STATIC_ASCII_VECTOR("UpdateScriptBreakPoints"));
Handle<GlobalObject> debug_global(debug->debug_context()->global_object());
Handle<Object> update_script_break_points =
GlobalObject::GetPropertyNoExceptionThrown(
debug_global, update_script_break_points_string);
Object::GetProperty(
debug_global, update_script_break_points_string).ToHandleChecked();
if (!update_script_break_points->IsJSFunction()) {
return;
}

View File

@ -731,7 +731,8 @@ Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) {
}
Handle<Object> char_at = Object::GetProperty(
isolate->js_builtins_object(), factory->char_at_string());
isolate->js_builtins_object(),
factory->char_at_string()).ToHandleChecked();
if (!char_at->IsJSFunction()) {
return factory->undefined_value();
}
@ -758,7 +759,7 @@ MaybeHandle<JSFunction> Execution::InstantiateFunction(
int serial_number = Smi::cast(data->serial_number())->value();
Handle<JSObject> cache(isolate->native_context()->function_cache());
Handle<Object> elm =
Object::GetElementNoExceptionThrown(isolate, cache, serial_number);
Object::GetElement(isolate, cache, serial_number).ToHandleChecked();
if (elm->IsJSFunction()) return Handle<JSFunction>::cast(elm);
}
// The function has not yet been instantiated in this context; do it.

View File

@ -1122,7 +1122,7 @@ Handle<String> Factory::EmergencyNewError(const char* message,
space--;
if (space > 0) {
Handle<String> arg_str = Handle<String>::cast(
Object::GetElementNoExceptionThrown(isolate(), args, i));
Object::GetElement(isolate(), args, i).ToHandleChecked());
SmartArrayPointer<char> arg = arg_str->ToCString();
Vector<char> v2(p, static_cast<int>(space));
OS::StrNCpy(v2, arg.get(), space);
@ -1145,8 +1145,8 @@ Handle<Object> Factory::NewError(const char* maker,
const char* message,
Handle<JSArray> args) {
Handle<String> make_str = InternalizeUtf8String(maker);
Handle<Object> fun_obj = GlobalObject::GetPropertyNoExceptionThrown(
isolate()->js_builtins_object(), make_str);
Handle<Object> fun_obj = Object::GetProperty(
isolate()->js_builtins_object(), make_str).ToHandleChecked();
// If the builtins haven't been properly configured yet this error
// constructor may not have been defined. Bail out.
if (!fun_obj->IsJSFunction()) {
@ -1179,9 +1179,8 @@ 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>::cast(
GlobalObject::GetPropertyNoExceptionThrown(
isolate()->js_builtins_object(), constr));
Handle<JSFunction> fun = Handle<JSFunction>::cast(Object::GetProperty(
isolate()->js_builtins_object(), constr).ToHandleChecked());
Handle<Object> argv[] = { message };
// Invoke the JavaScript factory method. If an exception is thrown while

View File

@ -394,8 +394,8 @@ Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) {
isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("nameOrSourceURL"));
Handle<JSValue> script_wrapper = GetScriptWrapper(script);
Handle<Object> property =
Object::GetProperty(script_wrapper, name_or_source_url_key);
Handle<Object> property = Object::GetProperty(
script_wrapper, name_or_source_url_key).ToHandleChecked();
ASSERT(property->IsJSFunction());
Handle<JSFunction> method = Handle<JSFunction>::cast(property);
Handle<Object> result;

View File

@ -58,7 +58,7 @@ bool ExtractStringSetting(Isolate* isolate,
const char* key,
icu::UnicodeString* setting) {
Handle<String> str = isolate->factory()->NewStringFromAscii(CStrVector(key));
Handle<Object> object = Object::GetProperty(options, str);
Handle<Object> object = Object::GetProperty(options, str).ToHandleChecked();
if (object->IsString()) {
v8::String::Utf8Value utf8_string(
v8::Utils::ToLocal(Handle<String>::cast(object)));
@ -74,7 +74,7 @@ bool ExtractIntegerSetting(Isolate* isolate,
const char* key,
int32_t* value) {
Handle<String> str = isolate->factory()->NewStringFromAscii(CStrVector(key));
Handle<Object> object = Object::GetProperty(options, str);
Handle<Object> object = Object::GetProperty(options, str).ToHandleChecked();
if (object->IsNumber()) {
object->ToInt32(value);
return true;
@ -88,7 +88,7 @@ bool ExtractBooleanSetting(Isolate* isolate,
const char* key,
bool* value) {
Handle<String> str = isolate->factory()->NewStringFromAscii(CStrVector(key));
Handle<Object> object = Object::GetProperty(options, str);
Handle<Object> object = Object::GetProperty(options, str).ToHandleChecked();
if (object->IsBoolean()) {
*value = object->BooleanValue();
return true;

View File

@ -850,8 +850,8 @@ Failure* Isolate::StackOverflow() {
// constructor. Instead, we copy the pre-constructed boilerplate and
// attach the stack trace as a hidden property.
Handle<String> key = factory()->stack_overflow_string();
Handle<JSObject> boilerplate =
Handle<JSObject>::cast(Object::GetProperty(js_builtins_object(), key));
Handle<JSObject> boilerplate = Handle<JSObject>::cast(
Object::GetProperty(js_builtins_object(), key).ToHandleChecked());
Handle<JSObject> exception = JSObject::Copy(boilerplate);
DoThrow(*exception, NULL);
@ -1050,8 +1050,8 @@ bool Isolate::IsErrorObject(Handle<Object> obj) {
Handle<String> error_key =
factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("$Error"));
Handle<Object> error_constructor = GlobalObject::GetPropertyNoExceptionThrown(
js_builtins_object(), error_key);
Handle<Object> error_constructor = Object::GetProperty(
js_builtins_object(), error_key).ToHandleChecked();
DisallowHeapAllocation no_gc;
for (Object* prototype = *obj; !prototype->IsNull();

View File

@ -724,8 +724,8 @@ class FunctionInfoListener {
HandleScope scope(isolate());
FunctionInfoWrapper info =
FunctionInfoWrapper::cast(
*Object::GetElementNoExceptionThrown(
isolate(), result_, current_parent_index_));
*Object::GetElement(
isolate(), result_, current_parent_index_).ToHandleChecked());
current_parent_index_ = info.GetParentIndex();
}
@ -734,8 +734,8 @@ class FunctionInfoListener {
void FunctionCode(Handle<Code> function_code) {
FunctionInfoWrapper info =
FunctionInfoWrapper::cast(
*Object::GetElementNoExceptionThrown(
isolate(), result_, current_parent_index_));
*Object::GetElement(
isolate(), result_, current_parent_index_).ToHandleChecked());
info.SetFunctionCode(function_code,
Handle<HeapObject>(isolate()->heap()->null_value()));
}
@ -749,8 +749,8 @@ class FunctionInfoListener {
}
FunctionInfoWrapper info =
FunctionInfoWrapper::cast(
*Object::GetElementNoExceptionThrown(
isolate(), result_, current_parent_index_));
*Object::GetElement(
isolate(), result_, current_parent_index_).ToHandleChecked());
info.SetFunctionCode(Handle<Code>(shared->code()),
Handle<HeapObject>(shared->scope_info()));
info.SetSharedFunctionInfo(shared);
@ -881,7 +881,7 @@ void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) {
for (int i = 0; i < len; i++) {
Handle<SharedFunctionInfo> info(
SharedFunctionInfo::cast(
*Object::GetElementNoExceptionThrown(isolate, array, i)));
*Object::GetElement(isolate, array, i).ToHandleChecked()));
SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(isolate);
Handle<String> name_handle(String::cast(info->name()));
info_wrapper.SetProperties(name_handle, info->start_position(),
@ -1239,21 +1239,21 @@ static int TranslatePosition(int original_position,
// TODO(635): binary search may be used here
for (int i = 0; i < array_len; i += 3) {
HandleScope scope(isolate);
Handle<Object> element = Object::GetElementNoExceptionThrown(
isolate, position_change_array, i);
Handle<Object> element = Object::GetElement(
isolate, position_change_array, i).ToHandleChecked();
CHECK(element->IsSmi());
int chunk_start = Handle<Smi>::cast(element)->value();
if (original_position < chunk_start) {
break;
}
element = Object::GetElementNoExceptionThrown(
isolate, position_change_array, i + 1);
element = Object::GetElement(
isolate, position_change_array, i + 1).ToHandleChecked();
CHECK(element->IsSmi());
int chunk_end = Handle<Smi>::cast(element)->value();
// Position mustn't be inside a chunk.
ASSERT(original_position >= chunk_end);
element = Object::GetElementNoExceptionThrown(
isolate, position_change_array, i + 2);
element = Object::GetElement(
isolate, position_change_array, i + 2).ToHandleChecked();
CHECK(element->IsSmi());
int chunk_changed_end = Handle<Smi>::cast(element)->value();
position_diff = chunk_changed_end - chunk_end;
@ -1504,7 +1504,7 @@ static bool CheckActivation(Handle<JSArray> shared_info_array,
for (int i = 0; i < len; i++) {
HandleScope scope(isolate);
Handle<Object> element =
Object::GetElementNoExceptionThrown(isolate, shared_info_array, i);
Object::GetElement(isolate, shared_info_array, i).ToHandleChecked();
Handle<JSValue> jsvalue = Handle<JSValue>::cast(element);
Handle<SharedFunctionInfo> shared =
UnwrapSharedFunctionInfoFromJSValue(jsvalue);
@ -1821,7 +1821,7 @@ static const char* DropActivationsInActiveThread(
// Replace "blocked on active" with "replaced on active" status.
for (int i = 0; i < array_len; i++) {
Handle<Object> obj =
Object::GetElementNoExceptionThrown(isolate, result, i);
Object::GetElement(isolate, result, i).ToHandleChecked();
if (*obj == Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) {
Handle<Object> replaced(
Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK), isolate);

View File

@ -216,8 +216,8 @@ class JSArrayBasedStruct {
}
Handle<Object> GetField(int field_position) {
return Object::GetElementNoExceptionThrown(
isolate(), array_, field_position);
return Object::GetElement(
isolate(), array_, field_position).ToHandleChecked();
}
int GetSmiValueField(int field_position) {
@ -297,8 +297,8 @@ class SharedInfoWrapper : public JSArrayBasedStruct<SharedInfoWrapper> {
public:
static bool IsInstance(Handle<JSArray> array) {
return array->length() == Smi::FromInt(kSize_) &&
Object::GetElementNoExceptionThrown(
array->GetIsolate(), array, kSharedInfoOffset_)->IsJSValue();
Object::GetElement(array->GetIsolate(), array, kSharedInfoOffset_)
.ToHandleChecked()->IsJSValue();
}
explicit SharedInfoWrapper(Handle<JSArray> array)

View File

@ -1208,8 +1208,8 @@ void Logger::LogRuntime(Vector<const char> format,
i++;
ASSERT('0' <= format[i] && format[i] <= '9');
// No exception expected when getting an element from an array literal.
Handle<Object> obj =
Object::GetElementNoExceptionThrown(isolate_, args, format[i] - '0');
Handle<Object> obj = Object::GetElement(
isolate_, args, format[i] - '0').ToHandleChecked();
i++;
switch (format[i]) {
case 's':

View File

@ -154,9 +154,8 @@ 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>::cast(
GlobalObject::GetPropertyNoExceptionThrown(
isolate->js_builtins_object(), fmt_str));
Handle<JSFunction> fun = Handle<JSFunction>::cast(Object::GetProperty(
isolate->js_builtins_object(), fmt_str).ToHandleChecked());
Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data);
Handle<Object> argv[] = { Handle<Object>(message->type(), isolate),
Handle<Object>(message->arguments(), isolate) };

View File

@ -1081,6 +1081,13 @@ bool Object::HasSpecificClassOf(String* name) {
}
MaybeHandle<Object> Object::GetProperty(Handle<Object> object,
Handle<Name> name) {
PropertyAttributes attributes;
return GetPropertyWithReceiver(object, object, name, &attributes);
}
MaybeHandle<Object> Object::GetElement(Isolate* isolate,
Handle<Object> object,
uint32_t index) {
@ -1092,19 +1099,39 @@ MaybeHandle<Object> Object::GetElement(Isolate* isolate,
}
Handle<Object> Object::GetElementNoExceptionThrown(Isolate* isolate,
Handle<Object> object,
uint32_t index) {
Handle<Object> result =
Object::GetElementWithReceiver(
isolate, object, object, index).ToHandleChecked();
return result;
MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object,
Handle<Name> name) {
uint32_t index;
Isolate* isolate = name->GetIsolate();
if (name->AsArrayIndex(&index)) return GetElement(isolate, object, index);
return GetProperty(object, name);
}
MaybeObject* Object::GetProperty(Name* key) {
PropertyAttributes attributes;
return GetPropertyWithReceiver(this, key, &attributes);
MaybeHandle<Object> JSProxy::GetElementWithHandler(Handle<JSProxy> proxy,
Handle<Object> receiver,
uint32_t index) {
return GetPropertyWithHandler(
proxy, receiver, proxy->GetIsolate()->factory()->Uint32ToString(index));
}
MaybeHandle<Object> JSProxy::SetElementWithHandler(Handle<JSProxy> proxy,
Handle<JSReceiver> receiver,
uint32_t index,
Handle<Object> value,
StrictMode strict_mode) {
Isolate* isolate = proxy->GetIsolate();
Handle<String> name = isolate->factory()->Uint32ToString(index);
return SetPropertyWithHandler(
proxy, receiver, name, value, NONE, strict_mode);
}
bool JSProxy::HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index) {
Isolate* isolate = proxy->GetIsolate();
Handle<String> name = isolate->factory()->Uint32ToString(index);
return HasPropertyWithHandler(proxy, name);
}
@ -3024,15 +3051,6 @@ 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()) ||

View File

@ -170,17 +170,6 @@ MaybeHandle<Object> Object::GetPropertyWithReceiver(
}
MaybeObject* Object::GetPropertyWithReceiver(Object* receiver,
Name* name,
PropertyAttributes* attributes) {
LookupResult result(name->GetIsolate());
Lookup(name, &result);
MaybeObject* value = GetProperty(receiver, &result, name, attributes);
ASSERT(*attributes <= ABSENT);
return value;
}
bool Object::ToInt32(int32_t* value) {
if (IsSmi()) {
*value = Smi::cast(this)->value();
@ -474,69 +463,17 @@ MaybeHandle<Object> JSObject::GetPropertyWithCallback(Handle<JSObject> object,
}
MaybeObject* JSProxy::GetPropertyWithHandler(Object* receiver_raw,
Name* name_raw) {
Isolate* isolate = GetIsolate();
HandleScope scope(isolate);
Handle<Object> receiver(receiver_raw, isolate);
Handle<Object> name(name_raw, isolate);
MaybeHandle<Object> JSProxy::GetPropertyWithHandler(Handle<JSProxy> proxy,
Handle<Object> receiver,
Handle<Name> name) {
Isolate* isolate = proxy->GetIsolate();
// TODO(rossberg): adjust once there is a story for symbols vs proxies.
if (name->IsSymbol()) return isolate->heap()->undefined_value();
if (name->IsSymbol()) return isolate->factory()->undefined_value();
Handle<Object> args[] = { receiver, name };
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
CallTrap(handle(this),
"get",
isolate->derived_get_trap(),
ARRAY_SIZE(args),
args));
return *result;
}
MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object,
Handle<Name> name) {
uint32_t index;
Isolate* isolate = name->GetIsolate();
if (name->AsArrayIndex(&index)) return GetElement(isolate, object, index);
return GetProperty(object, name);
}
Handle<Object> Object::GetProperty(Handle<Object> object,
Handle<Name> name) {
CALL_HEAP_FUNCTION(name->GetIsolate(), object->GetProperty(*name), Object);
}
MaybeObject* JSProxy::GetElementWithHandler(Object* receiver,
uint32_t index) {
String* name;
MaybeObject* maybe = GetHeap()->Uint32ToString(index);
if (!maybe->To<String>(&name)) return maybe;
return GetPropertyWithHandler(receiver, name);
}
MaybeHandle<Object> JSProxy::SetElementWithHandler(Handle<JSProxy> proxy,
Handle<JSReceiver> receiver,
uint32_t index,
Handle<Object> value,
StrictMode strict_mode) {
Isolate* isolate = proxy->GetIsolate();
Handle<String> name = isolate->factory()->Uint32ToString(index);
return SetPropertyWithHandler(
proxy, receiver, name, value, NONE, strict_mode);
}
bool JSProxy::HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index) {
Isolate* isolate = proxy->GetIsolate();
Handle<String> name = isolate->factory()->Uint32ToString(index);
return HasPropertyWithHandler(proxy, name);
return CallTrap(
proxy, "get", isolate->derived_get_trap(), ARRAY_SIZE(args), args);
}
@ -836,29 +773,10 @@ bool JSObject::IsDirty() {
MaybeHandle<Object> Object::GetProperty(Handle<Object> object,
Handle<Object> receiver,
LookupResult* result,
Handle<Name> key,
Handle<Name> name,
PropertyAttributes* attributes) {
Isolate* isolate = result->isolate();
CALL_HEAP_FUNCTION(
isolate,
object->GetProperty(*receiver, result, *key, attributes),
Object);
}
// TODO(yangguo): handlify this and get rid of.
MaybeObject* Object::GetProperty(Object* receiver,
LookupResult* result,
Name* name,
PropertyAttributes* attributes) {
Isolate* isolate = name->GetIsolate();
Heap* heap = isolate->heap();
#ifdef DEBUG
// TODO(mstarzinger): Only because of the AssertNoContextChange, drop as soon
// as this method has been fully handlified.
HandleScope scope(isolate);
#endif
Factory* factory = isolate->factory();
// Make sure that the top context does not change when doing
// callbacks or interceptor calls.
@ -872,93 +790,68 @@ MaybeObject* Object::GetProperty(Object* receiver,
// holder in the prototype chain.
// Proxy handlers do not use the proxy's prototype, so we can skip this.
if (!result->IsHandler()) {
Object* last = result->IsProperty()
? result->holder()
: Object::cast(heap->null_value());
ASSERT(this != this->GetPrototype(isolate));
for (Object* current = this;
ASSERT(*object != object->GetPrototype(isolate));
Handle<Object> last = result->IsProperty()
? Handle<Object>(result->holder(), isolate)
: Handle<Object>::cast(factory->null_value());
for (Handle<Object> current = object;
true;
current = current->GetPrototype(isolate)) {
current = Handle<Object>(current->GetPrototype(isolate), isolate)) {
if (current->IsAccessCheckNeeded()) {
// Check if we're allowed to read from the current object. Note
// that even though we may not actually end up loading the named
// property from the current object, we still check that we have
// access to it.
JSObject* checked = JSObject::cast(current);
if (!isolate->MayNamedAccess(checked, name, v8::ACCESS_GET)) {
HandleScope scope(isolate);
Handle<Object> value;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, value,
JSObject::GetPropertyWithFailedAccessCheck(
handle(checked, isolate),
handle(receiver, isolate),
result,
handle(name, isolate),
attributes));
return *value;
Handle<JSObject> checked = Handle<JSObject>::cast(current);
if (!isolate->MayNamedAccessWrapper(checked, name, v8::ACCESS_GET)) {
return JSObject::GetPropertyWithFailedAccessCheck(
checked, receiver, result, name, attributes);
}
}
// Stop traversing the chain once we reach the last object in the
// chain; either the holder of the result or null in case of an
// absent property.
if (current == last) break;
if (current.is_identical_to(last)) break;
}
}
if (!result->IsProperty()) {
*attributes = ABSENT;
return heap->undefined_value();
return factory->undefined_value();
}
*attributes = result->GetAttributes();
Object* value;
Handle<Object> value;
Handle<JSObject> holder(result->holder(), isolate);
switch (result->type()) {
case NORMAL:
value = result->holder()->GetNormalizedProperty(result);
ASSERT(!value->IsTheHole() || result->IsReadOnly());
return value->IsTheHole() ? heap->undefined_value() : value;
case FIELD: {
MaybeObject* maybe_result = result->holder()->FastPropertyAt(
result->representation(),
result->GetFieldIndex().field_index());
if (!maybe_result->To(&value)) return maybe_result;
ASSERT(!value->IsTheHole() || result->IsReadOnly());
return value->IsTheHole() ? heap->undefined_value() : value;
case NORMAL: {
DisallowHeapAllocation no_gc;
value = handle(holder->GetNormalizedProperty(result), isolate);
break;
}
case FIELD:
value = JSObject::FastPropertyAt(holder,
result->representation(),
result->GetFieldIndex().field_index());
break;
case CONSTANT:
return result->GetConstant();
case CALLBACKS: {
HandleScope scope(isolate);
Handle<Object> value;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, value,
JSObject::GetPropertyWithCallback(
handle(result->holder(), isolate),
handle(receiver, isolate),
handle(result->GetCallbackObject(), isolate),
handle(name, isolate)));
return *value;
}
return handle(result->GetConstant(), isolate);
case CALLBACKS:
return JSObject::GetPropertyWithCallback(
holder, receiver, handle(result->GetCallbackObject(), isolate), name);
case HANDLER:
return result->proxy()->GetPropertyWithHandler(receiver, name);
case INTERCEPTOR: {
HandleScope scope(isolate);
Handle<Object> value;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, value,
JSObject::GetPropertyWithInterceptor(
handle(result->holder(), isolate),
handle(receiver, isolate),
handle(name, isolate),
attributes));
return *value;
}
return JSProxy::GetPropertyWithHandler(
handle(result->proxy(), isolate), receiver, name);
case INTERCEPTOR:
return JSObject::GetPropertyWithInterceptor(
holder, receiver, name, attributes);
case NONEXISTENT:
UNREACHABLE();
break;
}
UNREACHABLE();
return NULL;
ASSERT(!value->IsTheHole() || result->IsReadOnly());
return value->IsTheHole() ? Handle<Object>::cast(factory->undefined_value())
: value;
}
@ -988,10 +881,8 @@ MaybeHandle<Object> Object::GetElementWithReceiver(Isolate* isolate,
holder = Handle<Object>(
native_context->boolean_function()->instance_prototype(), isolate);
} else if (holder->IsJSProxy()) {
CALL_HEAP_FUNCTION(isolate,
Handle<JSProxy>::cast(holder)->GetElementWithHandler(
*receiver, index),
Object);
return JSProxy::GetElementWithHandler(
Handle<JSProxy>::cast(holder), receiver, index);
} else {
// Undefined and null have no indexed properties.
ASSERT(holder->IsUndefined() || holder->IsNull());
@ -3622,9 +3513,9 @@ MaybeHandle<Object> JSProxy::SetPropertyViaPrototypesWithHandler(
Handle<String> configurable_name =
isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("configurable_"));
Handle<Object> configurable = Object::GetProperty(desc, configurable_name);
ASSERT(!configurable.is_null());
ASSERT(configurable->IsTrue() || configurable->IsFalse());
Handle<Object> configurable =
Object::GetProperty(desc, configurable_name).ToHandleChecked();
ASSERT(configurable->IsBoolean());
if (configurable->IsFalse()) {
Handle<String> trap =
isolate->factory()->InternalizeOneByteString(
@ -3640,16 +3531,16 @@ MaybeHandle<Object> JSProxy::SetPropertyViaPrototypesWithHandler(
Handle<String> hasWritable_name =
isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("hasWritable_"));
Handle<Object> hasWritable = Object::GetProperty(desc, hasWritable_name);
ASSERT(!hasWritable.is_null());
ASSERT(hasWritable->IsTrue() || hasWritable->IsFalse());
Handle<Object> hasWritable =
Object::GetProperty(desc, hasWritable_name).ToHandleChecked();
ASSERT(hasWritable->IsBoolean());
if (hasWritable->IsTrue()) {
Handle<String> writable_name =
isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("writable_"));
Handle<Object> writable = Object::GetProperty(desc, writable_name);
ASSERT(!writable.is_null());
ASSERT(writable->IsTrue() || writable->IsFalse());
Handle<Object> writable =
Object::GetProperty(desc, writable_name).ToHandleChecked();
ASSERT(writable->IsBoolean());
*done = writable->IsFalse();
if (!*done) return isolate->factory()->the_hole_value();
if (strict_mode == SLOPPY) return value;
@ -3662,8 +3553,7 @@ MaybeHandle<Object> JSProxy::SetPropertyViaPrototypesWithHandler(
// We have an AccessorDescriptor.
Handle<String> set_name = isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("set_"));
Handle<Object> setter = Object::GetProperty(desc, set_name);
ASSERT(!setter.is_null());
Handle<Object> setter = Object::GetProperty(desc, set_name).ToHandleChecked();
if (!setter->IsUndefined()) {
// TODO(rossberg): nicer would be to cast to some JSCallable here...
return SetPropertyWithDefinedSetter(
@ -3755,21 +3645,25 @@ PropertyAttributes JSProxy::GetPropertyAttributeWithHandler(
// Convert result to PropertyAttributes.
Handle<String> enum_n = isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("enumerable_"));
Handle<Object> enumerable = Object::GetProperty(desc, enum_n);
RETURN_IF_EMPTY_HANDLE_VALUE(isolate, enumerable, NONE);
Handle<Object> enumerable;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, enumerable, Object::GetProperty(desc, enum_n), NONE);
Handle<String> conf_n = isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("configurable_"));
Handle<Object> configurable = Object::GetProperty(desc, conf_n);
RETURN_IF_EMPTY_HANDLE_VALUE(isolate, configurable, NONE);
Handle<Object> configurable;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, configurable, Object::GetProperty(desc, conf_n), NONE);
Handle<String> writ_n = isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("writable_"));
Handle<Object> writable = Object::GetProperty(desc, writ_n);
RETURN_IF_EMPTY_HANDLE_VALUE(isolate, writable, NONE);
Handle<Object> writable;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, writable, Object::GetProperty(desc, writ_n), NONE);
if (!writable->BooleanValue()) {
Handle<String> set_n = isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("set_"));
Handle<Object> setter = Object::GetProperty(desc, set_n);
RETURN_IF_EMPTY_HANDLE_VALUE(isolate, setter, NONE);
Handle<Object> setter;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, setter, Object::GetProperty(desc, set_n), NONE);
writable = isolate->factory()->ToBoolean(!setter->IsUndefined());
}
@ -5220,7 +5114,8 @@ MaybeHandle<Object> JSObject::DeleteElement(Handle<JSObject> object,
if (!GetLocalElementAccessorPair(object, index).is_null()) {
old_value = Handle<Object>::cast(factory->the_hole_value());
} else {
old_value = Object::GetElementNoExceptionThrown(isolate, object, index);
old_value = Object::GetElement(
isolate, object, index).ToHandleChecked();
}
}
}
@ -5821,8 +5716,8 @@ Handle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
// In particular, don't try to copy the length attribute of
// an array.
if (attributes != NONE) continue;
Handle<Object> value = Object::GetProperty(copy, key_string);
CHECK_NOT_EMPTY_HANDLE(isolate, value);
Handle<Object> value =
Object::GetProperty(copy, key_string).ToHandleChecked();
if (value->IsJSObject()) {
Handle<JSObject> result = VisitElementOrProperty(
copy, Handle<JSObject>::cast(value));
@ -6385,7 +6280,8 @@ void JSObject::DefineAccessor(Handle<JSObject> object,
if (is_element) {
preexists = HasLocalElement(object, index);
if (preexists && GetLocalElementAccessorPair(object, index).is_null()) {
old_value = Object::GetElementNoExceptionThrown(isolate, object, index);
old_value =
Object::GetElement(isolate, object, index).ToHandleChecked();
}
} else {
LookupResult lookup(isolate);
@ -11293,7 +11189,7 @@ static bool GetOldValue(Isolate* isolate,
if (!JSObject::GetLocalElementAccessorPair(object, index).is_null()) {
value = Handle<Object>::cast(isolate->factory()->the_hole_value());
} else {
value = Object::GetElementNoExceptionThrown(isolate, object, index);
value = Object::GetElement(isolate, object, index).ToHandleChecked();
}
old_values->Add(value);
indices->Add(index);
@ -12544,7 +12440,7 @@ MaybeHandle<Object> JSObject::SetElement(Handle<JSObject> object,
if (old_attributes != ABSENT) {
if (GetLocalElementAccessorPair(object, index).is_null()) {
old_value = Object::GetElementNoExceptionThrown(isolate, object, index);
old_value = Object::GetElement(isolate, object, index).ToHandleChecked();
}
} else if (object->IsJSArray()) {
// Store old array length in case adding an element grows the array.
@ -12593,7 +12489,7 @@ MaybeHandle<Object> JSObject::SetElement(Handle<JSObject> object,
EnqueueChangeRecord(object, "reconfigure", name, old_value);
} else {
Handle<Object> new_value =
Object::GetElementNoExceptionThrown(isolate, object, index);
Object::GetElement(isolate, object, index).ToHandleChecked();
bool value_changed = !old_value->SameValue(*new_value);
if (old_attributes != new_attributes) {
if (!value_changed) old_value = isolate->factory()->the_hole_value();

View File

@ -1533,26 +1533,18 @@ class Object : public MaybeObject {
void Lookup(Name* name, LookupResult* result);
// Property access.
MUST_USE_RESULT inline MaybeObject* GetProperty(Name* key);
// TODO(yangguo): this should eventually replace the non-handlified version.
MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithReceiver(
Handle<Object> object,
Handle<Object> receiver,
Handle<Name> name,
PropertyAttributes* attributes);
MUST_USE_RESULT MaybeObject* GetPropertyWithReceiver(
Object* receiver,
Name* key,
PropertyAttributes* attributes);
MUST_USE_RESULT static MaybeHandle<Object> GetPropertyOrElement(
MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
Handle<Object> object,
Handle<Name> key);
static Handle<Object> GetProperty(Handle<Object> object,
Handle<Name> key);
MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty(
Handle<Object> object,
Handle<Name> key);
MUST_USE_RESULT static MaybeHandle<Object> GetProperty(
Handle<Object> object,
Handle<Object> receiver,
@ -1560,11 +1552,6 @@ class Object : public MaybeObject {
Handle<Name> key,
PropertyAttributes* attributes);
MUST_USE_RESULT MaybeObject* GetProperty(Object* receiver,
LookupResult* result,
Name* key,
PropertyAttributes* attributes);
MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithDefinedGetter(
Handle<Object> object,
Handle<Object> receiver,
@ -1575,12 +1562,6 @@ class Object : public MaybeObject {
Handle<Object> object,
uint32_t index);
// For use when we know that no exception can be thrown.
static inline Handle<Object> GetElementNoExceptionThrown(
Isolate* isolate,
Handle<Object> object,
uint32_t index);
MUST_USE_RESULT static MaybeHandle<Object> GetElementWithReceiver(
Isolate* isolate,
Handle<Object> object,
@ -7809,14 +7790,6 @@ class GlobalObject: public JSObject {
// Retrieve the property cell used to store a property.
PropertyCell* GetPropertyCell(LookupResult* result);
// This is like GetProperty, but is used when you know the lookup won't fail
// 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.
static inline Handle<Object> GetPropertyNoExceptionThrown(
Handle<GlobalObject> global,
Handle<Name> name);
// Casting.
static inline GlobalObject* cast(Object* obj);
@ -9845,11 +9818,13 @@ class JSProxy: public JSReceiver {
// Casting.
static inline JSProxy* cast(Object* obj);
MUST_USE_RESULT MaybeObject* GetPropertyWithHandler(
Object* receiver,
Name* name);
MUST_USE_RESULT MaybeObject* GetElementWithHandler(
Object* receiver,
MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler(
Handle<JSProxy> proxy,
Handle<Object> receiver,
Handle<Name> name);
MUST_USE_RESULT static inline MaybeHandle<Object> GetElementWithHandler(
Handle<JSProxy> proxy,
Handle<Object> receiver,
uint32_t index);
// If the handler defines an accessor property with a setter, invoke it.
@ -9920,7 +9895,7 @@ class JSProxy: public JSReceiver {
Handle<Object> value,
PropertyAttributes attributes,
StrictMode strict_mode);
MUST_USE_RESULT static MaybeHandle<Object> SetElementWithHandler(
MUST_USE_RESULT static inline MaybeHandle<Object> SetElementWithHandler(
Handle<JSProxy> proxy,
Handle<JSReceiver> receiver,
uint32_t index,
@ -9928,7 +9903,8 @@ class JSProxy: public JSReceiver {
StrictMode strict_mode);
static bool HasPropertyWithHandler(Handle<JSProxy> proxy, Handle<Name> name);
static bool HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index);
static inline bool HasElementWithHandler(Handle<JSProxy> proxy,
uint32_t index);
MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler(
Handle<JSProxy> proxy,

View File

@ -6047,9 +6047,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) {
HandleScope scope(isolate);
if (args[0]->IsSymbol()) {
// Lookup in the initial Object.prototype object.
Handle<Object> result = Object::GetProperty(
isolate->initial_object_prototype(), args.at<Symbol>(0));
RETURN_IF_EMPTY_HANDLE(isolate, result);
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
Object::GetProperty(
isolate->initial_object_prototype(), args.at<Symbol>(0)));
return *result;
}
@ -6087,9 +6089,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) {
}
// Lookup in the initial Object.prototype object.
Handle<Object> result = Object::GetProperty(
isolate->initial_object_prototype(), key);
RETURN_IF_EMPTY_HANDLE(isolate, result);
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
Object::GetProperty(isolate->initial_object_prototype(), key));
return *result;
}
@ -9308,9 +9311,11 @@ static ObjectPair LoadContextSlotHelper(Arguments args,
// No need to unhole the value here. This is taken care of by the
// GetProperty function.
Handle<Object> value = Object::GetProperty(object, name);
RETURN_IF_EMPTY_HANDLE_VALUE(
isolate, value, MakePair(Failure::Exception(), NULL));
Handle<Object> value;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, value,
Object::GetProperty(object, name),
MakePair(Failure::Exception(), NULL));
return MakePair(*value, *receiver_handle);
}

View File

@ -21960,7 +21960,7 @@ THREADED_TEST(FunctionNew) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::Handle<i::JSObject> cache(i_isolate->native_context()->function_cache());
i::Handle<i::Object> elm =
i::Object::GetElementNoExceptionThrown(i_isolate, cache, serial_number);
i::Object::GetElement(i_isolate, cache, serial_number).ToHandleChecked();
CHECK(elm->IsUndefined());
// Verify that each Function::New creates a new function instance
Local<Object> data2 = v8::Object::New(isolate);

View File

@ -40,8 +40,8 @@ static Handle<Object> GetGlobalProperty(const char* name) {
Isolate* isolate = CcTest::i_isolate();
Handle<String> internalized_name =
isolate->factory()->InternalizeUtf8String(name);
return GlobalObject::GetPropertyNoExceptionThrown(
isolate->global_object(), internalized_name);
return Object::GetProperty(
isolate->global_object(), internalized_name).ToHandleChecked();
}
@ -236,7 +236,7 @@ TEST(C2JSFrames) {
Handle<String> foo_string = isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("foo"));
Handle<Object> fun1 = Object::GetProperty(
isolate->global_object(), foo_string);
isolate->global_object(), foo_string).ToHandleChecked();
CHECK(fun1->IsJSFunction());
Handle<Object> argv[] = { isolate->factory()->InternalizeOneByteString(

View File

@ -290,8 +290,10 @@ TEST(GarbageCollection) {
JSReceiver::SetProperty(
obj, prop_namex, twenty_four, NONE, SLOPPY).Check();
CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(obj, prop_name));
CHECK_EQ(Smi::FromInt(24), *Object::GetProperty(obj, prop_namex));
CHECK_EQ(Smi::FromInt(23),
*Object::GetProperty(obj, prop_name).ToHandleChecked());
CHECK_EQ(Smi::FromInt(24),
*Object::GetProperty(obj, prop_namex).ToHandleChecked());
}
heap->CollectGarbage(NEW_SPACE);
@ -299,7 +301,8 @@ TEST(GarbageCollection) {
// Function should be alive.
CHECK(JSReceiver::HasLocalProperty(global, name));
// Check function is retained.
Handle<Object> func_value = Object::GetProperty(global, name);
Handle<Object> func_value =
Object::GetProperty(global, name).ToHandleChecked();
CHECK(func_value->IsJSFunction());
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
@ -316,9 +319,11 @@ TEST(GarbageCollection) {
heap->CollectGarbage(NEW_SPACE);
CHECK(JSReceiver::HasLocalProperty(global, obj_name));
Handle<Object> obj = Object::GetProperty(global, obj_name);
Handle<Object> obj =
Object::GetProperty(global, obj_name).ToHandleChecked();
CHECK(obj->IsJSObject());
CHECK_EQ(Smi::FromInt(23), *Object::GetProperty(obj, prop_name));
CHECK_EQ(Smi::FromInt(23),
*Object::GetProperty(obj, prop_name).ToHandleChecked());
}
@ -642,11 +647,13 @@ 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), *Object::GetProperty(obj, prop_name));
CHECK_EQ(Smi::FromInt(23),
*Object::GetProperty(obj, prop_name).ToHandleChecked());
// Check that we can add properties to function objects.
JSReceiver::SetProperty(
function, prop_name, twenty_four, NONE, SLOPPY).Check();
CHECK_EQ(Smi::FromInt(24), *Object::GetProperty(function, prop_name));
CHECK_EQ(Smi::FromInt(24),
*Object::GetProperty(function, prop_name).ToHandleChecked());
}
@ -657,8 +664,8 @@ TEST(ObjectProperties) {
v8::HandleScope sc(CcTest::isolate());
Handle<String> object_string(String::cast(CcTest::heap()->Object_string()));
Handle<Object> object =
Object::GetProperty(CcTest::i_isolate()->global_object(), object_string);
Handle<Object> object = Object::GetProperty(
CcTest::i_isolate()->global_object(), object_string).ToHandleChecked();
Handle<JSFunction> constructor = Handle<JSFunction>::cast(object);
Handle<JSObject> obj = factory->NewJSObject(constructor);
Handle<String> first = factory->InternalizeUtf8String("first");
@ -739,7 +746,8 @@ 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), *Object::GetProperty(obj, prop_name));
CHECK_EQ(Smi::FromInt(23),
*Object::GetProperty(obj, prop_name).ToHandleChecked());
// Check the map has changed
CHECK(*initial_map != obj->map());
@ -753,8 +761,8 @@ TEST(JSArray) {
v8::HandleScope sc(CcTest::isolate());
Handle<String> name = factory->InternalizeUtf8String("Array");
Handle<Object> fun_obj =
Object::GetProperty(CcTest::i_isolate()->global_object(), name);
Handle<Object> fun_obj = Object::GetProperty(
CcTest::i_isolate()->global_object(), name).ToHandleChecked();
Handle<JSFunction> function = Handle<JSFunction>::cast(fun_obj);
// Allocate the object.
@ -802,8 +810,8 @@ TEST(JSObjectCopy) {
v8::HandleScope sc(CcTest::isolate());
Handle<String> object_string(String::cast(CcTest::heap()->Object_string()));
Handle<Object> object =
Object::GetProperty(CcTest::i_isolate()->global_object(), object_string);
Handle<Object> object = Object::GetProperty(
CcTest::i_isolate()->global_object(), object_string).ToHandleChecked();
Handle<JSFunction> constructor = Handle<JSFunction>::cast(object);
Handle<JSObject> obj = factory->NewJSObject(constructor);
Handle<String> first = factory->InternalizeUtf8String("first");
@ -827,10 +835,10 @@ TEST(JSObjectCopy) {
CHECK_EQ(*i::Object::GetElement(isolate, obj, 1).ToHandleChecked(),
*i::Object::GetElement(isolate, clone, 1).ToHandleChecked());
CHECK_EQ(*Object::GetProperty(obj, first),
*Object::GetProperty(clone, first));
CHECK_EQ(*Object::GetProperty(obj, second),
*Object::GetProperty(clone, second));
CHECK_EQ(*Object::GetProperty(obj, first).ToHandleChecked(),
*Object::GetProperty(clone, first).ToHandleChecked());
CHECK_EQ(*Object::GetProperty(obj, second).ToHandleChecked(),
*Object::GetProperty(clone, second).ToHandleChecked());
// Flip the values.
JSReceiver::SetProperty(clone, first, two, NONE, SLOPPY).Check();
@ -844,10 +852,10 @@ TEST(JSObjectCopy) {
CHECK_EQ(*i::Object::GetElement(isolate, obj, 0).ToHandleChecked(),
*i::Object::GetElement(isolate, clone, 1).ToHandleChecked());
CHECK_EQ(*Object::GetProperty(obj, second),
*Object::GetProperty(clone, first));
CHECK_EQ(*Object::GetProperty(obj, first),
*Object::GetProperty(clone, second));
CHECK_EQ(*Object::GetProperty(obj, second).ToHandleChecked(),
*Object::GetProperty(clone, first).ToHandleChecked());
CHECK_EQ(*Object::GetProperty(obj, first).ToHandleChecked(),
*Object::GetProperty(clone, second).ToHandleChecked());
}
@ -1066,8 +1074,8 @@ TEST(TestCodeFlushing) {
}
// Check function is compiled.
Handle<Object> func_value =
Object::GetProperty(CcTest::i_isolate()->global_object(), foo_name);
Handle<Object> func_value = Object::GetProperty(
CcTest::i_isolate()->global_object(), foo_name).ToHandleChecked();
CHECK(func_value->IsJSFunction());
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
CHECK(function->shared()->is_compiled());
@ -1117,7 +1125,7 @@ TEST(TestCodeFlushingPreAged) {
// Check function is compiled.
Handle<Object> func_value =
Object::GetProperty(isolate->global_object(), foo_name);
Object::GetProperty(isolate->global_object(), foo_name).ToHandleChecked();
CHECK(func_value->IsJSFunction());
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
CHECK(function->shared()->is_compiled());
@ -1182,7 +1190,7 @@ TEST(TestCodeFlushingIncremental) {
// Check function is compiled.
Handle<Object> func_value =
Object::GetProperty(isolate->global_object(), foo_name);
Object::GetProperty(isolate->global_object(), foo_name).ToHandleChecked();
CHECK(func_value->IsJSFunction());
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
CHECK(function->shared()->is_compiled());
@ -1259,12 +1267,12 @@ TEST(TestCodeFlushingIncrementalScavenge) {
// Check functions are compiled.
Handle<Object> func_value =
Object::GetProperty(isolate->global_object(), foo_name);
Object::GetProperty(isolate->global_object(), foo_name).ToHandleChecked();
CHECK(func_value->IsJSFunction());
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
CHECK(function->shared()->is_compiled());
Handle<Object> func_value2 =
Object::GetProperty(isolate->global_object(), bar_name);
Object::GetProperty(isolate->global_object(), bar_name).ToHandleChecked();
CHECK(func_value2->IsJSFunction());
Handle<JSFunction> function2 = Handle<JSFunction>::cast(func_value2);
CHECK(function2->shared()->is_compiled());
@ -1321,7 +1329,7 @@ TEST(TestCodeFlushingIncrementalAbort) {
// Check function is compiled.
Handle<Object> func_value =
Object::GetProperty(isolate->global_object(), foo_name);
Object::GetProperty(isolate->global_object(), foo_name).ToHandleChecked();
CHECK(func_value->IsJSFunction());
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
CHECK(function->shared()->is_compiled());

View File

@ -173,7 +173,8 @@ TEST(MarkCompactCollector) {
{ 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);
Handle<Object> func_value =
Object::GetProperty(global, func_name).ToHandleChecked();
CHECK(func_value->IsJSFunction());
Handle<JSFunction> function = Handle<JSFunction>::cast(func_value);
Handle<JSObject> obj = factory->NewJSObject(function);
@ -190,10 +191,12 @@ TEST(MarkCompactCollector) {
{ HandleScope scope(isolate);
Handle<String> obj_name = factory->InternalizeUtf8String("theObject");
CHECK(JSReceiver::HasLocalProperty(global, obj_name));
Handle<Object> object = Object::GetProperty(global, obj_name);
Handle<Object> object =
Object::GetProperty(global, obj_name).ToHandleChecked();
CHECK(object->IsJSObject());
Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
CHECK_EQ(*Object::GetProperty(object, prop_name), Smi::FromInt(23));
CHECK_EQ(*Object::GetProperty(object, prop_name).ToHandleChecked(),
Smi::FromInt(23));
}
}