Commit df5483ca authored by Mathias Bynens's avatar Mathias Bynens Committed by Commit Bot

[builtins] Remove BooleanConstructor_ConstructStub builtin

This brings us closer to our goal of deprecating the `construct_stub`
field in `SharedFunctionInfo`.

Bug: v8:7503
Change-Id: I20e6c7d58e7cdcc7316e35568357a4ad3059a892
Reviewed-on: https://chromium-review.googlesource.com/940129Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51626}
parent c8f34835
......@@ -1909,7 +1909,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
isolate->initial_object_prototype(), Builtins::kBooleanConstructor);
boolean_fun->shared()->DontAdaptArguments();
boolean_fun->shared()->SetConstructStub(
*BUILTIN_CODE(isolate, BooleanConstructor_ConstructStub));
*BUILTIN_CODE(isolate, JSBuiltinsConstructStub));
boolean_fun->shared()->set_length(1);
InstallWithIntrinsicDefaultProto(isolate, boolean_fun,
Context::BOOLEAN_FUNCTION_INDEX);
......
......@@ -11,28 +11,27 @@ namespace v8 {
namespace internal {
// -----------------------------------------------------------------------------
// ES6 section 19.3 Boolean Objects
// ES #sec-boolean-objects
// ES6 section 19.3.1.1 Boolean ( value ) for the [[Call]] case.
// ES #sec-boolean-constructor
BUILTIN(BooleanConstructor) {
HandleScope scope(isolate);
Handle<Object> value = args.atOrUndefined(isolate, 1);
return isolate->heap()->ToBoolean(value->BooleanValue());
}
// ES6 section 19.3.1.1 Boolean ( value ) for the [[Construct]] case.
BUILTIN(BooleanConstructor_ConstructStub) {
HandleScope scope(isolate);
Handle<Object> value = args.atOrUndefined(isolate, 1);
Handle<JSFunction> target = args.target();
Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target());
DCHECK(*target == target->native_context()->boolean_function());
Handle<JSObject> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
JSObject::New(target, new_target));
Handle<JSValue>::cast(result)->set_value(
isolate->heap()->ToBoolean(value->BooleanValue()));
return *result;
if (args.new_target()->IsUndefined(isolate)) { // [[Call]]
Handle<Object> value = args.atOrUndefined(isolate, 1);
return isolate->heap()->ToBoolean(value->BooleanValue());
} else { // [[Construct]]
HandleScope scope(isolate);
Handle<Object> value = args.atOrUndefined(isolate, 1);
Handle<JSFunction> target = args.target();
Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target());
DCHECK(*target == target->native_context()->boolean_function());
Handle<JSObject> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
JSObject::New(target, new_target));
Handle<JSValue>::cast(result)->set_value(
isolate->heap()->ToBoolean(value->BooleanValue()));
return *result;
}
}
} // namespace internal
......
......@@ -382,8 +382,8 @@ namespace internal {
CPP(BigIntPrototypeValueOf) \
\
/* Boolean */ \
/* ES #sec-boolean-constructor */ \
CPP(BooleanConstructor) \
CPP(BooleanConstructor_ConstructStub) \
/* ES6 #sec-boolean.prototype.tostring */ \
TFJ(BooleanPrototypeToString, 0) \
/* ES6 #sec-boolean.prototype.valueof */ \
......
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