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

Side by Side Diff: src/interpreter/bytecode-array-builder.cc

Issue 1385623002: [Interpreter]: Add support for strict mode load / store ICs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix gcc error 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 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 122
123 void BytecodeArrayBuilder::Output(Bytecode bytecode) { 123 void BytecodeArrayBuilder::Output(Bytecode bytecode) {
124 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 0); 124 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 0);
125 last_bytecode_start_ = bytecodes()->size(); 125 last_bytecode_start_ = bytecodes()->size();
126 bytecodes()->push_back(Bytecodes::ToByte(bytecode)); 126 bytecodes()->push_back(Bytecodes::ToByte(bytecode));
127 } 127 }
128 128
129 129
130 BytecodeArrayBuilder& BytecodeArrayBuilder::BinaryOperation(Token::Value op, 130 BytecodeArrayBuilder& BytecodeArrayBuilder::BinaryOperation(Token::Value op,
131 Register reg) { 131 Register reg,
132 Strength strength) {
133 if (is_strong(strength)) {
134 UNIMPLEMENTED();
135 }
136
132 Output(BytecodeForBinaryOperation(op), reg.ToOperand()); 137 Output(BytecodeForBinaryOperation(op), reg.ToOperand());
133 return *this; 138 return *this;
134 } 139 }
135 140
136 141
137 BytecodeArrayBuilder& BytecodeArrayBuilder::LogicalNot() { 142 BytecodeArrayBuilder& BytecodeArrayBuilder::LogicalNot() {
138 Output(Bytecode::kLogicalNot); 143 Output(Bytecode::kLogicalNot);
139 return *this; 144 return *this;
140 } 145 }
141 146
142 147
143 BytecodeArrayBuilder& BytecodeArrayBuilder::TypeOf() { 148 BytecodeArrayBuilder& BytecodeArrayBuilder::TypeOf() {
144 Output(Bytecode::kTypeOf); 149 Output(Bytecode::kTypeOf);
145 return *this; 150 return *this;
146 } 151 }
147 152
148 153
149 BytecodeArrayBuilder& BytecodeArrayBuilder::CompareOperation( 154 BytecodeArrayBuilder& BytecodeArrayBuilder::CompareOperation(
150 Token::Value op, Register reg, LanguageMode language_mode) { 155 Token::Value op, Register reg, Strength strength) {
151 if (!is_sloppy(language_mode)) { 156 if (is_strong(strength)) {
152 UNIMPLEMENTED(); 157 UNIMPLEMENTED();
153 } 158 }
154 159
155 Output(BytecodeForCompareOperation(op), reg.ToOperand()); 160 Output(BytecodeForCompareOperation(op), reg.ToOperand());
156 return *this; 161 return *this;
157 } 162 }
158 163
159 164
160 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadLiteral( 165 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadLiteral(
161 v8::internal::Smi* smi) { 166 v8::internal::Smi* smi) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 if (FitsInIdx8Operand(slot_index)) { 236 if (FitsInIdx8Operand(slot_index)) {
232 Output(Bytecode::kLdaGlobal, static_cast<uint8_t>(slot_index)); 237 Output(Bytecode::kLdaGlobal, static_cast<uint8_t>(slot_index));
233 } else { 238 } else {
234 UNIMPLEMENTED(); 239 UNIMPLEMENTED();
235 } 240 }
236 return *this; 241 return *this;
237 } 242 }
238 243
239 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( 244 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty(
240 Register object, int feedback_slot, LanguageMode language_mode) { 245 Register object, int feedback_slot, LanguageMode language_mode) {
241 if (!is_sloppy(language_mode)) { 246 Bytecode bytecode = BytecodeForLoadIC(language_mode);
242 UNIMPLEMENTED();
243 }
244
245 if (FitsInIdx8Operand(feedback_slot)) { 247 if (FitsInIdx8Operand(feedback_slot)) {
246 Output(Bytecode::kLoadIC, object.ToOperand(), 248 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(feedback_slot));
247 static_cast<uint8_t>(feedback_slot));
248 } else { 249 } else {
249 UNIMPLEMENTED(); 250 UNIMPLEMENTED();
250 } 251 }
251 return *this; 252 return *this;
252 } 253 }
253 254
254 255
255 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty( 256 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty(
256 Register object, int feedback_slot, LanguageMode language_mode) { 257 Register object, int feedback_slot, LanguageMode language_mode) {
257 if (!is_sloppy(language_mode)) { 258 Bytecode bytecode = BytecodeForKeyedLoadIC(language_mode);
258 UNIMPLEMENTED();
259 }
260
261 if (FitsInIdx8Operand(feedback_slot)) { 259 if (FitsInIdx8Operand(feedback_slot)) {
262 Output(Bytecode::kKeyedLoadIC, object.ToOperand(), 260 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(feedback_slot));
263 static_cast<uint8_t>(feedback_slot));
264 } else { 261 } else {
265 UNIMPLEMENTED(); 262 UNIMPLEMENTED();
266 } 263 }
267 return *this; 264 return *this;
268 } 265 }
269 266
270 267
271 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty( 268 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty(
272 Register object, Register name, int feedback_slot, 269 Register object, Register name, int feedback_slot,
273 LanguageMode language_mode) { 270 LanguageMode language_mode) {
274 if (!is_sloppy(language_mode)) { 271 Bytecode bytecode = BytecodeForStoreIC(language_mode);
275 UNIMPLEMENTED();
276 }
277
278 if (FitsInIdx8Operand(feedback_slot)) { 272 if (FitsInIdx8Operand(feedback_slot)) {
279 Output(Bytecode::kStoreIC, object.ToOperand(), name.ToOperand(), 273 Output(bytecode, object.ToOperand(), name.ToOperand(),
280 static_cast<uint8_t>(feedback_slot)); 274 static_cast<uint8_t>(feedback_slot));
281 } else { 275 } else {
282 UNIMPLEMENTED(); 276 UNIMPLEMENTED();
283 } 277 }
284 return *this; 278 return *this;
285 } 279 }
286 280
287 281
288 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreKeyedProperty( 282 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreKeyedProperty(
289 Register object, Register key, int feedback_slot, 283 Register object, Register key, int feedback_slot,
290 LanguageMode language_mode) { 284 LanguageMode language_mode) {
291 if (!is_sloppy(language_mode)) { 285 Bytecode bytecode = BytecodeForKeyedStoreIC(language_mode);
292 UNIMPLEMENTED();
293 }
294
295 if (FitsInIdx8Operand(feedback_slot)) { 286 if (FitsInIdx8Operand(feedback_slot)) {
296 Output(Bytecode::kKeyedStoreIC, object.ToOperand(), key.ToOperand(), 287 Output(bytecode, object.ToOperand(), key.ToOperand(),
297 static_cast<uint8_t>(feedback_slot)); 288 static_cast<uint8_t>(feedback_slot));
298 } else { 289 } else {
299 UNIMPLEMENTED(); 290 UNIMPLEMENTED();
300 } 291 }
301 return *this; 292 return *this;
302 } 293 }
303 294
304 295
305 BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToBoolean() { 296 BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToBoolean() {
306 if (LastBytecodeInSameBlock()) { 297 if (LastBytecodeInSameBlock()) {
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 case Token::Value::IN: 604 case Token::Value::IN:
614 return Bytecode::kTestIn; 605 return Bytecode::kTestIn;
615 default: 606 default:
616 UNREACHABLE(); 607 UNREACHABLE();
617 return static_cast<Bytecode>(-1); 608 return static_cast<Bytecode>(-1);
618 } 609 }
619 } 610 }
620 611
621 612
622 // static 613 // static
614 Bytecode BytecodeArrayBuilder::BytecodeForLoadIC(LanguageMode language_mode) {
615 switch (language_mode) {
616 case SLOPPY:
617 return Bytecode::kLoadICSloppy;
618 case STRICT:
619 return Bytecode::kLoadICStrict;
620 case STRONG:
621 UNIMPLEMENTED();
622 default:
623 UNREACHABLE();
624 }
625 return static_cast<Bytecode>(-1);
626 }
627
628
629 // static
630 Bytecode BytecodeArrayBuilder::BytecodeForKeyedLoadIC(
631 LanguageMode language_mode) {
632 switch (language_mode) {
633 case SLOPPY:
634 return Bytecode::kKeyedLoadICSloppy;
635 case STRICT:
636 return Bytecode::kKeyedLoadICStrict;
637 case STRONG:
638 UNIMPLEMENTED();
639 default:
640 UNREACHABLE();
641 }
642 return static_cast<Bytecode>(-1);
643 }
644
645
646 // static
647 Bytecode BytecodeArrayBuilder::BytecodeForStoreIC(LanguageMode language_mode) {
648 switch (language_mode) {
649 case SLOPPY:
650 return Bytecode::kStoreICSloppy;
651 case STRICT:
652 return Bytecode::kStoreICStrict;
653 case STRONG:
654 UNIMPLEMENTED();
655 default:
656 UNREACHABLE();
657 }
658 return static_cast<Bytecode>(-1);
659 }
660
661
662 // static
663 Bytecode BytecodeArrayBuilder::BytecodeForKeyedStoreIC(
664 LanguageMode language_mode) {
665 switch (language_mode) {
666 case SLOPPY:
667 return Bytecode::kKeyedStoreICSloppy;
668 case STRICT:
669 return Bytecode::kKeyedStoreICStrict;
670 case STRONG:
671 UNIMPLEMENTED();
672 default:
673 UNREACHABLE();
674 }
675 return static_cast<Bytecode>(-1);
676 }
677
678
679 // static
623 bool BytecodeArrayBuilder::FitsInIdx8Operand(int value) { 680 bool BytecodeArrayBuilder::FitsInIdx8Operand(int value) {
624 return kMinUInt8 <= value && value <= kMaxUInt8; 681 return kMinUInt8 <= value && value <= kMaxUInt8;
625 } 682 }
626 683
627 684
628 // static 685 // static
629 bool BytecodeArrayBuilder::FitsInIdx8Operand(size_t value) { 686 bool BytecodeArrayBuilder::FitsInIdx8Operand(size_t value) {
630 return value <= static_cast<size_t>(kMaxUInt8); 687 return value <= static_cast<size_t>(kMaxUInt8);
631 } 688 }
632 689
(...skipping 23 matching lines...) Expand all
656 713
657 Register TemporaryRegisterScope::NewRegister() { 714 Register TemporaryRegisterScope::NewRegister() {
658 count_++; 715 count_++;
659 last_register_index_ = builder_->BorrowTemporaryRegister(); 716 last_register_index_ = builder_->BorrowTemporaryRegister();
660 return Register(last_register_index_); 717 return Register(last_register_index_);
661 } 718 }
662 719
663 } // namespace interpreter 720 } // namespace interpreter
664 } // namespace internal 721 } // namespace internal
665 } // namespace v8 722 } // 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