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

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

Issue 1419003002: [Interpreter] Unify global and unallocated variable access. (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 unified diff | Download patch
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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 257 }
258 258
259 259
260 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister( 260 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister(
261 Register reg) { 261 Register reg) {
262 Output(Bytecode::kStar, reg.ToOperand()); 262 Output(Bytecode::kStar, reg.ToOperand());
263 return *this; 263 return *this;
264 } 264 }
265 265
266 266
267 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal(int slot_index) { 267 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal(
268 DCHECK(slot_index >= 0); 268 size_t name_index, int feedback_slot, LanguageMode language_mode) {
269 if (FitsInIdx8Operand(slot_index)) { 269 Bytecode bytecode = BytecodeForLoadGlobal(language_mode);
270 Output(Bytecode::kLdaGlobal, static_cast<uint8_t>(slot_index)); 270 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) {
271 Output(bytecode, static_cast<uint8_t>(name_index),
272 static_cast<uint8_t>(feedback_slot));
271 } else { 273 } else {
272 UNIMPLEMENTED(); 274 UNIMPLEMENTED();
273 } 275 }
274 return *this; 276 return *this;
275 } 277 }
276 278
277 279
278 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreGlobal( 280 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreGlobal(
279 int slot_index, LanguageMode language_mode) { 281 size_t name_index, int feedback_slot, LanguageMode language_mode) {
280 DCHECK(slot_index >= 0);
281 Bytecode bytecode = BytecodeForStoreGlobal(language_mode); 282 Bytecode bytecode = BytecodeForStoreGlobal(language_mode);
282 if (FitsInIdx8Operand(slot_index)) { 283 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) {
283 Output(bytecode, static_cast<uint8_t>(slot_index)); 284 Output(bytecode, static_cast<uint8_t>(name_index),
285 static_cast<uint8_t>(feedback_slot));
284 } else { 286 } else {
285 UNIMPLEMENTED(); 287 UNIMPLEMENTED();
286 } 288 }
287 return *this; 289 return *this;
288 } 290 }
289 291
290 292
291 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadContextSlot(Register context, 293 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadContextSlot(Register context,
292 int slot_index) { 294 int slot_index) {
293 DCHECK(slot_index >= 0); 295 DCHECK(slot_index >= 0);
(...skipping 14 matching lines...) Expand all
308 Output(Bytecode::kStaContextSlot, context.ToOperand(), 310 Output(Bytecode::kStaContextSlot, context.ToOperand(),
309 static_cast<uint8_t>(slot_index)); 311 static_cast<uint8_t>(slot_index));
310 } else { 312 } else {
311 UNIMPLEMENTED(); 313 UNIMPLEMENTED();
312 } 314 }
313 return *this; 315 return *this;
314 } 316 }
315 317
316 318
317 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( 319 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty(
318 Register object, int feedback_slot, LanguageMode language_mode) { 320 Register object, size_t name_index, int feedback_slot,
321 LanguageMode language_mode) {
319 Bytecode bytecode = BytecodeForLoadIC(language_mode); 322 Bytecode bytecode = BytecodeForLoadIC(language_mode);
320 if (FitsInIdx8Operand(feedback_slot)) { 323 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) {
321 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(feedback_slot)); 324 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(name_index),
325 static_cast<uint8_t>(feedback_slot));
322 } else { 326 } else {
323 UNIMPLEMENTED(); 327 UNIMPLEMENTED();
324 } 328 }
325 return *this; 329 return *this;
326 } 330 }
327 331
328 332
329 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty( 333 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty(
330 Register object, int feedback_slot, LanguageMode language_mode) { 334 Register object, int feedback_slot, LanguageMode language_mode) {
331 Bytecode bytecode = BytecodeForKeyedLoadIC(language_mode); 335 Bytecode bytecode = BytecodeForKeyedLoadIC(language_mode);
332 if (FitsInIdx8Operand(feedback_slot)) { 336 if (FitsInIdx8Operand(feedback_slot)) {
333 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(feedback_slot)); 337 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(feedback_slot));
334 } else { 338 } else {
335 UNIMPLEMENTED(); 339 UNIMPLEMENTED();
336 } 340 }
337 return *this; 341 return *this;
338 } 342 }
339 343
340 344
341 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty( 345 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty(
342 Register object, Register name, int feedback_slot, 346 Register object, size_t name_index, int feedback_slot,
343 LanguageMode language_mode) { 347 LanguageMode language_mode) {
344 Bytecode bytecode = BytecodeForStoreIC(language_mode); 348 Bytecode bytecode = BytecodeForStoreIC(language_mode);
345 if (FitsInIdx8Operand(feedback_slot)) { 349 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) {
346 Output(bytecode, object.ToOperand(), name.ToOperand(), 350 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(name_index),
347 static_cast<uint8_t>(feedback_slot)); 351 static_cast<uint8_t>(feedback_slot));
348 } else { 352 } else {
349 UNIMPLEMENTED(); 353 UNIMPLEMENTED();
350 } 354 }
351 return *this; 355 return *this;
352 } 356 }
353 357
354 358
355 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreKeyedProperty( 359 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreKeyedProperty(
356 Register object, Register key, int feedback_slot, 360 Register object, Register key, int feedback_slot,
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 case STRONG: 916 case STRONG:
913 UNIMPLEMENTED(); 917 UNIMPLEMENTED();
914 default: 918 default:
915 UNREACHABLE(); 919 UNREACHABLE();
916 } 920 }
917 return static_cast<Bytecode>(-1); 921 return static_cast<Bytecode>(-1);
918 } 922 }
919 923
920 924
921 // static 925 // static
926 Bytecode BytecodeArrayBuilder::BytecodeForLoadGlobal(
Igor Sheludko 2015/10/22 09:58:36 It would be necessary to also propagate a TypeofMo
rmcilroy 2015/10/22 10:13:20 What does TypeofMode get used for, I can't see it
rmcilroy 2015/10/22 13:27:48 Added a TODO in BytecodeGenerator VisitTypeOf for
Igor Sheludko 2015/11/03 17:52:56 See LoadIC::ShoudlThrowReferenceError(). Referenci
rmcilroy 2015/11/03 18:26:12 Yeah, I figured this out and landed the fix in htt
927 LanguageMode language_mode) {
928 switch (language_mode) {
929 case SLOPPY:
930 return Bytecode::kLdaGlobalSloppy;
931 case STRICT:
932 return Bytecode::kLdaGlobalStrict;
933 case STRONG:
934 UNIMPLEMENTED();
935 default:
936 UNREACHABLE();
937 }
938 return static_cast<Bytecode>(-1);
939 }
940
941
942 // static
922 Bytecode BytecodeArrayBuilder::BytecodeForStoreGlobal( 943 Bytecode BytecodeArrayBuilder::BytecodeForStoreGlobal(
923 LanguageMode language_mode) { 944 LanguageMode language_mode) {
924 switch (language_mode) { 945 switch (language_mode) {
925 case SLOPPY: 946 case SLOPPY:
926 return Bytecode::kStaGlobalSloppy; 947 return Bytecode::kStaGlobalSloppy;
927 case STRICT: 948 case STRICT:
928 return Bytecode::kStaGlobalStrict; 949 return Bytecode::kStaGlobalStrict;
929 case STRONG: 950 case STRONG:
930 UNIMPLEMENTED(); 951 UNIMPLEMENTED();
931 default: 952 default:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 DCHECK_GT(next_consecutive_count_, 0); 1016 DCHECK_GT(next_consecutive_count_, 0);
996 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); 1017 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_);
997 allocated_.push_back(next_consecutive_register_); 1018 allocated_.push_back(next_consecutive_register_);
998 next_consecutive_count_--; 1019 next_consecutive_count_--;
999 return Register(next_consecutive_register_++); 1020 return Register(next_consecutive_register_++);
1000 } 1021 }
1001 1022
1002 } // namespace interpreter 1023 } // namespace interpreter
1003 } // namespace internal 1024 } // namespace internal
1004 } // namespace v8 1025 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698