Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: src/interpreter/interpreter.cc

Issue 1985033002: [Interpreter] Change LogicalNot to ToBooleanLogicalNot and add non-ToBoolean version. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/interpreter/interpreter.cc
diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc
index 226ddbd8533bca6b28763f4e475a673c93d3642d..1f90a27b438b56cb544f1b05d992d10e6e548d25 100644
--- a/src/interpreter/interpreter.cc
+++ b/src/interpreter/interpreter.cc
@@ -852,22 +852,11 @@ void Interpreter::DoDec(InterpreterAssembler* assembler) {
DoCountOp(CodeFactory::Dec(isolate_), assembler);
}
-
-// LogicalNot
-//
-// Perform logical-not on the accumulator, first casting the
-// accumulator to a boolean value if required.
-void Interpreter::DoLogicalNot(InterpreterAssembler* assembler) {
- Callable callable = CodeFactory::ToBoolean(isolate_);
- Node* target = __ HeapConstant(callable.code());
- Node* accumulator = __ GetAccumulator();
- Node* context = __ GetContext();
- Node* to_boolean_value =
- __ CallStub(callable.descriptor(), target, context, accumulator);
+void Interpreter::DoLogicalNotOp(Node* value, InterpreterAssembler* assembler) {
Label if_true(assembler), if_false(assembler), end(assembler);
Node* true_value = __ BooleanConstant(true);
Node* false_value = __ BooleanConstant(false);
- __ BranchIfWordEqual(to_boolean_value, true_value, &if_true, &if_false);
+ __ BranchIfWordEqual(value, true_value, &if_true, &if_false);
__ Bind(&if_true);
{
__ SetAccumulator(false_value);
@@ -875,10 +864,38 @@ void Interpreter::DoLogicalNot(InterpreterAssembler* assembler) {
}
__ Bind(&if_false);
{
+ if (FLAG_debug_code) {
+ __ AbortIfWordNotEqual(value, false_value,
+ BailoutReason::kExpectedBooleanValue);
+ }
__ SetAccumulator(true_value);
__ Goto(&end);
}
__ Bind(&end);
+}
+
+// ToBooleanLogicalNot
+//
+// Perform logical-not on the accumulator, first casting the
+// accumulator to a boolean value if required.
+void Interpreter::DoToBooleanLogicalNot(InterpreterAssembler* assembler) {
+ Callable callable = CodeFactory::ToBoolean(isolate_);
+ Node* target = __ HeapConstant(callable.code());
+ Node* accumulator = __ GetAccumulator();
+ Node* context = __ GetContext();
+ Node* to_boolean_value =
+ __ CallStub(callable.descriptor(), target, context, accumulator);
+ DoLogicalNotOp(to_boolean_value, assembler);
+ __ Dispatch();
+}
+
+// LogicalNot
+//
+// Perform logical-not on the accumulator, which must already be a boolean
+// value.
+void Interpreter::DoLogicalNot(InterpreterAssembler* assembler) {
+ Node* value = __ GetAccumulator();
+ DoLogicalNotOp(value, assembler);
__ Dispatch();
}

Powered by Google App Engine
This is Rietveld 408576698