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

Side by Side Diff: src/interpreter/interpreter.cc

Issue 1531693002: [Interpreter] Implement ForIn in bytecode graph builder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@oth-0009-phi
Patch Set: Fix ForInPrepare. Created 5 years 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/interpreter.h" 5 #include "src/interpreter/interpreter.h"
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/compiler/interpreter-assembler.h" 9 #include "src/compiler/interpreter-assembler.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 1443
1444 1444
1445 // Return 1445 // Return
1446 // 1446 //
1447 // Return the value in the accumulator. 1447 // Return the value in the accumulator.
1448 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { 1448 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) {
1449 __ Return(); 1449 __ Return();
1450 } 1450 }
1451 1451
1452 1452
1453 // ForInPrepare <receiver> 1453 // ForInPrepare <receiver> <cache_type> <cache_array> <cache_length>
1454 // 1454 //
1455 // Returns state for for..in loop execution based on the |receiver| and 1455 // Returns state for for..in loop execution based on the |receiver| and
1456 // the property names in the accumulator. 1456 // the property names in the accumulator. The cache information is output
1457 // to the registers cache_array, cache_type, and cache_length.
1457 void Interpreter::DoForInPrepare(compiler::InterpreterAssembler* assembler) { 1458 void Interpreter::DoForInPrepare(compiler::InterpreterAssembler* assembler) {
1459 // Call runtime to set-up ForInPrepareState
1458 Node* receiver_reg = __ BytecodeOperandReg(0); 1460 Node* receiver_reg = __ BytecodeOperandReg(0);
1459 Node* receiver = __ LoadRegister(receiver_reg); 1461 Node* receiver = __ LoadRegister(receiver_reg);
1460 Node* property_names = __ GetAccumulator(); 1462 Node* property_names = __ GetAccumulator();
1461 Node* result = __ CallRuntime(Runtime::kInterpreterForInPrepare, receiver, 1463 Node* result = __ CallRuntime(Runtime::kInterpreterForInPrepare, receiver,
Benedikt Meurer 2015/12/16 20:00:14 Quick question: Long-term you plan to implement al
1462 property_names); 1464 property_names);
1465 for (int i = 0; i < 3; i++) {
1466 // 0 == cache_type, 1 == cache_array, 2 == cache_length
1467 Node* cache_info = __ LoadFixedArrayElement(result, i);
1468 Node* cache_info_reg = __ BytecodeOperandReg(i + 1);
1469 __ StoreRegister(cache_info, cache_info_reg);
1470 }
1463 __ SetAccumulator(result); 1471 __ SetAccumulator(result);
1464 __ Dispatch(); 1472 __ Dispatch();
1465 } 1473 }
1466 1474
1467 1475
1468 // ForInNext <for_in_state> <index> 1476 // ForInNext <receiver> <cache_type> <cache_array> <index>
1469 // 1477 //
1470 // Returns the next key in a for..in loop. The state associated with the 1478 // Returns the next key in a for..in loop.
1471 // iteration is contained in |for_in_state| and |index| is the current
1472 // zero-based iteration count.
1473 void Interpreter::DoForInNext(compiler::InterpreterAssembler* assembler) { 1479 void Interpreter::DoForInNext(compiler::InterpreterAssembler* assembler) {
1474 Node* for_in_state_reg = __ BytecodeOperandReg(0); 1480 Node* receiver_reg = __ BytecodeOperandReg(0);
1475 Node* for_in_state = __ LoadRegister(for_in_state_reg); 1481 Node* receiver = __ LoadRegister(receiver_reg);
1476 Node* receiver = __ LoadFixedArrayElement(for_in_state, 0); 1482 Node* cache_type_reg = __ BytecodeOperandReg(1);
1477 Node* cache_array = __ LoadFixedArrayElement(for_in_state, 1); 1483 Node* cache_type = __ LoadRegister(cache_type_reg);
1478 Node* cache_type = __ LoadFixedArrayElement(for_in_state, 2); 1484 Node* cache_array_reg = __ BytecodeOperandReg(2);
1479 Node* index_reg = __ BytecodeOperandReg(1); 1485 Node* cache_array = __ LoadRegister(cache_array_reg);
1486 Node* index_reg = __ BytecodeOperandReg(3);
1480 Node* index = __ LoadRegister(index_reg); 1487 Node* index = __ LoadRegister(index_reg);
1481 Node* result = __ CallRuntime(Runtime::kForInNext, receiver, cache_array, 1488 Node* result = __ CallRuntime(Runtime::kForInNext, receiver, cache_array,
1482 cache_type, index); 1489 cache_type, index);
1483 __ SetAccumulator(result); 1490 __ SetAccumulator(result);
1484 __ Dispatch(); 1491 __ Dispatch();
1485 } 1492 }
1486 1493
1487 1494
1488 // ForInDone <for_in_state> 1495 // ForInDone <index> <cache_length>
1489 // 1496 //
1490 // Returns the next key in a for..in loop. The accumulator contains the current 1497 // Returns the next key in a for..in loop.
1491 // zero-based iteration count and |for_in_state| is the state returned by an
1492 // earlier invocation of ForInPrepare.
1493 void Interpreter::DoForInDone(compiler::InterpreterAssembler* assembler) { 1498 void Interpreter::DoForInDone(compiler::InterpreterAssembler* assembler) {
1494 Node* index = __ GetAccumulator(); 1499 Node* index_reg = __ BytecodeOperandReg(0);
1495 Node* for_in_state_reg = __ BytecodeOperandReg(0); 1500 Node* index = __ LoadRegister(index_reg);
1496 Node* for_in_state = __ LoadRegister(for_in_state_reg); 1501 Node* cache_length_reg = __ BytecodeOperandReg(1);
1497 Node* cache_length = __ LoadFixedArrayElement(for_in_state, 3); 1502 Node* cache_length = __ LoadRegister(cache_length_reg);
1498 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length); 1503 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length);
1499 __ SetAccumulator(result); 1504 __ SetAccumulator(result);
1500 __ Dispatch(); 1505 __ Dispatch();
1501 } 1506 }
1502 1507
1503 1508
1509 // ForInStep <index>
1510 //
1511 // Increments the loop counter |index|.
1512 void Interpreter::DoForInStep(compiler::InterpreterAssembler* assembler) {
1513 Node* index_reg = __ BytecodeOperandReg(0);
1514 Node* index = __ LoadRegister(index_reg);
1515 Node* result = __ CallRuntime(Runtime::kForInStep, index);
1516 __ StoreRegister(result, index_reg);
1517 __ Dispatch();
1518 }
1519
1520
1504 } // namespace interpreter 1521 } // namespace interpreter
1505 } // namespace internal 1522 } // namespace internal
1506 } // namespace v8 1523 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698