[Torque] port Boolean prototype to Torque
Change-Id: Ia450876e085b8d4aec5df6be6d17a9cfa557980a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1866884 Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#64402}
This commit is contained in:
parent
8f58c84e45
commit
88e1cf8cf4
1
BUILD.gn
1
BUILD.gn
@ -1546,7 +1546,6 @@ v8_source_set("v8_initializers") {
|
||||
"src/builtins/builtins-async-iterator-gen.cc",
|
||||
"src/builtins/builtins-bigint-gen.cc",
|
||||
"src/builtins/builtins-bigint-gen.h",
|
||||
"src/builtins/builtins-boolean-gen.cc",
|
||||
"src/builtins/builtins-call-gen.cc",
|
||||
"src/builtins/builtins-call-gen.h",
|
||||
"src/builtins/builtins-collections-gen.cc",
|
||||
|
@ -1449,6 +1449,8 @@ const kStrictReadOnlyProperty: constexpr MessageTemplate
|
||||
|
||||
const kString: constexpr PrimitiveType
|
||||
generates 'PrimitiveType::kString';
|
||||
const kBoolean: constexpr PrimitiveType
|
||||
generates 'PrimitiveType::kBoolean';
|
||||
|
||||
const kNameDictionaryInitialCapacity:
|
||||
constexpr int32 generates 'NameDictionary::kInitialCapacity';
|
||||
|
@ -3,6 +3,11 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
namespace boolean {
|
||||
transitioning macro ThisBooleanValue(implicit context: Context)(
|
||||
receiver: JSAny, method: constexpr string): Boolean {
|
||||
return UnsafeCast<Boolean>(ToThisValue(receiver, kBoolean, method));
|
||||
}
|
||||
|
||||
javascript builtin
|
||||
BooleanConstructor(
|
||||
js-implicit context: Context, receiver: JSAny, newTarget: JSAny,
|
||||
@ -20,4 +25,20 @@ namespace boolean {
|
||||
obj.value = value;
|
||||
return obj;
|
||||
}
|
||||
|
||||
// ES #sec-boolean.prototype.tostring
|
||||
transitioning javascript builtin BooleanPrototypeToString(
|
||||
js-implicit context: Context, receiver: JSAny)(): JSAny {
|
||||
// 1. Let b be ? thisBooleanValue(this value).
|
||||
const b = ThisBooleanValue(receiver, 'Boolean.prototype.toString');
|
||||
// 2. If b is true, return "true"; else return "false".
|
||||
return b.to_string;
|
||||
}
|
||||
|
||||
// ES #sec-boolean.prototype.valueof
|
||||
transitioning javascript builtin BooleanPrototypeValueOf(
|
||||
js-implicit context: Context, receiver: JSAny)(): JSAny {
|
||||
// 1. Return ? thisBooleanValue(this value).
|
||||
return ThisBooleanValue(receiver, 'Boolean.prototype.valueOf');
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
// Copyright 2017 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/builtins/builtins-utils-gen.h"
|
||||
#include "src/builtins/builtins.h"
|
||||
#include "src/codegen/code-stub-assembler.h"
|
||||
#include "src/objects/oddball.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// ES6 section 19.3 Boolean Objects
|
||||
|
||||
// ES6 #sec-boolean.prototype.tostring
|
||||
TF_BUILTIN(BooleanPrototypeToString, CodeStubAssembler) {
|
||||
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
|
||||
TNode<Oddball> value =
|
||||
CAST(ToThisValue(context, receiver, PrimitiveType::kBoolean,
|
||||
"Boolean.prototype.toString"));
|
||||
TNode<String> result = CAST(LoadObjectField(value, Oddball::kToStringOffset));
|
||||
Return(result);
|
||||
}
|
||||
|
||||
// ES6 #sec-boolean.prototype.valueof
|
||||
TF_BUILTIN(BooleanPrototypeValueOf, CodeStubAssembler) {
|
||||
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
|
||||
TNode<Oddball> result = CAST(ToThisValue(
|
||||
context, receiver, PrimitiveType::kBoolean, "Boolean.prototype.valueOf"));
|
||||
Return(result);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
@ -394,12 +394,6 @@ namespace internal {
|
||||
CPP(BigIntPrototypeToString) \
|
||||
CPP(BigIntPrototypeValueOf) \
|
||||
\
|
||||
/* Boolean */ \
|
||||
/* ES6 #sec-boolean.prototype.tostring */ \
|
||||
TFJ(BooleanPrototypeToString, 0, kReceiver) \
|
||||
/* ES6 #sec-boolean.prototype.valueof */ \
|
||||
TFJ(BooleanPrototypeValueOf, 0, kReceiver) \
|
||||
\
|
||||
/* CallSite */ \
|
||||
CPP(CallSitePrototypeGetColumnNumber) \
|
||||
CPP(CallSitePrototypeGetEvalOrigin) \
|
||||
|
Loading…
Reference in New Issue
Block a user