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

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

Issue 2331033002: [interpreter] Merge {OsrPoll} with {Jump} bytecode. (Closed)
Patch Set: Fix for wide jumps. 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 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool 1840 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool
1841 // if the object referenced by the accumulator is the hole constant. 1841 // if the object referenced by the accumulator is the hole constant.
1842 void Interpreter::DoJumpIfNotHoleConstant(InterpreterAssembler* assembler) { 1842 void Interpreter::DoJumpIfNotHoleConstant(InterpreterAssembler* assembler) {
1843 Node* accumulator = __ GetAccumulator(); 1843 Node* accumulator = __ GetAccumulator();
1844 Node* the_hole_value = __ HeapConstant(isolate_->factory()->the_hole_value()); 1844 Node* the_hole_value = __ HeapConstant(isolate_->factory()->the_hole_value());
1845 Node* index = __ BytecodeOperandIdx(0); 1845 Node* index = __ BytecodeOperandIdx(0);
1846 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); 1846 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index);
1847 __ JumpIfWordNotEqual(accumulator, the_hole_value, relative_jump); 1847 __ JumpIfWordNotEqual(accumulator, the_hole_value, relative_jump);
1848 } 1848 }
1849 1849
1850 // JumpLoop <imm> <loop_depth>
1851 //
1852 // Jump by number of bytes represented by the immediate operand |imm|. Also
1853 // performs a loop nesting check and potentially triggers OSR in case the
1854 // current OSR level matches (or exceeds) the specified |loop_depth|.
1855 void Interpreter::DoJumpLoop(InterpreterAssembler* assembler) {
1856 Node* relative_jump = __ BytecodeOperandImm(0);
1857 Node* loop_depth = __ BytecodeOperandImm(1);
1858 Node* osr_level = __ LoadOSRNestingLevel();
1859
1860 // Check if OSR points at the given {loop_depth} are armed by comparing it to
1861 // the current {osr_level} loaded from the header of the BytecodeArray.
1862 Label ok(assembler), osr_armed(assembler, Label::kDeferred);
1863 Node* condition = __ Int32GreaterThanOrEqual(loop_depth, osr_level);
1864 __ Branch(condition, &ok, &osr_armed);
1865
1866 __ Bind(&ok);
1867 __ Jump(relative_jump);
1868
1869 __ Bind(&osr_armed);
1870 {
1871 Callable callable = CodeFactory::InterpreterOnStackReplacement(isolate_);
1872 Node* target = __ HeapConstant(callable.code());
1873 Node* context = __ GetContext();
1874 __ CallStub(callable.descriptor(), target, context);
1875 __ Jump(relative_jump);
1876 }
1877 }
1878
1850 // CreateRegExpLiteral <pattern_idx> <literal_idx> <flags> 1879 // CreateRegExpLiteral <pattern_idx> <literal_idx> <flags>
1851 // 1880 //
1852 // Creates a regular expression literal for literal index <literal_idx> with 1881 // Creates a regular expression literal for literal index <literal_idx> with
1853 // <flags> and the pattern in <pattern_idx>. 1882 // <flags> and the pattern in <pattern_idx>.
1854 void Interpreter::DoCreateRegExpLiteral(InterpreterAssembler* assembler) { 1883 void Interpreter::DoCreateRegExpLiteral(InterpreterAssembler* assembler) {
1855 Node* index = __ BytecodeOperandIdx(0); 1884 Node* index = __ BytecodeOperandIdx(0);
1856 Node* pattern = __ LoadConstantPoolEntry(index); 1885 Node* pattern = __ LoadConstantPoolEntry(index);
1857 Node* literal_index_raw = __ BytecodeOperandIdx(1); 1886 Node* literal_index_raw = __ BytecodeOperandIdx(1);
1858 Node* literal_index = __ SmiTag(literal_index_raw); 1887 Node* literal_index = __ SmiTag(literal_index_raw);
1859 Node* flags_raw = __ BytecodeOperandFlag(2); 1888 Node* flags_raw = __ BytecodeOperandFlag(2);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 __ Dispatch(); 2139 __ Dispatch();
2111 2140
2112 __ Bind(&stack_check_interrupt); 2141 __ Bind(&stack_check_interrupt);
2113 { 2142 {
2114 Node* context = __ GetContext(); 2143 Node* context = __ GetContext();
2115 __ CallRuntime(Runtime::kStackGuard, context); 2144 __ CallRuntime(Runtime::kStackGuard, context);
2116 __ Dispatch(); 2145 __ Dispatch();
2117 } 2146 }
2118 } 2147 }
2119 2148
2120 // OsrPoll <loop_depth>
2121 //
2122 // Performs a loop nesting check and potentially triggers OSR.
2123 void Interpreter::DoOsrPoll(InterpreterAssembler* assembler) {
2124 Node* loop_depth = __ BytecodeOperandImm(0);
2125 Node* osr_level = __ LoadOSRNestingLevel();
2126
2127 // Check if OSR points at the given {loop_depth} are armed by comparing it to
2128 // the current {osr_level} loaded from the header of the BytecodeArray.
2129 Label ok(assembler), osr_armed(assembler, Label::kDeferred);
2130 Node* condition = __ Int32GreaterThanOrEqual(loop_depth, osr_level);
2131 __ Branch(condition, &ok, &osr_armed);
2132
2133 __ Bind(&ok);
2134 __ Dispatch();
2135
2136 __ Bind(&osr_armed);
2137 {
2138 Callable callable = CodeFactory::InterpreterOnStackReplacement(isolate_);
2139 Node* target = __ HeapConstant(callable.code());
2140 Node* context = __ GetContext();
2141 __ CallStub(callable.descriptor(), target, context);
2142 __ Dispatch();
2143 }
2144 }
2145
2146 // Throw 2149 // Throw
2147 // 2150 //
2148 // Throws the exception in the accumulator. 2151 // Throws the exception in the accumulator.
2149 void Interpreter::DoThrow(InterpreterAssembler* assembler) { 2152 void Interpreter::DoThrow(InterpreterAssembler* assembler) {
2150 Node* exception = __ GetAccumulator(); 2153 Node* exception = __ GetAccumulator();
2151 Node* context = __ GetContext(); 2154 Node* context = __ GetContext();
2152 __ CallRuntime(Runtime::kThrow, context, exception); 2155 __ CallRuntime(Runtime::kThrow, context, exception);
2153 // We shouldn't ever return from a throw. 2156 // We shouldn't ever return from a throw.
2154 __ Abort(kUnexpectedReturnFromThrow); 2157 __ Abort(kUnexpectedReturnFromThrow);
2155 } 2158 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2456 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 2459 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
2457 __ SmiTag(new_state)); 2460 __ SmiTag(new_state));
2458 __ SetAccumulator(old_state); 2461 __ SetAccumulator(old_state);
2459 2462
2460 __ Dispatch(); 2463 __ Dispatch();
2461 } 2464 }
2462 2465
2463 } // namespace interpreter 2466 } // namespace interpreter
2464 } // namespace internal 2467 } // namespace internal
2465 } // namespace v8 2468 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698