Commit 3e363204 authored by jkummerow's avatar jkummerow Committed by Commit bot

[cleanup] Refactor remaining builtins-*.cc to use TF_BUILTIN macro

Review-Url: https://codereview.chromium.org/2734323004
Cr-Commit-Position: refs/heads/master@{#43695}
parent f58177dd
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -104,110 +104,98 @@ BUILTIN(GlobalEval) {
}
// ES6 section 18.2.2 isFinite ( number )
void Builtins::Generate_GlobalIsFinite(compiler::CodeAssemblerState* state) {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
typedef CodeStubAssembler::Variable Variable;
CodeStubAssembler assembler(state);
TF_BUILTIN(GlobalIsFinite, CodeStubAssembler) {
Node* context = Parameter(4);
Node* context = assembler.Parameter(4);
Label return_true(&assembler), return_false(&assembler);
Label return_true(this), return_false(this);
// We might need to loop once for ToNumber conversion.
Variable var_num(&assembler, MachineRepresentation::kTagged);
Label loop(&assembler, &var_num);
var_num.Bind(assembler.Parameter(1));
assembler.Goto(&loop);
assembler.Bind(&loop);
Variable var_num(this, MachineRepresentation::kTagged);
Label loop(this, &var_num);
var_num.Bind(Parameter(1));
Goto(&loop);
Bind(&loop);
{
// Load the current {num} value.
Node* num = var_num.value();
// Check if {num} is a Smi or a HeapObject.
assembler.GotoIf(assembler.TaggedIsSmi(num), &return_true);
GotoIf(TaggedIsSmi(num), &return_true);
// Check if {num} is a HeapNumber.
Label if_numisheapnumber(&assembler),
if_numisnotheapnumber(&assembler, Label::kDeferred);
assembler.Branch(assembler.IsHeapNumberMap(assembler.LoadMap(num)),
&if_numisheapnumber, &if_numisnotheapnumber);
Label if_numisheapnumber(this),
if_numisnotheapnumber(this, Label::kDeferred);
Branch(IsHeapNumberMap(LoadMap(num)), &if_numisheapnumber,
&if_numisnotheapnumber);
assembler.Bind(&if_numisheapnumber);
Bind(&if_numisheapnumber);
{
// Check if {num} contains a finite, non-NaN value.
Node* num_value = assembler.LoadHeapNumberValue(num);
assembler.BranchIfFloat64IsNaN(assembler.Float64Sub(num_value, num_value),
&return_false, &return_true);
Node* num_value = LoadHeapNumberValue(num);
BranchIfFloat64IsNaN(Float64Sub(num_value, num_value), &return_false,
&return_true);
}
assembler.Bind(&if_numisnotheapnumber);
Bind(&if_numisnotheapnumber);
{
// Need to convert {num} to a Number first.
Callable callable = CodeFactory::NonNumberToNumber(assembler.isolate());
var_num.Bind(assembler.CallStub(callable, context, num));
assembler.Goto(&loop);
Callable callable = CodeFactory::NonNumberToNumber(isolate());
var_num.Bind(CallStub(callable, context, num));
Goto(&loop);
}
}
assembler.Bind(&return_true);
assembler.Return(assembler.BooleanConstant(true));
Bind(&return_true);
Return(BooleanConstant(true));
assembler.Bind(&return_false);
assembler.Return(assembler.BooleanConstant(false));
Bind(&return_false);
Return(BooleanConstant(false));
}
// ES6 section 18.2.3 isNaN ( number )
void Builtins::Generate_GlobalIsNaN(compiler::CodeAssemblerState* state) {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
typedef CodeStubAssembler::Variable Variable;
CodeStubAssembler assembler(state);
Node* context = assembler.Parameter(4);
TF_BUILTIN(GlobalIsNaN, CodeStubAssembler) {
Node* context = Parameter(4);
Label return_true(&assembler), return_false(&assembler);
Label return_true(this), return_false(this);
// We might need to loop once for ToNumber conversion.
Variable var_num(&assembler, MachineRepresentation::kTagged);
Label loop(&assembler, &var_num);
var_num.Bind(assembler.Parameter(1));
assembler.Goto(&loop);
assembler.Bind(&loop);
Variable var_num(this, MachineRepresentation::kTagged);
Label loop(this, &var_num);
var_num.Bind(Parameter(1));
Goto(&loop);
Bind(&loop);
{
// Load the current {num} value.
Node* num = var_num.value();
// Check if {num} is a Smi or a HeapObject.
assembler.GotoIf(assembler.TaggedIsSmi(num), &return_false);
GotoIf(TaggedIsSmi(num), &return_false);
// Check if {num} is a HeapNumber.
Label if_numisheapnumber(&assembler),
if_numisnotheapnumber(&assembler, Label::kDeferred);
assembler.Branch(assembler.IsHeapNumberMap(assembler.LoadMap(num)),
&if_numisheapnumber, &if_numisnotheapnumber);
Label if_numisheapnumber(this),
if_numisnotheapnumber(this, Label::kDeferred);
Branch(IsHeapNumberMap(LoadMap(num)), &if_numisheapnumber,
&if_numisnotheapnumber);
assembler.Bind(&if_numisheapnumber);
Bind(&if_numisheapnumber);
{
// Check if {num} contains a NaN.
Node* num_value = assembler.LoadHeapNumberValue(num);
assembler.BranchIfFloat64IsNaN(num_value, &return_true, &return_false);
Node* num_value = LoadHeapNumberValue(num);
BranchIfFloat64IsNaN(num_value, &return_true, &return_false);
}
assembler.Bind(&if_numisnotheapnumber);
Bind(&if_numisnotheapnumber);
{
// Need to convert {num} to a Number first.
Callable callable = CodeFactory::NonNumberToNumber(assembler.isolate());
var_num.Bind(assembler.CallStub(callable, context, num));
assembler.Goto(&loop);
Callable callable = CodeFactory::NonNumberToNumber(isolate());
var_num.Bind(CallStub(callable, context, num));
Goto(&loop);
}
}
assembler.Bind(&return_true);
assembler.Return(assembler.BooleanConstant(true));
Bind(&return_true);
Return(BooleanConstant(true));
assembler.Bind(&return_false);
assembler.Return(assembler.BooleanConstant(false));
Bind(&return_false);
Return(BooleanConstant(false));
}
} // namespace internal
......
This diff is collapsed.
......@@ -13,10 +13,6 @@
namespace v8 {
namespace internal {
typedef compiler::Node Node;
typedef CodeStubAssembler::ParameterMode ParameterMode;
typedef compiler::CodeAssemblerState CodeAssemblerState;
Node* PromiseBuiltinsAssembler::AllocateJSPromise(Node* context) {
Node* const native_context = LoadNativeContext(context);
Node* const promise_fun =
......
This diff is collapsed.
......@@ -68,48 +68,34 @@ BUILTIN(SymbolKeyFor) {
}
// ES6 section 19.4.3.4 Symbol.prototype [ @@toPrimitive ] ( hint )
void Builtins::Generate_SymbolPrototypeToPrimitive(
compiler::CodeAssemblerState* state) {
typedef compiler::Node Node;
CodeStubAssembler assembler(state);
TF_BUILTIN(SymbolPrototypeToPrimitive, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(4);
Node* receiver = assembler.Parameter(0);
Node* context = assembler.Parameter(4);
Node* result =
assembler.ToThisValue(context, receiver, PrimitiveType::kSymbol,
"Symbol.prototype [ @@toPrimitive ]");
assembler.Return(result);
Node* result = ToThisValue(context, receiver, PrimitiveType::kSymbol,
"Symbol.prototype [ @@toPrimitive ]");
Return(result);
}
// ES6 section 19.4.3.2 Symbol.prototype.toString ( )
void Builtins::Generate_SymbolPrototypeToString(
compiler::CodeAssemblerState* state) {
typedef compiler::Node Node;
CodeStubAssembler assembler(state);
Node* receiver = assembler.Parameter(0);
Node* context = assembler.Parameter(3);
Node* value = assembler.ToThisValue(context, receiver, PrimitiveType::kSymbol,
"Symbol.prototype.toString");
Node* result =
assembler.CallRuntime(Runtime::kSymbolDescriptiveString, context, value);
assembler.Return(result);
TF_BUILTIN(SymbolPrototypeToString, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* value = ToThisValue(context, receiver, PrimitiveType::kSymbol,
"Symbol.prototype.toString");
Node* result = CallRuntime(Runtime::kSymbolDescriptiveString, context, value);
Return(result);
}
// ES6 section 19.4.3.3 Symbol.prototype.valueOf ( )
void Builtins::Generate_SymbolPrototypeValueOf(
compiler::CodeAssemblerState* state) {
typedef compiler::Node Node;
CodeStubAssembler assembler(state);
Node* receiver = assembler.Parameter(0);
Node* context = assembler.Parameter(3);
TF_BUILTIN(SymbolPrototypeValueOf, CodeStubAssembler) {
Node* receiver = Parameter(0);
Node* context = Parameter(3);
Node* result = assembler.ToThisValue(
context, receiver, PrimitiveType::kSymbol, "Symbol.prototype.valueOf");
assembler.Return(result);
Node* result = ToThisValue(context, receiver, PrimitiveType::kSymbol,
"Symbol.prototype.valueOf");
Return(result);
}
} // namespace internal
......
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