Add GetProperty/GetElement to JSReceiver and use it where possible

Also move GetProperty with string-name to JSReceiver

BUG=

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

Cr-Commit-Position: refs/heads/master@{#34596}
This commit is contained in:
verwaest 2016-03-08 09:29:05 -08:00 committed by Commit bot
parent 667b04a94a
commit 7736102034
25 changed files with 192 additions and 150 deletions

View File

@ -2226,7 +2226,7 @@ MaybeLocal<Value> v8::TryCatch::StackTrace(Local<Context> context) const {
if (!maybe.FromJust()) return v8::Local<Value>();
Local<Value> result;
has_pending_exception =
!ToLocal<Value>(i::Object::GetProperty(obj, name), &result);
!ToLocal<Value>(i::JSReceiver::GetProperty(obj, name), &result);
RETURN_ON_FAILED_EXECUTION(Value);
RETURN_ESCAPED(result);
}
@ -2457,7 +2457,7 @@ Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
ENTER_V8(isolate);
EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
auto self = Utils::OpenHandle(this);
auto obj = i::Object::GetElement(isolate, self, index).ToHandleChecked();
auto obj = i::JSReceiver::GetElement(isolate, self, index).ToHandleChecked();
auto jsobj = i::Handle<i::JSObject>::cast(obj);
return scope.Escape(Utils::StackFrameToLocal(jsobj));
}
@ -2497,7 +2497,7 @@ static int getIntProperty(const StackFrame* f, const char* propertyName,
i::HandleScope scope(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(f);
i::Handle<i::Object> obj =
i::Object::GetProperty(isolate, self, propertyName).ToHandleChecked();
i::JSReceiver::GetProperty(isolate, self, propertyName).ToHandleChecked();
return obj->IsSmi() ? i::Smi::cast(*obj)->value() : defaultValue;
}
@ -2524,7 +2524,7 @@ static Local<String> getStringProperty(const StackFrame* f,
EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
i::Handle<i::JSObject> self = Utils::OpenHandle(f);
i::Handle<i::Object> obj =
i::Object::GetProperty(isolate, self, propertyName).ToHandleChecked();
i::JSReceiver::GetProperty(isolate, self, propertyName).ToHandleChecked();
return obj->IsString()
? scope.Escape(Local<String>::Cast(Utils::ToLocal(obj)))
: Local<String>();
@ -2552,7 +2552,7 @@ static bool getBoolProperty(const StackFrame* f, const char* propertyName) {
i::HandleScope scope(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(f);
i::Handle<i::Object> obj =
i::Object::GetProperty(isolate, self, propertyName).ToHandleChecked();
i::JSReceiver::GetProperty(isolate, self, propertyName).ToHandleChecked();
return obj->IsTrue();
}
@ -3656,7 +3656,7 @@ MaybeLocal<Value> v8::Object::Get(Local<Context> context, uint32_t index) {
auto self = Utils::OpenHandle(this);
i::Handle<i::Object> result;
has_pending_exception =
!i::Object::GetElement(isolate, self, index).ToHandle(&result);
!i::JSReceiver::GetElement(isolate, self, index).ToHandle(&result);
RETURN_ON_FAILED_EXECUTION(Value);
RETURN_ESCAPED(Utils::ToLocal(result));
}
@ -7977,7 +7977,7 @@ MaybeLocal<Value> Debug::GetMirror(Local<Context> context,
RETURN_ON_FAILED_EXECUTION(Value);
i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object());
auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror");
auto fun_obj = i::Object::GetProperty(debug, name).ToHandleChecked();
auto fun_obj = i::JSReceiver::GetProperty(debug, name).ToHandleChecked();
auto v8_fun = Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(fun_obj));
const int kArgc = 1;
v8::Local<v8::Value> argv[kArgc] = {obj};

View File

@ -901,7 +901,7 @@ Handle<JSGlobalObject> Genesis::CreateNewGlobals(
#ifdef DEBUG
LookupIterator it(prototype, factory()->constructor_string(),
LookupIterator::OWN_SKIP_INTERCEPTOR);
Handle<Object> value = JSReceiver::GetProperty(&it).ToHandleChecked();
Handle<Object> value = Object::GetProperty(&it).ToHandleChecked();
DCHECK(it.IsFound());
DCHECK_EQ(*isolate()->object_function(), *value);
#endif
@ -1983,7 +1983,7 @@ static Handle<JSObject> ResolveBuiltinIdHolder(Handle<Context> native_context,
Handle<String> property_string = factory->InternalizeUtf8String(property);
DCHECK(!property_string.is_null());
Handle<JSObject> object = Handle<JSObject>::cast(
Object::GetProperty(global, property_string).ToHandleChecked());
JSReceiver::GetProperty(global, property_string).ToHandleChecked());
if (strcmp("prototype", inner) == 0) {
Handle<JSFunction> function = Handle<JSFunction>::cast(object);
return Handle<JSObject>(JSObject::cast(function->prototype()));
@ -1991,7 +1991,7 @@ static Handle<JSObject> ResolveBuiltinIdHolder(Handle<Context> native_context,
Handle<String> inner_string = factory->InternalizeUtf8String(inner);
DCHECK(!inner_string.is_null());
Handle<Object> value =
Object::GetProperty(object, inner_string).ToHandleChecked();
JSReceiver::GetProperty(object, inner_string).ToHandleChecked();
return Handle<JSObject>::cast(value);
}
@ -2737,7 +2737,7 @@ bool Genesis::InstallNatives(GlobalContextType context_type) {
{
Handle<String> key = factory()->Promise_string();
Handle<JSFunction> function = Handle<JSFunction>::cast(
Object::GetProperty(handle(native_context()->global_object()), key)
JSReceiver::GetProperty(handle(native_context()->global_object()), key)
.ToHandleChecked());
JSFunction::EnsureHasInitialMap(function);
function->initial_map()->set_instance_type(JS_PROMISE_TYPE);
@ -3036,7 +3036,7 @@ static void InstallBuiltinFunctionId(Handle<JSObject> holder,
BuiltinFunctionId id) {
Isolate* isolate = holder->GetIsolate();
Handle<Object> function_object =
Object::GetProperty(isolate, holder, function_name).ToHandleChecked();
JSReceiver::GetProperty(isolate, holder, function_name).ToHandleChecked();
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
function->shared()->set_builtin_function_id(id);
}

View File

@ -454,7 +454,7 @@ BUILTIN(ArrayPop) {
// Use Slow Lookup otherwise
uint32_t new_length = len - 1;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, Object::GetElement(isolate, array, new_length));
isolate, result, JSReceiver::GetElement(isolate, array, new_length));
JSArray::SetLength(array, new_length);
}
return *result;
@ -1016,9 +1016,9 @@ bool IterateElementsSlow(Isolate* isolate, Handle<JSReceiver> receiver,
if (!maybe.IsJust()) return false;
if (maybe.FromJust()) {
Handle<Object> element_value;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, element_value,
Object::GetElement(isolate, receiver, i),
false);
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, element_value, JSReceiver::GetElement(isolate, receiver, i),
false);
if (!visitor->visit(i, element_value)) return false;
}
}
@ -1087,8 +1087,8 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
// Call GetElement on array, not its prototype, or getters won't
// have the correct receiver.
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, element_value, Object::GetElement(isolate, array, j),
false);
isolate, element_value,
JSReceiver::GetElement(isolate, array, j), false);
if (!visitor->visit(j, element_value)) return false;
}
}
@ -1124,8 +1124,8 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
// have the correct receiver.
Handle<Object> element_value;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, element_value, Object::GetElement(isolate, array, j),
false);
isolate, element_value,
JSReceiver::GetElement(isolate, array, j), false);
if (!visitor->visit(j, element_value)) return false;
}
}
@ -1155,7 +1155,8 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
uint32_t index = indices[j];
Handle<Object> element;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, element, Object::GetElement(isolate, array, index), false);
isolate, element, JSReceiver::GetElement(isolate, array, index),
false);
if (!visitor->visit(index, element)) return false;
// Skip to next different index (i.e., omit duplicates).
do {
@ -1170,7 +1171,8 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
HandleScope loop_scope(isolate);
Handle<Object> element;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, element, Object::GetElement(isolate, array, index), false);
isolate, element, JSReceiver::GetElement(isolate, array, index),
false);
if (!visitor->visit(index, element)) return false;
}
break;
@ -1534,9 +1536,9 @@ MUST_USE_RESULT Maybe<bool> FastAssign(Handle<JSReceiver> to,
prop_value = JSObject::FastPropertyAt(from, representation, index);
}
} else {
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, prop_value,
Object::GetProperty(from, next_key),
Nothing<bool>());
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, prop_value, JSReceiver::GetProperty(from, next_key),
Nothing<bool>());
stable = from->map() == *map;
}
} else {
@ -3738,7 +3740,8 @@ BUILTIN(FunctionHasInstance) {
Handle<Object> prototype;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, prototype,
Object::GetProperty(callable, isolate->factory()->prototype_string()));
JSReceiver::GetProperty(Handle<JSReceiver>::cast(callable),
isolate->factory()->prototype_string()));
if (!prototype->IsJSReceiver()) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,
@ -3781,7 +3784,7 @@ BUILTIN(ObjectProtoToString) {
Handle<Object> object = args.at<Object>(0);
Handle<String> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, JSObject::ObjectProtoToString(isolate, object));
isolate, result, Object::ObjectProtoToString(isolate, object));
return *result;
}

