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

Unified Diff: src/interpreter/bytecode-array-builder.cc

Issue 1416623003: [Interpreter] Add support for for count operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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/bytecode-array-builder.cc
diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc
index 8e52ecd7fd287b1d475b2971f5f24df86c5edd84..e100491bb06c0be3bb592659e67d469c097f3251 100644
--- a/src/interpreter/bytecode-array-builder.cc
+++ b/src/interpreter/bytecode-array-builder.cc
@@ -151,6 +151,17 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::BinaryOperation(Token::Value op,
}
+BytecodeArrayBuilder& BytecodeArrayBuilder::CountOperation(Token::Value op,
+ Strength strength) {
+ if (is_strong(strength)) {
+ UNIMPLEMENTED();
+ }
+
+ Output(BytecodeForCountOperation(op));
+ return *this;
+}
+
+
BytecodeArrayBuilder& BytecodeArrayBuilder::LogicalNot() {
Output(Bytecode::kLogicalNot);
return *this;
@@ -428,6 +439,14 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToName() {
}
+BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToNumber() {
+ // TODO(rmcilroy): consider omitting if the preceeding bytecode always returns
+ // a number.
+ Output(Bytecode::kToNumber);
+ return *this;
+}
+
+
BytecodeArrayBuilder& BytecodeArrayBuilder::Bind(BytecodeLabel* label) {
if (label->is_forward_target()) {
// An earlier jump instruction refers to this label. Update it's location.
@@ -724,6 +743,20 @@ Bytecode BytecodeArrayBuilder::BytecodeForBinaryOperation(Token::Value op) {
// static
+Bytecode BytecodeArrayBuilder::BytecodeForCountOperation(Token::Value op) {
+ switch (op) {
+ case Token::Value::ADD:
+ return Bytecode::kInc;
+ case Token::Value::SUB:
+ return Bytecode::kDec;
+ default:
+ UNREACHABLE();
+ return static_cast<Bytecode>(-1);
+ }
+}
+
+
+// static
Bytecode BytecodeArrayBuilder::BytecodeForCompareOperation(Token::Value op) {
switch (op) {
case Token::Value::EQ:

Powered by Google App Engine
This is Rietveld 408576698