Commit ec37add6 authored by jkummerow's avatar jkummerow Committed by Commit bot

[API] GetOwnPropertyDescriptor: use C++ implementation

Also delete a bunch of dead code from src/js/.

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

Cr-Commit-Position: refs/heads/master@{#32650}
parent 18a3ddcf
......@@ -3659,17 +3659,18 @@ MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context,
Local<String> key) {
PREPARE_FOR_EXECUTION(context, "v8::Object::GetOwnPropertyDescriptor()",
Value);
auto obj = Utils::OpenHandle(this);
auto key_name = Utils::OpenHandle(*key);
i::Handle<i::Object> args[] = { obj, key_name };
i::Handle<i::JSFunction> fun = isolate->object_get_own_property_descriptor();
i::Handle<i::Object> undefined = isolate->factory()->undefined_value();
i::Handle<i::Object> result;
has_pending_exception =
!i::Execution::Call(isolate, fun, undefined, arraysize(args), args)
.ToHandle(&result);
i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
i::Handle<i::String> key_name = Utils::OpenHandle(*key);
i::PropertyDescriptor desc;
bool found =
i::JSReceiver::GetOwnPropertyDescriptor(isolate, obj, key_name, &desc);
has_pending_exception = isolate->has_pending_exception();
RETURN_ON_FAILED_EXECUTION(Value);
RETURN_ESCAPED(Utils::ToLocal(result));
if (!found) {
return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
}
RETURN_ESCAPED(Utils::ToLocal(desc.ToObject(isolate)));
}
......
......@@ -130,8 +130,6 @@ enum BindingFlags {
no_side_effect_to_string_fun) \
V(OBJECT_VALUE_OF, JSFunction, object_value_of) \
V(OBJECT_TO_STRING, JSFunction, object_to_string) \
V(OBJECT_GET_OWN_PROPERTY_DESCROPTOR_INDEX, JSFunction, \
object_get_own_property_descriptor) \
V(OBSERVERS_BEGIN_SPLICE_INDEX, JSFunction, observers_begin_perform_splice) \
V(OBSERVERS_END_SPLICE_INDEX, JSFunction, observers_end_perform_splice) \
V(OBSERVERS_ENQUEUE_SPLICE_INDEX, JSFunction, observers_enqueue_splice) \
......@@ -152,8 +150,6 @@ enum BindingFlags {
V(SET_HAS_METHOD_INDEX, JSFunction, set_has) \
V(STACK_OVERFLOW_BOILERPLATE_INDEX, JSObject, stack_overflow_boilerplate) \
V(SYNTAX_ERROR_FUNCTION_INDEX, JSFunction, syntax_error_function) \
V(TO_COMPLETE_PROPERTY_DESCRIPTOR_INDEX, JSFunction, \
to_complete_property_descriptor) \
V(TO_DETAIL_STRING_FUN_INDEX, JSFunction, to_detail_string_fun) \
V(TYPE_ERROR_FUNCTION_INDEX, JSFunction, type_error_function) \
V(URI_ERROR_FUNCTION_INDEX, JSFunction, uri_error_function) \
......
......@@ -490,6 +490,7 @@ function ArrayPop() {
n--;
var value = array[n];
// TODO(jkummerow): Use %DeleteProperty_Strict instead, delete "Delete".
Delete(array, n, true);
array.length = n;
return value;
......
......@@ -12,8 +12,6 @@
// Imports
//
var GlobalProxy = global.Proxy;
var GlobalFunction = global.Function;
var GlobalObject = global.Object;
var MakeTypeError;
utils.Import(function(from) {
......@@ -30,75 +28,6 @@ function ProxyCreateRevocable(target, handler) {
// -------------------------------------------------------------------
// Proxy Builtins
function DerivedConstructTrap(callTrap) {
return function() {
var proto = this.prototype
if (!IS_SPEC_OBJECT(proto)) proto = GlobalObject.prototype
var obj = { __proto__: proto };
var result = %Apply(callTrap, obj, arguments, 0, %_ArgumentsLength());
return IS_SPEC_OBJECT(result) ? result : obj
}
}
function DelegateCallAndConstruct(callTrap, constructTrap) {
return function() {
return %Apply(IS_UNDEFINED(new.target) ? callTrap : constructTrap,
this, arguments, 0, %_ArgumentsLength())
}
}
function DerivedSetTrap(receiver, name, val) {
var desc = this.getOwnPropertyDescriptor(name)
if (desc) {
if ('writable' in desc) {
if (desc.writable) {
desc.value = val
this.defineProperty(name, desc)
return true
} else {
return false
}
} else { // accessor
if (desc.set) {
// The proposal says: desc.set.call(receiver, val)
%_Call(desc.set, receiver, val)
return true
} else {
return false
}
}
}
desc = this.getPropertyDescriptor(name)
if (desc) {
if ('writable' in desc) {
if (desc.writable) {
// fall through
} else {
return false
}
} else { // accessor
if (desc.set) {
// The proposal says: desc.set.call(receiver, val)
%_Call(desc.set, receiver, val)
return true
} else {
return false
}
}
}
this.defineProperty(name, {
value: val,
writable: true,
enumerable: true,
configurable: true});
return true;
}
function DerivedHasOwnTrap(name) {
return !!this.getOwnPropertyDescriptor(name)
}
// Implements part of ES6 9.5.11 Proxy.[[Enumerate]]:
// Call the trap, which should return an iterator, exhaust the iterator,
// and return an array containing the values.
......@@ -135,11 +64,6 @@ utils.InstallFunctions(GlobalProxy, DONT_ENUM, [
// -------------------------------------------------------------------
// Exports
utils.Export(function(to) {
to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct;
to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap;
});
%InstallToContext([
"proxy_enumerate", ProxyEnumerate,
]);
......
......@@ -25,8 +25,6 @@ var NaN = %GetRootNaN();
var ObserveBeginPerformSplice;
var ObserveEndPerformSplice;
var ObserveEnqueueSpliceRecord;
var ProxyDelegateCallAndConstruct;
var ProxyDerivedHasOwnTrap;
var SameValue = utils.ImportNow("SameValue");
var StringIndexOf;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
......@@ -44,8 +42,6 @@ utils.Import(function(from) {
utils.ImportFromExperimental(function(from) {
FLAG_harmony_tostring = from.FLAG_harmony_tostring;
ProxyDelegateCallAndConstruct = from.ProxyDelegateCallAndConstruct;
ProxyDerivedHasOwnTrap = from.ProxyDerivedHasOwnTrap;
});
// ----------------------------------------------------------------------------
......@@ -514,11 +510,6 @@ function GetTrap(handler, name, defaultTrap) {
}
function CallTrap0(handler, name, defaultTrap) {
return %_Call(GetTrap(handler, name, defaultTrap), handler);
}
function CallTrap1(handler, name, defaultTrap, x) {
return %_Call(GetTrap(handler, name, defaultTrap), handler, x);
}
......@@ -1614,8 +1605,6 @@ utils.Export(function(to) {
"global_eval_fun", GlobalEval,
"object_value_of", ObjectValueOf,
"object_to_string", ObjectToString,
"object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor,
"to_complete_property_descriptor", ToCompletePropertyDescriptor,
]);
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment