Commit 9c6a52be authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[Interpreter] Inline ToBooleanStub and do some cleanup on unary ops.

Inlines the ToBoolean operations in the interpreter. Also do some
cleanup to unify UnaryOp helper in the Interpreter, remove the unused
BinaryOp Runtime call helper and remove extra newlines.

BUG=v8:4280
LOG=N

Review-Url: https://codereview.chromium.org/1998593002
Cr-Commit-Position: refs/heads/master@{#36366}
parent 02f228ec
......@@ -3638,13 +3638,17 @@ void ToLengthStub::GenerateAssembly(CodeStubAssembler* assembler) const {
}
}
void ToBooleanStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// static
compiler::Node* ToBooleanStub::Generate(CodeStubAssembler* assembler,
compiler::Node* value,
compiler::Node* context) {
typedef compiler::Node Node;
typedef CodeStubAssembler::Label Label;
typedef CodeStubAssembler::Variable Variable;
Node* value = assembler->Parameter(0);
Variable result(assembler, MachineRepresentation::kTagged);
Label if_valueissmi(assembler), if_valueisnotsmi(assembler),
return_true(assembler), return_false(assembler);
return_true(assembler), return_false(assembler), end(assembler);
// Check if {value} is a Smi or a HeapObject.
assembler->Branch(assembler->WordIsSmi(value), &if_valueissmi,
......@@ -3722,7 +3726,8 @@ void ToBooleanStub::GenerateAssembly(CodeStubAssembler* assembler) const {
// The {value} is an Oddball, and every Oddball knows its boolean value.
Node* value_toboolean =
assembler->LoadObjectField(value, Oddball::kToBooleanOffset);
assembler->Return(value_toboolean);
result.Bind(value_toboolean);
assembler->Goto(&end);
}
assembler->Bind(&if_valueisother);
......@@ -3740,11 +3745,21 @@ void ToBooleanStub::GenerateAssembly(CodeStubAssembler* assembler) const {
&return_true, &return_false);
}
}
assembler->Bind(&return_false);
assembler->Return(assembler->BooleanConstant(false));
{
result.Bind(assembler->BooleanConstant(false));
assembler->Goto(&end);
}
assembler->Bind(&return_true);
assembler->Return(assembler->BooleanConstant(true));
{
result.Bind(assembler->BooleanConstant(true));
assembler->Goto(&end);
}
assembler->Bind(&end);
return result.value();
}
void ToIntegerStub::GenerateAssembly(CodeStubAssembler* assembler) const {
......
......@@ -934,7 +934,7 @@ class ToBooleanStub final : public TurboFanCodeStub {
explicit ToBooleanStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion);
DEFINE_TURBOFAN_CODE_STUB(ToBoolean, TurboFanCodeStub);
DEFINE_TURBOFAN_UNARY_OP_CODE_STUB(ToBoolean, TurboFanCodeStub);
};
class ToIntegerStub final : public TurboFanCodeStub {
......
This diff is collapsed.
......@@ -73,14 +73,13 @@ class Interpreter {
// Generates code to perform the binary operation via |callable|.
void DoBinaryOp(Callable callable, InterpreterAssembler* assembler);
// Generates code to perform the binary operation via |function_id|.
void DoBinaryOp(Runtime::FunctionId function_id,
InterpreterAssembler* assembler);
// Generates code to perform the binary operation via |Generator|.
template <class Generator>
void DoBinaryOp(InterpreterAssembler* assembler);
// Generates code to perform the unary operation via |callable|.
void DoUnaryOp(Callable callable, InterpreterAssembler* assembler);
// Generates code to perform the unary operation via |Generator|.
template <class Generator>
void DoUnaryOp(InterpreterAssembler* assembler);
......@@ -125,12 +124,6 @@ class Interpreter {
// Generates code to perform a constructor call.
void DoCallConstruct(InterpreterAssembler* assembler);
// Generates code to perform a type conversion.
void DoTypeConversionOp(Callable callable, InterpreterAssembler* assembler);
// Generates code to perform logical-not on boolean |value|.
void DoLogicalNotOp(compiler::Node* value, InterpreterAssembler* assembler);
// Generates code to perform delete via function_id.
void DoDelete(Runtime::FunctionId function_id,
InterpreterAssembler* assembler);
......@@ -143,6 +136,16 @@ class Interpreter {
void DoStoreLookupSlot(LanguageMode language_mode,
InterpreterAssembler* assembler);
// Generates code to perform logical-not on boolean |value| and returns the
// result.
compiler::Node* BuildLogicalNot(compiler::Node* value,
InterpreterAssembler* assembler);
// Generates code to convert |value| to a boolean and returns the
// result.
compiler::Node* BuildToBoolean(compiler::Node* value,
InterpreterAssembler* assembler);
uintptr_t GetDispatchCounter(Bytecode from, Bytecode to) const;
// Get dispatch table index of bytecode.
......
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