View File

@ -164,14 +164,16 @@ static Maybe<bool> UnscopableLookup(LookupIterator* it) {
Handle<Object> unscopables;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, unscopables,
Object::GetProperty(it->GetReceiver(),
isolate->factory()->unscopables_symbol()),
JSReceiver::GetProperty(Handle<JSReceiver>::cast(it->GetReceiver()),
isolate->factory()->unscopables_symbol()),
Nothing<bool>());
if (!unscopables->IsJSReceiver()) return Just(true);
Handle<Object> blacklist;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, blacklist,
Object::GetProperty(unscopables, it->name()),
Nothing<bool>());
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, blacklist,
JSReceiver::GetProperty(Handle<JSReceiver>::cast(unscopables),
it->name()),
Nothing<bool>());
return Just(!blacklist->BooleanValue());
}

View File

@ -732,9 +732,10 @@ MaybeHandle<Object> Debug::CallFunction(const char* name, int argc,
Handle<Object> args[]) {
PostponeInterruptsScope no_interrupts(isolate_);
AssertDebugContext();
Handle<Object> holder = isolate_->natives_utils_object();
Handle<JSReceiver> holder =
Handle<JSReceiver>::cast(isolate_->natives_utils_object());
Handle<JSFunction> fun = Handle<JSFunction>::cast(
Object::GetProperty(isolate_, holder, name).ToHandleChecked());
JSReceiver::GetProperty(isolate_, holder, name).ToHandleChecked());
Handle<Object> undefined = isolate_->factory()->undefined_value();
return Execution::TryCall(isolate_, fun, undefined, argc, args);
}
@ -2098,16 +2099,19 @@ void Debug::NotifyMessageHandler(v8::DebugEvent event,
// DebugCommandProcessor goes here.
bool running = auto_continue;
Handle<Object> cmd_processor_ctor = Object::GetProperty(
isolate_, exec_state, "debugCommandProcessor").ToHandleChecked();
Handle<Object> cmd_processor_ctor =
JSReceiver::GetProperty(isolate_, exec_state, "debugCommandProcessor")
.ToHandleChecked();
Handle<Object> ctor_args[] = { isolate_->factory()->ToBoolean(running) };
Handle<Object> cmd_processor = Execution::Call(
isolate_, cmd_processor_ctor, exec_state, 1, ctor_args).ToHandleChecked();
Handle<JSReceiver> cmd_processor = Handle<JSReceiver>::cast(
Execution::Call(isolate_, cmd_processor_ctor, exec_state, 1, ctor_args)
.ToHandleChecked());
Handle<JSFunction> process_debug_request = Handle<JSFunction>::cast(
Object::GetProperty(
isolate_, cmd_processor, "processDebugRequest").ToHandleChecked());
Handle<Object> is_running = Object::GetProperty(
isolate_, cmd_processor, "isRunning").ToHandleChecked();
JSReceiver::GetProperty(isolate_, cmd_processor, "processDebugRequest")
.ToHandleChecked());
Handle<Object> is_running =
JSReceiver::GetProperty(isolate_, cmd_processor, "isRunning")
.ToHandleChecked();
// Process requests from the debugger.
do {
@ -2500,8 +2504,9 @@ v8::Local<v8::String> MessageImpl::GetJSON() const {
if (IsEvent()) {
// Call toJSONProtocol on the debug event object.
Handle<Object> fun = Object::GetProperty(
isolate, event_data_, "toJSONProtocol").ToHandleChecked();
Handle<Object> fun =
JSReceiver::GetProperty(isolate, event_data_, "toJSONProtocol")
.ToHandleChecked();
if (!fun->IsJSFunction()) {
return v8::Local<v8::String>();
}

View File

@ -710,20 +710,18 @@ class FunctionInfoListener {
void FunctionDone() {
HandleScope scope(isolate());
FunctionInfoWrapper info =
FunctionInfoWrapper::cast(
*Object::GetElement(
isolate(), result_, current_parent_index_).ToHandleChecked());
FunctionInfoWrapper info = FunctionInfoWrapper::cast(
*JSReceiver::GetElement(isolate(), result_, current_parent_index_)
.ToHandleChecked());
current_parent_index_ = info.GetParentIndex();
}
// Saves only function code, because for a script function we
// may never create a SharedFunctionInfo object.
void FunctionCode(Handle<Code> function_code) {
FunctionInfoWrapper info =
FunctionInfoWrapper::cast(
*Object::GetElement(
isolate(), result_, current_parent_index_).ToHandleChecked());
FunctionInfoWrapper info = FunctionInfoWrapper::cast(
*JSReceiver::GetElement(isolate(), result_, current_parent_index_)
.ToHandleChecked());
info.SetFunctionCode(function_code,
Handle<HeapObject>(isolate()->heap()->null_value()));
}
@ -735,10 +733,9 @@ class FunctionInfoListener {
if (!shared->IsSharedFunctionInfo()) {
return;
}
FunctionInfoWrapper info =
FunctionInfoWrapper::cast(
*Object::GetElement(
isolate(), result_, current_parent_index_).ToHandleChecked());
FunctionInfoWrapper info = FunctionInfoWrapper::cast(
*JSReceiver::GetElement(isolate(), result_, current_parent_index_)
.ToHandleChecked());
info.SetFunctionCode(Handle<Code>(shared->code()),
Handle<HeapObject>(shared->scope_info()));
info.SetSharedFunctionInfo(shared);
@ -1185,21 +1182,22 @@ 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::GetElement(
isolate, position_change_array, i).ToHandleChecked();
Handle<Object> element =
JSReceiver::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::GetElement(
isolate, position_change_array, i + 1).ToHandleChecked();
element = JSReceiver::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.
DCHECK(original_position >= chunk_end);
element = Object::GetElement(
isolate, position_change_array, i + 2).ToHandleChecked();
element = JSReceiver::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;
@ -1448,7 +1446,7 @@ static bool CheckActivation(Handle<JSArray> shared_info_array,
for (int i = 0; i < len; i++) {
HandleScope scope(isolate);
Handle<Object> element =
Object::GetElement(isolate, shared_info_array, i).ToHandleChecked();
JSReceiver::GetElement(isolate, shared_info_array, i).ToHandleChecked();
Handle<JSValue> jsvalue = Handle<JSValue>::cast(element);
Handle<SharedFunctionInfo> shared =
UnwrapSharedFunctionInfoFromJSValue(jsvalue);
@ -1661,14 +1659,16 @@ class MultipleFunctionTarget {
for (int i = 0; i < len; i++) {
HandleScope scope(isolate);
Handle<Object> old_element =
Object::GetElement(isolate, old_shared_array_, i).ToHandleChecked();
JSReceiver::GetElement(isolate, old_shared_array_, i)
.ToHandleChecked();
if (!old_shared.is_identical_to(UnwrapSharedFunctionInfoFromJSValue(
Handle<JSValue>::cast(old_element)))) {
continue;
}
Handle<Object> new_element =
Object::GetElement(isolate, new_shared_array_, i).ToHandleChecked();
JSReceiver::GetElement(isolate, new_shared_array_, i)
.ToHandleChecked();
if (new_element->IsUndefined()) return false;
Handle<SharedFunctionInfo> new_shared =
UnwrapSharedFunctionInfoFromJSValue(
@ -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::GetElement(isolate, result, i).ToHandleChecked();
JSReceiver::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

@ -252,8 +252,8 @@ class JSArrayBasedStruct {
}
Handle<Object> GetField(int field_position) {
return Object::GetElement(
isolate(), array_, field_position).ToHandleChecked();
return JSReceiver::GetElement(isolate(), array_, field_position)
.ToHandleChecked();
}
int GetSmiValueField(int field_position) {
@ -333,9 +333,8 @@ class SharedInfoWrapper : public JSArrayBasedStruct<SharedInfoWrapper> {
static bool IsInstance(Handle<JSArray> array) {
if (array->length() != Smi::FromInt(kSize_)) return false;
Handle<Object> element(
Object::GetElement(array->GetIsolate(),
array,
kSharedInfoOffset_).ToHandleChecked());
JSReceiver::GetElement(array->GetIsolate(), array, kSharedInfoOffset_)
.ToHandleChecked());
if (!element->IsJSValue()) return false;
return Handle<JSValue>::cast(element)->value()->IsSharedFunctionInfo();
}

View File

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

View File

@ -2814,8 +2814,7 @@ RUNTIME_FUNCTION(Runtime_LoadPropertyWithInterceptor) {
Handle<Object> result;
LookupIterator it(receiver, name, holder);
// TODO(conradw): Investigate strong mode semantics for this.
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
JSObject::GetProperty(&it));
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it));
if (it.IsFound()) return *result;

View File

@ -501,8 +501,7 @@ BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSArraySlow(
if (i > 0) builder_.AppendCharacter(',');
Handle<Object> element;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate_, element,
Object::GetElement(isolate_, object, i),
isolate_, element, JSReceiver::GetElement(isolate_, object, i),
EXCEPTION);
if (element->IsUndefined()) {
builder_.AppendCString("null");
@ -580,8 +579,8 @@ BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSObject(
DCHECK(key->IsNumber());
key_handle = factory()->NumberToString(Handle<Object>(key, isolate_));
if (key->IsSmi()) {
maybe_property = Object::GetElement(
isolate_, object, Smi::cast(key)->value());
maybe_property =
JSReceiver::GetElement(isolate_, object, Smi::cast(key)->value());
} else {
maybe_property = Object::GetPropertyOrElement(object, key_handle);
}

View File

@ -917,7 +917,7 @@ void LogRegExpSource(Handle<JSRegExp> regexp, Isolate* isolate,
// (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"")
Handle<Object> source =
Object::GetProperty(isolate, regexp, "source").ToHandleChecked();
JSReceiver::GetProperty(isolate, regexp, "source").ToHandleChecked();
if (!source->IsString()) {
msg->Append("no source");
return;
@ -936,19 +936,19 @@ void LogRegExpSource(Handle<JSRegExp> regexp, Isolate* isolate,
// global flag
Handle<Object> global =
Object::GetProperty(isolate, regexp, "global").ToHandleChecked();
JSReceiver::GetProperty(isolate, regexp, "global").ToHandleChecked();
if (global->IsTrue()) {
msg->Append('g');
}
// ignorecase flag
Handle<Object> ignorecase =
Object::GetProperty(isolate, regexp, "ignoreCase").ToHandleChecked();
JSReceiver::GetProperty(isolate, regexp, "ignoreCase").ToHandleChecked();
if (ignorecase->IsTrue()) {
msg->Append('i');
}
// multiline flag
Handle<Object> multiline =
Object::GetProperty(isolate, regexp, "multiline").ToHandleChecked();
JSReceiver::GetProperty(isolate, regexp, "multiline").ToHandleChecked();
if (multiline->IsTrue()) {
msg->Append('m');
}

View File

@ -1053,6 +1053,13 @@ MaybeHandle<Object> Object::GetProperty(Handle<Object> object,
return GetProperty(&it);
}
MaybeHandle<Object> JSReceiver::GetProperty(Handle<JSReceiver> receiver,
Handle<Name> name) {
LookupIterator it(receiver, name, receiver);
if (!it.IsFound()) return it.factory()->undefined_value();
return Object::GetProperty(&it);
}
MaybeHandle<Object> Object::GetElement(Isolate* isolate, Handle<Object> object,
uint32_t index) {
LookupIterator it(isolate, object, index);
@ -1060,6 +1067,14 @@ MaybeHandle<Object> Object::GetElement(Isolate* isolate, Handle<Object> object,
return GetProperty(&it);
}
MaybeHandle<Object> JSReceiver::GetElement(Isolate* isolate,
Handle<JSReceiver> receiver,
uint32_t index) {
LookupIterator it(isolate, receiver, index, receiver);
if (!it.IsFound()) return it.factory()->undefined_value();
return Object::GetProperty(&it);
}
Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object,
Handle<Name> name) {
LookupIterator it(object, name, object,
@ -1090,10 +1105,11 @@ MaybeHandle<Object> JSReceiver::GetPrototype(Isolate* isolate,
return PrototypeIterator::GetCurrent(iter);
}
MaybeHandle<Object> Object::GetProperty(Isolate* isolate, Handle<Object> object,
const char* name) {
MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate,
Handle<JSReceiver> receiver,
const char* name) {
Handle<String> str = isolate->factory()->InternalizeUtf8String(name);
return GetProperty(object, str);
return GetProperty(receiver, str);
}

View File

@ -616,10 +616,11 @@ MaybeHandle<FixedArray> Object::CreateListFromArrayLike(
FixedArray);
}
// 4. Let len be ? ToLength(? Get(obj, "length")).
Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object);
Handle<Object> raw_length_obj;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, raw_length_obj,
JSReceiver::GetProperty(object, isolate->factory()->length_string()),
JSReceiver::GetProperty(receiver, isolate->factory()->length_string()),
FixedArray);
Handle<Object> raw_length_number;
ASSIGN_RETURN_ON_EXCEPTION(isolate, raw_length_number,
@ -640,8 +641,9 @@ MaybeHandle<FixedArray> Object::CreateListFromArrayLike(
// 7a. Let indexName be ToString(index).
// 7b. Let next be ? Get(obj, indexName).
Handle<Object> next;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, next, Object::GetElement(isolate, object, index), FixedArray);
ASSIGN_RETURN_ON_EXCEPTION(isolate, next,
JSReceiver::GetElement(isolate, receiver, index),
FixedArray);
switch (element_types) {
case ElementTypes::kAll:
// Nothing to do.
@ -1555,8 +1557,8 @@ MaybeHandle<Object> Object::ArraySpeciesConstructor(
if (constructor->IsJSReceiver()) {
ASSIGN_RETURN_ON_EXCEPTION(
isolate, constructor,
Object::GetProperty(constructor,
isolate->factory()->species_symbol()),
JSReceiver::GetProperty(Handle<JSReceiver>::cast(constructor),
isolate->factory()->species_symbol()),
Object);
if (constructor->IsNull()) {
constructor = isolate->factory()->undefined_value();
@ -7170,7 +7172,7 @@ Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(LookupIterator* it,
if (!is_accessor_pair) {
// 5a. Set D.[[Value]] to the value of X's [[Value]] attribute.
Handle<Object> value;
if (!JSObject::GetProperty(it).ToHandle(&value)) {
if (!Object::GetProperty(it).ToHandle(&value)) {
DCHECK(isolate->has_pending_exception());
return Nothing<bool>();
}
@ -8037,7 +8039,7 @@ MaybeHandle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
DCHECK(names->get(i)->IsName());
Handle<Name> name(Name::cast(names->get(i)));
Handle<Object> value =
Object::GetProperty(copy, name).ToHandleChecked();
JSObject::GetProperty(copy, name).ToHandleChecked();
if (value->IsJSObject()) {
Handle<JSObject> result;
ASSIGN_RETURN_ON_EXCEPTION(
@ -8818,9 +8820,9 @@ MUST_USE_RESULT Maybe<bool> FastGetOwnValuesOrEntries(
JSObject::FastPropertyAt(object, representation, field_index);
}
} else {
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, prop_value,
Object::GetProperty(object, next_key),
Nothing<bool>());
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, prop_value, JSReceiver::GetProperty(object, next_key),
Nothing<bool>());
stable = object->map() == *map;
}
} else {
@ -8992,7 +8994,7 @@ MaybeHandle<Object> JSObject::DefineAccessor(LookupIterator* it,
preexists = it->IsFound();
if (preexists && (it->state() == LookupIterator::DATA ||
it->GetAccessors()->IsAccessorInfo())) {
old_value = GetProperty(it).ToHandleChecked();
old_value = Object::GetProperty(it).ToHandleChecked();
}
}
@ -13464,8 +13466,9 @@ Handle<Object> Script::GetNameOrSourceURL(Handle<Script> script) {
isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("nameOrSourceURL"));
Handle<JSObject> script_wrapper = Script::GetWrapper(script);
Handle<Object> property = Object::GetProperty(
script_wrapper, name_or_source_url_key).ToHandleChecked();
Handle<Object> property =
JSReceiver::GetProperty(script_wrapper, name_or_source_url_key)
.ToHandleChecked();
DCHECK(property->IsJSFunction());
Handle<Object> result;
// Do not check against pending exception, since this function may be called
@ -16697,7 +16700,8 @@ MaybeHandle<String> Object::ObjectProtoToString(Isolate* isolate,
Handle<Object> to_string_tag;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, to_string_tag,
GetProperty(receiver, isolate->factory()->to_string_tag_symbol()),
JSReceiver::GetProperty(receiver,
isolate->factory()->to_string_tag_symbol()),
String);
if (to_string_tag->IsString()) {
tag = Handle<String>::cast(to_string_tag);

View File

@ -1263,8 +1263,6 @@ class Object {
Handle<Object> object, Handle<Name> name);
MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
Handle<Object> receiver, Handle<Name> name, Handle<JSReceiver> holder);
MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty(
Isolate* isolate, Handle<Object> object, const char* key);
MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty(
Handle<Object> object, Handle<Name> name);
@ -1818,6 +1816,13 @@ class JSReceiver: public HeapObject {
MUST_USE_RESULT static inline Maybe<bool> HasOwnProperty(
Handle<JSReceiver> object, Handle<Name> name);
MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty(
Isolate* isolate, Handle<JSReceiver> receiver, const char* key);
MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty(
Handle<JSReceiver> receiver, Handle<Name> name);
MUST_USE_RESULT static inline MaybeHandle<Object> GetElement(
Isolate* isolate, Handle<JSReceiver> receiver, uint32_t index);
// Implementation of ES6 [[Delete]]
MUST_USE_RESULT static Maybe<bool> DeletePropertyOrElement(
Handle<JSReceiver> object, Handle<Name> name,

View File

@ -18,9 +18,9 @@ namespace {
// Helper function for ToPropertyDescriptor. Comments describe steps for
// "enumerable", other properties are handled the same way.
// Returns false if an exception was thrown.
bool GetPropertyIfPresent(Handle<Object> obj, Handle<String> name,
bool GetPropertyIfPresent(Handle<JSReceiver> receiver, Handle<String> name,
Handle<Object>* value) {
LookupIterator it(obj, name);
LookupIterator it(receiver, name, receiver);
// 4. Let hasEnumerable be HasProperty(Obj, "enumerable").
Maybe<bool> has_property = JSReceiver::HasProperty(&it);
// 5. ReturnIfAbrupt(hasEnumerable).
@ -29,7 +29,7 @@ bool GetPropertyIfPresent(Handle<Object> obj, Handle<String> name,
if (has_property.FromJust() == true) {
// 6a. Let enum be ToBoolean(Get(Obj, "enumerable")).
// 6b. ReturnIfAbrupt(enum).
if (!JSObject::GetProperty(&it).ToHandle(value)) return false;
if (!Object::GetProperty(&it).ToHandle(value)) return false;
}
return true;
}
@ -39,7 +39,7 @@ bool GetPropertyIfPresent(Handle<Object> obj, Handle<String> name,
// objects: nothing on the prototype chain, just own fast data properties.
// Must not have observable side effects, because the slow path will restart
// the entire conversion!
bool ToPropertyDescriptorFastPath(Isolate* isolate, Handle<Object> obj,
bool ToPropertyDescriptorFastPath(Isolate* isolate, Handle<JSReceiver> obj,
PropertyDescriptor* desc) {
if (!obj->IsJSObject()) return false;
Map* map = Handle<JSObject>::cast(obj)->map();
@ -190,14 +190,15 @@ bool PropertyDescriptor::ToPropertyDescriptor(Isolate* isolate,
// 3. Let desc be a new Property Descriptor that initially has no fields.
DCHECK(desc->is_empty());
if (ToPropertyDescriptorFastPath(isolate, obj, desc)) {
Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(obj);
if (ToPropertyDescriptorFastPath(isolate, receiver, desc)) {
return true;
}
// enumerable?
Handle<Object> enumerable;
// 4 through 6b.
if (!GetPropertyIfPresent(obj, isolate->factory()->enumerable_string(),
if (!GetPropertyIfPresent(receiver, isolate->factory()->enumerable_string(),
&enumerable)) {
return false;
}
@ -209,7 +210,7 @@ bool PropertyDescriptor::ToPropertyDescriptor(Isolate* isolate,
// configurable?
Handle<Object> configurable;
// 7 through 9b.
if (!GetPropertyIfPresent(obj, isolate->factory()->configurable_string(),
if (!GetPropertyIfPresent(receiver, isolate->factory()->configurable_string(),
&configurable)) {
return false;
}
@ -221,7 +222,8 @@ bool PropertyDescriptor::ToPropertyDescriptor(Isolate* isolate,
// value?
Handle<Object> value;
// 10 through 12b.
if (!GetPropertyIfPresent(obj, isolate->factory()->value_string(), &value)) {
if (!GetPropertyIfPresent(receiver, isolate->factory()->value_string(),
&value)) {
return false;
}
// 12c. Set the [[Value]] field of desc to value.
@ -230,7 +232,7 @@ bool PropertyDescriptor::ToPropertyDescriptor(Isolate* isolate,
// writable?
Handle<Object> writable;
// 13 through 15b.
if (!GetPropertyIfPresent(obj, isolate->factory()->writable_string(),
if (!GetPropertyIfPresent(receiver, isolate->factory()->writable_string(),
&writable)) {
return false;
}
@ -240,7 +242,8 @@ bool PropertyDescriptor::ToPropertyDescriptor(Isolate* isolate,
// getter?
Handle<Object> getter;
// 16 through 18b.
if (!GetPropertyIfPresent(obj, isolate->factory()->get_string(), &getter)) {
if (!GetPropertyIfPresent(receiver, isolate->factory()->get_string(),
&getter)) {
return false;
}
if (!getter.is_null()) {
@ -257,7 +260,8 @@ bool PropertyDescriptor::ToPropertyDescriptor(Isolate* isolate,
// setter?
Handle<Object> setter;
// 19 through 21b.
if (!GetPropertyIfPresent(obj, isolate->factory()->set_string(), &setter)) {
if (!GetPropertyIfPresent(receiver, isolate->factory()->set_string(),
&setter)) {
return false;
}
if (!setter.is_null()) {

View File

@ -302,8 +302,8 @@ RUNTIME_FUNCTION(Runtime_DebugGetPropertyDetails) {
if (name->AsArrayIndex(&index)) {
Handle<FixedArray> details = isolate->factory()->NewFixedArray(2);
Handle<Object> element_or_char;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, element_or_char,
Object::GetElement(isolate, obj, index));
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, element_or_char, JSReceiver::GetElement(isolate, obj, index));
details->set(0, *element_or_char);
details->set(1, PropertyDetails::Empty().AsSmi());
return *isolate->factory()->NewJSArrayWithElements(details);
@ -418,8 +418,8 @@ RUNTIME_FUNCTION(Runtime_DebugIndexedInterceptorElementValue) {
RUNTIME_ASSERT(obj->HasIndexedInterceptor());
CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]);
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
Object::GetElement(isolate, obj, index));
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, JSReceiver::GetElement(isolate, obj, index));
return *result;
}

View File

@ -158,8 +158,8 @@ RUNTIME_FUNCTION(Runtime_GetLanguageTagVariants) {
Handle<Name> base = factory->NewStringFromStaticChars("base");
for (unsigned int i = 0; i < length; ++i) {
Handle<Object> locale_id;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, locale_id,
Object::GetElement(isolate, input, i));
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, locale_id, JSReceiver::GetElement(isolate, input, i));
if (!locale_id->IsString()) {
return isolate->Throw(*factory->illegal_argument_string());
}

View File

@ -214,12 +214,14 @@ RUNTIME_FUNCTION(Runtime_LiveEditCheckAndDropActivations) {
Handle<Object> old_element;
Handle<Object> new_element;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, old_element, Object::GetElement(isolate, old_shared_array, i));
isolate, old_element,
JSReceiver::GetElement(isolate, old_shared_array, i));
RUNTIME_ASSERT(
old_element->IsJSValue() &&
Handle<JSValue>::cast(old_element)->value()->IsSharedFunctionInfo());
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, new_element, Object::GetElement(isolate, new_shared_array, i));
isolate, new_element,
JSReceiver::GetElement(isolate, new_shared_array, i));
RUNTIME_ASSERT(
new_element->IsUndefined() ||
(new_element->IsJSValue() &&

View File

@ -1058,7 +1058,8 @@ RUNTIME_FUNCTION(Runtime_InstanceOf) {
Handle<Object> prototype;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, prototype,
Object::GetProperty(callable, isolate->factory()->prototype_string()));
JSReceiver::GetProperty(Handle<JSReceiver>::cast(callable),
isolate->factory()->prototype_string()));
if (!prototype->IsJSReceiver()) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,

View File

@ -16,7 +16,7 @@ TEST(ArgumentsMapped) {
CHECK(arguments->IsJSObject() && !arguments->IsJSArray());
CHECK(JSObject::cast(*arguments)->HasSloppyArgumentsElements());
Handle<String> l = T.isolate->factory()->length_string();
Handle<Object> length = JSObject::GetProperty(arguments, l).ToHandleChecked();
Handle<Object> length = Object::GetProperty(arguments, l).ToHandleChecked();
CHECK_EQ(4, length->Number());
}
@ -29,7 +29,7 @@ TEST(ArgumentsUnmapped) {
CHECK(arguments->IsJSObject() && !arguments->IsJSArray());
CHECK(!JSObject::cast(*arguments)->HasSloppyArgumentsElements());
Handle<String> l = T.isolate->factory()->length_string();
Handle<Object> length = JSObject::GetProperty(arguments, l).ToHandleChecked();
Handle<Object> length = Object::GetProperty(arguments, l).ToHandleChecked();
CHECK_EQ(4, length->Number());
}
@ -42,7 +42,7 @@ TEST(ArgumentsRest) {
CHECK(arguments->IsJSObject() && arguments->IsJSArray());
CHECK(!JSObject::cast(*arguments)->HasSloppyArgumentsElements());
Handle<String> l = T.isolate->factory()->length_string();
Handle<Object> length = JSObject::GetProperty(arguments, l).ToHandleChecked();
Handle<Object> length = Object::GetProperty(arguments, l).ToHandleChecked();
CHECK_EQ(3, length->Number());
}

View File

@ -6004,7 +6004,7 @@ TEST(PreprocessStackTrace) {
Handle<Object> exception = v8::Utils::OpenHandle(*try_catch.Exception());
Handle<Name> key = isolate->factory()->stack_trace_symbol();
Handle<Object> stack_trace =
JSObject::GetProperty(exception, key).ToHandleChecked();
Object::GetProperty(exception, key).ToHandleChecked();
Handle<Object> code =
Object::GetElement(isolate, stack_trace, 3).ToHandleChecked();
CHECK(code->IsCode());

View File

@ -39,8 +39,8 @@ using namespace v8::internal;
static Handle<Object> GetGlobalProperty(const char* name) {
Isolate* isolate = CcTest::i_isolate();
return Object::GetProperty(
isolate, isolate->global_object(), name).ToHandleChecked();
return JSReceiver::GetProperty(isolate, isolate->global_object(), name)
.ToHandleChecked();
}
@ -227,10 +227,9 @@ TEST(C2JSFrames) {
Handle<JSObject> global(isolate->context()->global_object());
Execution::Call(isolate, fun0, global, 0, NULL).Check();
Handle<String> foo_string =
isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("foo"));
Handle<Object> fun1 = Object::GetProperty(
isolate->global_object(), foo_string).ToHandleChecked();
Handle<Object> fun1 =
JSReceiver::GetProperty(isolate, isolate->global_object(), "foo")
.ToHandleChecked();
CHECK(fun1->IsJSFunction());
Handle<Object> argv[] = {isolate->factory()->InternalizeOneByteString(

View File

@ -491,16 +491,17 @@ TEST(ObservationWeakMap) {
i::Isolate* i_isolate = CcTest::i_isolate();
i::Handle<i::JSObject> observation_state =
i_isolate->factory()->observation_state();
i::Handle<i::JSWeakMap> callbackInfoMap =
i::Handle<i::JSWeakMap>::cast(i::Object::GetProperty(
i_isolate, observation_state, "callbackInfoMap").ToHandleChecked());
i::Handle<i::JSWeakMap> objectInfoMap =
i::Handle<i::JSWeakMap>::cast(i::Object::GetProperty(
i_isolate, observation_state, "objectInfoMap").ToHandleChecked());
i::Handle<i::JSWeakMap> notifierObjectInfoMap =
i::Handle<i::JSWeakMap>::cast(i::Object::GetProperty(
i_isolate, observation_state, "notifierObjectInfoMap")
.ToHandleChecked());
i::Handle<i::JSWeakMap> callbackInfoMap = i::Handle<i::JSWeakMap>::cast(
i::JSReceiver::GetProperty(i_isolate, observation_state,
"callbackInfoMap")
.ToHandleChecked());
i::Handle<i::JSWeakMap> objectInfoMap = i::Handle<i::JSWeakMap>::cast(
i::JSReceiver::GetProperty(i_isolate, observation_state, "objectInfoMap")
.ToHandleChecked());
i::Handle<i::JSWeakMap> notifierObjectInfoMap = i::Handle<i::JSWeakMap>::cast(
i::JSReceiver::GetProperty(i_isolate, observation_state,
"notifierObjectInfoMap")
.ToHandleChecked());
CHECK_EQ(1, NumberOfElements(callbackInfoMap));
CHECK_EQ(1, NumberOfElements(objectInfoMap));
CHECK_EQ(1, NumberOfElements(notifierObjectInfoMap));

View File

@ -1599,9 +1599,9 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
CHECK(isolate->has_pending_exception());
i::Handle<i::JSObject> exception_handle(
i::JSObject::cast(isolate->pending_exception()));
i::Handle<i::String> message_string =
i::Handle<i::String>::cast(i::Object::GetProperty(
isolate, exception_handle, "message").ToHandleChecked());
i::Handle<i::String> message_string = i::Handle<i::String>::cast(
i::JSReceiver::GetProperty(isolate, exception_handle, "message")
.ToHandleChecked());
if (result == kSuccess) {
v8::base::OS::Print(
@ -5742,9 +5742,9 @@ TEST(BasicImportExportParsing) {
if (!parser.Parse(&info)) {
i::Handle<i::JSObject> exception_handle(
i::JSObject::cast(isolate->pending_exception()));
i::Handle<i::String> message_string =
i::Handle<i::String>::cast(i::Object::GetProperty(
isolate, exception_handle, "message").ToHandleChecked());
i::Handle<i::String> message_string = i::Handle<i::String>::cast(
i::JSReceiver::GetProperty(isolate, exception_handle, "message")
.ToHandleChecked());
v8::base::OS::Print(
"Parser failed on:\n"

View File

@ -43,7 +43,7 @@ class JSBuiltinReducerTest : public TypedGraphTest {
isolate()->factory()->NewStringFromAsciiChecked(
"Math")).ToHandleChecked();
Handle<JSFunction> f = Handle<JSFunction>::cast(
JSObject::GetProperty(
Object::GetProperty(
m, isolate()->factory()->NewStringFromAsciiChecked(name))
.ToHandleChecked());
return HeapConstant(f);