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

Side by Side 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: Fix gcc error Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/interpreter/bytecode-array-builder.h" 5 #include "src/interpreter/bytecode-array-builder.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace interpreter { 9 namespace interpreter {
10 10
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 Strength strength) { 165 Strength strength) {
166 if (is_strong(strength)) { 166 if (is_strong(strength)) {
167 UNIMPLEMENTED(); 167 UNIMPLEMENTED();
168 } 168 }
169 169
170 Output(BytecodeForBinaryOperation(op), reg.ToOperand()); 170 Output(BytecodeForBinaryOperation(op), reg.ToOperand());
171 return *this; 171 return *this;
172 } 172 }
173 173
174 174
175 BytecodeArrayBuilder& BytecodeArrayBuilder::CountOperation(Token::Value op,
176 Strength strength) {
177 if (is_strong(strength)) {
178 UNIMPLEMENTED();
179 }
180
181 Output(BytecodeForCountOperation(op));
182 return *this;
183 }
184
185
175 BytecodeArrayBuilder& BytecodeArrayBuilder::LogicalNot() { 186 BytecodeArrayBuilder& BytecodeArrayBuilder::LogicalNot() {
176 Output(Bytecode::kLogicalNot); 187 Output(Bytecode::kLogicalNot);
177 return *this; 188 return *this;
178 } 189 }
179 190
180 191
181 BytecodeArrayBuilder& BytecodeArrayBuilder::TypeOf() { 192 BytecodeArrayBuilder& BytecodeArrayBuilder::TypeOf() {
182 Output(Bytecode::kTypeOf); 193 Output(Bytecode::kTypeOf);
183 return *this; 194 return *this;
184 } 195 }
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 return *this; 469 return *this;
459 } 470 }
460 471
461 472
462 BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToName() { 473 BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToName() {
463 Output(Bytecode::kToName); 474 Output(Bytecode::kToName);
464 return *this; 475 return *this;
465 } 476 }
466 477
467 478
479 BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToNumber() {
480 // TODO(rmcilroy): consider omitting if the preceeding bytecode always returns
481 // a number.
482 Output(Bytecode::kToNumber);
483 return *this;
484 }
485
486
468 BytecodeArrayBuilder& BytecodeArrayBuilder::Bind(BytecodeLabel* label) { 487 BytecodeArrayBuilder& BytecodeArrayBuilder::Bind(BytecodeLabel* label) {
469 if (label->is_forward_target()) { 488 if (label->is_forward_target()) {
470 // An earlier jump instruction refers to this label. Update it's location. 489 // An earlier jump instruction refers to this label. Update it's location.
471 PatchJump(bytecodes()->end(), bytecodes()->begin() + label->offset()); 490 PatchJump(bytecodes()->end(), bytecodes()->begin() + label->offset());
472 // Now treat as if the label will only be back referred to. 491 // Now treat as if the label will only be back referred to.
473 } 492 }
474 label->bind_to(bytecodes()->size()); 493 label->bind_to(bytecodes()->size());
475 return *this; 494 return *this;
476 } 495 }
477 496
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 case Token::Value::SHR: 839 case Token::Value::SHR:
821 return Bytecode::kShiftRightLogical; 840 return Bytecode::kShiftRightLogical;
822 default: 841 default:
823 UNREACHABLE(); 842 UNREACHABLE();
824 return static_cast<Bytecode>(-1); 843 return static_cast<Bytecode>(-1);
825 } 844 }
826 } 845 }
827 846
828 847
829 // static 848 // static
849 Bytecode BytecodeArrayBuilder::BytecodeForCountOperation(Token::Value op) {
850 switch (op) {
851 case Token::Value::ADD:
852 return Bytecode::kInc;
853 case Token::Value::SUB:
854 return Bytecode::kDec;
855 default:
856 UNREACHABLE();
857 return static_cast<Bytecode>(-1);
858 }
859 }
860
861
862 // static
830 Bytecode BytecodeArrayBuilder::BytecodeForCompareOperation(Token::Value op) { 863 Bytecode BytecodeArrayBuilder::BytecodeForCompareOperation(Token::Value op) {
831 switch (op) { 864 switch (op) {
832 case Token::Value::EQ: 865 case Token::Value::EQ:
833 return Bytecode::kTestEqual; 866 return Bytecode::kTestEqual;
834 case Token::Value::NE: 867 case Token::Value::NE:
835 return Bytecode::kTestNotEqual; 868 return Bytecode::kTestNotEqual;
836 case Token::Value::EQ_STRICT: 869 case Token::Value::EQ_STRICT:
837 return Bytecode::kTestEqualStrict; 870 return Bytecode::kTestEqualStrict;
838 case Token::Value::NE_STRICT: 871 case Token::Value::NE_STRICT:
839 return Bytecode::kTestNotEqualStrict; 872 return Bytecode::kTestNotEqualStrict;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 DCHECK_GT(next_consecutive_count_, 0); 1049 DCHECK_GT(next_consecutive_count_, 0);
1017 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); 1050 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_);
1018 allocated_.push_back(next_consecutive_register_); 1051 allocated_.push_back(next_consecutive_register_);
1019 next_consecutive_count_--; 1052 next_consecutive_count_--;
1020 return Register(next_consecutive_register_++); 1053 return Register(next_consecutive_register_++);
1021 } 1054 }
1022 1055
1023 } // namespace interpreter 1056 } // namespace interpreter
1024 } // namespace internal 1057 } // namespace internal
1025 } // namespace v8 1058 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698