Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[Interpreter] Inline ToBooleanStub and do some cleanup on unary ops.
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
rmcilroy authored and Commit bot committed May 19, 2016
1 parent 02f228e commit 9c6a52b
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 149 deletions.
27 changes: 21 additions & 6 deletions src/code-stubs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/code-stubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit 9c6a52b

Please sign in to comment.