Revert of [builtins] Migrate Object.getOwnPropertyDescriptor to C++. (patchset #1 id:1 of https://codereview.chromium.org/1606783002/ )

Reason for revert:
Breaks roll: https://codereview.chromium.org/1603953002/

Original issue's description:
> [builtins] Migrate Object.getOwnPropertyDescriptor to C++.
>
> The implementation of Object.getOwnPropertyDescriptor always called into
> C++ anyway, so there's no need to have this JavaScript wrapper around at
> all.
>
> R=yangguo@chromium.org
>
> Committed: https://crrev.com/3fdd37b028f4711d0f6dcb038f575ce08ef0cfa3
> Cr-Commit-Position: refs/heads/master@{#33379}

TBR=yangguo@chromium.org,bmeurer@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.

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

Cr-Commit-Position: refs/heads/master@{#33404}
This commit is contained in:
hablich 2016-01-20 04:29:48 -08:00 committed by Commit bot
parent 8f67a6e710
commit 654a63e1e1
6 changed files with 33 additions and 27 deletions

View File

@ -1098,8 +1098,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSFunction> object_freeze = SimpleInstallFunction(
object_function, "freeze", Builtins::kObjectFreeze, 1, false);
native_context()->set_object_freeze(*object_freeze);
SimpleInstallFunction(object_function, "getOwnPropertyDescriptor",
Builtins::kObjectGetOwnPropertyDescriptor, 2, false);
SimpleInstallFunction(object_function, "getOwnPropertySymbols",
Builtins::kObjectGetOwnPropertySymbols, 1, false);
Handle<JSFunction> object_is_extensible =

View File

@ -1566,30 +1566,6 @@ BUILTIN(ObjectFreeze) {
}
// ES6 section 19.1.2.6 Object.getOwnPropertyDescriptor ( O, P )
BUILTIN(ObjectGetOwnPropertyDescriptor) {
HandleScope scope(isolate);
// 1. Let obj be ? ToObject(O).
Handle<Object> object = args.atOrUndefined(isolate, 1);
Handle<JSReceiver> receiver;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver,
Object::ToObject(isolate, object));
// 2. Let key be ? ToPropertyKey(P).
Handle<Object> property = args.atOrUndefined(isolate, 2);
Handle<Name> key;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key,
Object::ToName(isolate, property));
// 3. Let desc be ? obj.[[GetOwnProperty]](key).
PropertyDescriptor desc;
Maybe<bool> found =
JSReceiver::GetOwnPropertyDescriptor(isolate, receiver, key, &desc);
MAYBE_RETURN(found, isolate->heap()->exception());
// 4. Return FromPropertyDescriptor(desc).
if (!found.FromJust()) return isolate->heap()->undefined_value();
return *desc.ToObject(isolate);
}
// ES6 section 19.1.2.8 Object.getOwnPropertySymbols ( O )
BUILTIN(ObjectGetOwnPropertySymbols) {
HandleScope scope(isolate);

View File

@ -110,7 +110,6 @@ inline bool operator&(BuiltinExtraArguments lhs, BuiltinExtraArguments rhs) {
V(ObjectAssign, kNone) \
V(ObjectCreate, kNone) \
V(ObjectFreeze, kNone) \
V(ObjectGetOwnPropertyDescriptor, kNone) \
V(ObjectGetOwnPropertySymbols, kNone) \
V(ObjectIsExtensible, kNone) \
V(ObjectIsFrozen, kNone) \

View File

@ -772,6 +772,12 @@ function ObjectSetPrototypeOf(obj, proto) {
}
// ES6 section 19.1.2.6
function ObjectGetOwnPropertyDescriptor(obj, p) {
return %GetOwnProperty(obj, p);
}
// ES5 section 15.2.3.4.
function ObjectGetOwnPropertyNames(obj) {
obj = TO_OBJECT(obj);
@ -883,6 +889,7 @@ utils.InstallFunctions(GlobalObject, DONT_ENUM, [
"defineProperties", ObjectDefineProperties,
"getPrototypeOf", ObjectGetPrototypeOf,
"setPrototypeOf", ObjectSetPrototypeOf,
"getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor,
"getOwnPropertyNames", ObjectGetOwnPropertyNames,
// getOwnPropertySymbols is added in symbol.js.
"is", SameValue, // ECMA-262, Edition 6, section 19.1.2.10

View File

@ -266,6 +266,31 @@ RUNTIME_FUNCTION(Runtime_GetOwnProperty_Legacy) {
}
// ES6 19.1.2.6
RUNTIME_FUNCTION(Runtime_GetOwnProperty) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, raw_name, 1);
// 1. Let obj be ? ToObject(O).
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, object,
Object::ToObject(isolate, object));
// 2. Let key be ? ToPropertyKey(P).
Handle<Name> key;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key,
Object::ToName(isolate, raw_name));
// 3. Let desc be ? obj.[[GetOwnProperty]](key).
PropertyDescriptor desc;
Maybe<bool> found = JSReceiver::GetOwnPropertyDescriptor(
isolate, Handle<JSReceiver>::cast(object), key, &desc);
MAYBE_RETURN(found, isolate->heap()->exception());
// 4. Return FromPropertyDescriptor(desc).
if (!found.FromJust()) return isolate->heap()->undefined_value();
return *desc.ToObject(isolate);
}
RUNTIME_FUNCTION(Runtime_OptimizeObjectForAddingMultipleProperties) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);

View File

@ -414,6 +414,7 @@ namespace internal {
F(GetPrototype, 1, 1) \
F(InternalSetPrototype, 2, 1) \
F(SetPrototype, 2, 1) \
F(GetOwnProperty, 2, 1) \
F(GetOwnProperty_Legacy, 2, 1) \
F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
F(GetProperty, 2, 1) \