[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/940129
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51626}
This commit is contained in:
Mathias Bynens 2018-02-28 11:35:16 +01:00 committed by Commit Bot
parent c8f34835af
commit df5483caee
3 changed files with 20 additions and 21 deletions

View File

@ -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);

View File

@ -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

View File

@ -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 */ \