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

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: 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 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 Node* receiver_reg = __ BytecodeOperandReg(0); 1458 Node* receiver_reg = __ BytecodeOperandReg(0);
1459 Node* receiver = __ LoadRegister(receiver_reg); 1459 Node* receiver = __ LoadRegister(receiver_reg);
1460 Node* property_names = __ GetAccumulator(); 1460 Node* property_names = __ GetAccumulator();
1461 Node* result = __ CallRuntime(Runtime::kInterpreterForInPrepare, receiver, 1461 Node* result = __ CallRuntime(Runtime::kInterpreterForInPrepare, receiver,
1462 property_names); 1462 property_names);
1463 __ SetAccumulator(result); 1463 __ SetAccumulator(result);
1464 __ Dispatch(); 1464 __ Dispatch();
1465 } 1465 }
1466 1466
1467 1467
1468 // ForInNext <for_in_state> <index> 1468 // ForInNext <receiver> <index> <cache_type> <cache_array>
1469 // 1469 //
1470 // Returns the next key in a for..in loop. The state associated with the 1470 // 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) { 1471 void Interpreter::DoForInNext(compiler::InterpreterAssembler* assembler) {
1474 Node* for_in_state_reg = __ BytecodeOperandReg(0); 1472 Node* receiver_reg = __ BytecodeOperandReg(0);
1475 Node* for_in_state = __ LoadRegister(for_in_state_reg); 1473 Node* receiver = __ LoadRegister(receiver_reg);
1476 Node* receiver = __ LoadFixedArrayElement(for_in_state, 0);
1477 Node* cache_array = __ LoadFixedArrayElement(for_in_state, 1);
1478 Node* cache_type = __ LoadFixedArrayElement(for_in_state, 2);
1479 Node* index_reg = __ BytecodeOperandReg(1); 1474 Node* index_reg = __ BytecodeOperandReg(1);
1480 Node* index = __ LoadRegister(index_reg); 1475 Node* index = __ LoadRegister(index_reg);
1476 Node* cache_type_reg = __ BytecodeOperandReg(2);
1477 Node* cache_type = __ LoadRegister(cache_type_reg);
1478 Node* cache_array_reg = __ BytecodeOperandReg(3);
1479 Node* cache_array = __ LoadRegister(cache_array_reg);
1481 Node* result = __ CallRuntime(Runtime::kForInNext, receiver, cache_array, 1480 Node* result = __ CallRuntime(Runtime::kForInNext, receiver, cache_array,
1482 cache_type, index); 1481 cache_type, index);
1483 __ SetAccumulator(result); 1482 __ SetAccumulator(result);
1484 __ Dispatch(); 1483 __ Dispatch();
1485 } 1484 }
1486 1485
1487 1486
1488 // ForInDone <for_in_state> 1487 // ForInDone <index> <cache_length>
1489 // 1488 //
1490 // Returns the next key in a for..in loop. The accumulator contains the current 1489 // 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) { 1490 void Interpreter::DoForInDone(compiler::InterpreterAssembler* assembler) {
1494 Node* index = __ GetAccumulator(); 1491 Node* index_reg = __ BytecodeOperandReg(0);
1495 Node* for_in_state_reg = __ BytecodeOperandReg(0); 1492 Node* index = __ LoadRegister(index_reg);
1496 Node* for_in_state = __ LoadRegister(for_in_state_reg); 1493 Node* cache_length_reg = __ BytecodeOperandReg(1);
1497 Node* cache_length = __ LoadFixedArrayElement(for_in_state, 3); 1494 Node* cache_length = __ LoadRegister(cache_length_reg);
1498 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length); 1495 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length);
1499 __ SetAccumulator(result); 1496 __ SetAccumulator(result);
1500 __ Dispatch(); 1497 __ Dispatch();
1501 } 1498 }
1502 1499
1503 1500
1501 // ForInStep <index>
1502 //
1503 // Increments the loop counter |index|.
1504 void Interpreter::DoForInStep(compiler::InterpreterAssembler* assembler) {
1505 Node* index_reg = __ BytecodeOperandReg(0);
1506 Node* index = __ LoadRegister(index_reg);
1507 Node* result = __ CallRuntime(Runtime::kForInStep, index);
1508 __ StoreRegister(result, index_reg);
1509 __ Dispatch();
1510 }
1511
1512
1504 } // namespace interpreter 1513 } // namespace interpreter
1505 } // namespace internal 1514 } // namespace internal
1506 } // namespace v8 1515 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698