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

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

Issue 2336643002: [Interpreter] Move context chain search loop to handler (Closed)
Patch Set: Created 4 years, 3 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/interpreter.h" 5 #include "src/interpreter/interpreter.h"
6 6
7 #include <fstream> 7 #include <fstream>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 508
509 // StaGlobalStrict <name_index> <slot> 509 // StaGlobalStrict <name_index> <slot>
510 // 510 //
511 // Store the value in the accumulator into the global with name in constant pool 511 // Store the value in the accumulator into the global with name in constant pool
512 // entry <name_index> using FeedBackVector slot <slot> in strict mode. 512 // entry <name_index> using FeedBackVector slot <slot> in strict mode.
513 void Interpreter::DoStaGlobalStrict(InterpreterAssembler* assembler) { 513 void Interpreter::DoStaGlobalStrict(InterpreterAssembler* assembler) {
514 Callable ic = CodeFactory::StoreICInOptimizedCode(isolate_, STRICT); 514 Callable ic = CodeFactory::StoreICInOptimizedCode(isolate_, STRICT);
515 DoStaGlobal(ic, assembler); 515 DoStaGlobal(ic, assembler);
516 } 516 }
517 517
518 compiler::Node* Interpreter::GetContextAtDepth(InterpreterAssembler* assembler,
519 Node* root_context,
520 Node* depth) {
521 Variable context(assembler, MachineRepresentation::kTaggedPointer);
522 context.Bind(root_context);
523
524 Label context_found(assembler);
525
526 // Fast path if the depth is 0
rmcilroy 2016/09/12 17:07:15 Nit - full stop on comments.
Leszek Swirski 2016/09/13 09:42:34 Done.
527 __ GotoIf(__ WordEqual(depth, __ Int32Constant(0)), &context_found);
528
529 // Loop until the depth is 0
530 Variable cur_depth(assembler, MachineRepresentation::kWord32);
531
532 Variable* context_search_loop_variables[2] = {&cur_depth, &context};
533 Label context_search(assembler, 2, context_search_loop_variables);
534
535 cur_depth.Bind(depth);
536 __ Goto(&context_search);
537 __ Bind(&context_search);
538 {
539 cur_depth.Bind(__ Int32Sub(cur_depth.value(), __ Int32Constant(1)));
540 context.Bind(__ LoadContextSlot(context.value(), Context::PREVIOUS_INDEX));
rmcilroy 2016/09/12 17:07:15 Nit - swapping these around might give slightly be
Leszek Swirski 2016/09/13 09:42:34 Sadly there's no improvement in the codegen, but a
541
542 __ Branch(__ WordEqual(cur_depth.value(), __ Int32Constant(0)),
rmcilroy 2016/09/12 17:07:15 You can do BranchIfWordEqual(...)
Leszek Swirski 2016/09/13 09:42:34 Done.
543 &context_found, &context_search);
544 }
545
546 __ Bind(&context_found);
547 return context.value();
548 }
549
518 compiler::Node* Interpreter::BuildLoadContextSlot( 550 compiler::Node* Interpreter::BuildLoadContextSlot(
519 InterpreterAssembler* assembler) { 551 InterpreterAssembler* assembler) {
520 Node* reg_index = __ BytecodeOperandReg(0); 552 Node* reg_index = __ BytecodeOperandReg(0);
521 Node* context = __ LoadRegister(reg_index); 553 Node* root_context = __ LoadRegister(reg_index);
522 Node* slot_index = __ BytecodeOperandIdx(1); 554 Node* slot_index = __ BytecodeOperandIdx(1);
523 return __ LoadContextSlot(context, slot_index); 555 Node* depth = __ BytecodeOperandIdx(2);
556
557 return __ LoadContextSlot(GetContextAtDepth(assembler, root_context, depth),
rmcilroy 2016/09/12 17:07:15 Nit - do the GetContextAtDepth on a different line
Leszek Swirski 2016/09/13 09:42:34 Done.
558 slot_index);
524 } 559 }
525 560
526 // LdaContextSlot <context> <slot_index> 561 // LdaContextSlot <context> <slot_index>
rmcilroy 2016/09/12 17:07:15 Please update these comments (with <depth> and /s/
Leszek Swirski 2016/09/13 09:42:34 Done.
527 // 562 //
528 // Load the object in |slot_index| of |context| into the accumulator. 563 // Load the object in |slot_index| of |context| into the accumulator.
529 void Interpreter::DoLdaContextSlot(InterpreterAssembler* assembler) { 564 void Interpreter::DoLdaContextSlot(InterpreterAssembler* assembler) {
530 Node* result = BuildLoadContextSlot(assembler); 565 Node* result = BuildLoadContextSlot(assembler);
531 __ SetAccumulator(result); 566 __ SetAccumulator(result);
532 __ Dispatch(); 567 __ Dispatch();
533 } 568 }
534 569
535 // LdrContextSlot <context> <slot_index> <reg> 570 // LdrContextSlot <context> <slot_index> <reg>
536 // 571 //
537 // Load the object in <slot_index> of <context> into register <reg>. 572 // Load the object in <slot_index> of <context> into register <reg>.
538 void Interpreter::DoLdrContextSlot(InterpreterAssembler* assembler) { 573 void Interpreter::DoLdrContextSlot(InterpreterAssembler* assembler) {
539 Node* result = BuildLoadContextSlot(assembler); 574 Node* result = BuildLoadContextSlot(assembler);
540 Node* destination = __ BytecodeOperandReg(2); 575 Node* destination = __ BytecodeOperandReg(3);
541 __ StoreRegister(result, destination); 576 __ StoreRegister(result, destination);
542 __ Dispatch(); 577 __ Dispatch();
543 } 578 }
544 579
545 // StaContextSlot <context> <slot_index> 580 // StaContextSlot <context> <slot_index>
546 // 581 //
547 // Stores the object in the accumulator into |slot_index| of |context|. 582 // Stores the object in the accumulator into |slot_index| of |context|.
548 void Interpreter::DoStaContextSlot(InterpreterAssembler* assembler) { 583 void Interpreter::DoStaContextSlot(InterpreterAssembler* assembler) {
549 Node* value = __ GetAccumulator(); 584 Node* value = __ GetAccumulator();
550 Node* reg_index = __ BytecodeOperandReg(0); 585 Node* reg_index = __ BytecodeOperandReg(0);
551 Node* context = __ LoadRegister(reg_index); 586 Node* root_context = __ LoadRegister(reg_index);
552 Node* slot_index = __ BytecodeOperandIdx(1); 587 Node* slot_index = __ BytecodeOperandIdx(1);
553 __ StoreContextSlot(context, slot_index, value); 588 Node* depth = __ BytecodeOperandIdx(2);
589
590 __ StoreContextSlot(GetContextAtDepth(assembler, root_context, depth),
rmcilroy 2016/09/12 17:07:15 Ditto
Leszek Swirski 2016/09/13 09:42:34 Done.
591 slot_index, value);
554 __ Dispatch(); 592 __ Dispatch();
555 } 593 }
556 594
557 void Interpreter::DoLdaLookupSlot(Runtime::FunctionId function_id, 595 void Interpreter::DoLdaLookupSlot(Runtime::FunctionId function_id,
558 InterpreterAssembler* assembler) { 596 InterpreterAssembler* assembler) {
559 Node* index = __ BytecodeOperandIdx(0); 597 Node* index = __ BytecodeOperandIdx(0);
560 Node* name = __ LoadConstantPoolEntry(index); 598 Node* name = __ LoadConstantPoolEntry(index);
561 Node* context = __ GetContext(); 599 Node* context = __ GetContext();
562 Node* result = __ CallRuntime(function_id, context, name); 600 Node* result = __ CallRuntime(function_id, context, name);
563 __ SetAccumulator(result); 601 __ SetAccumulator(result);
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after
2456 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 2494 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
2457 __ SmiTag(new_state)); 2495 __ SmiTag(new_state));
2458 __ SetAccumulator(old_state); 2496 __ SetAccumulator(old_state);
2459 2497
2460 __ Dispatch(); 2498 __ Dispatch();
2461 } 2499 }
2462 2500
2463 } // namespace interpreter 2501 } // namespace interpreter
2464 } // namespace internal 2502 } // namespace internal
2465 } // namespace v8 2503 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698