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

Side by Side Diff: src/compiler/bytecode-graph-builder.cc

Issue 2894293003: Save/restore only live registers in the generator suspend/resume. (Closed)
Patch Set: Tweak Created 3 years, 6 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
« no previous file with comments | « src/compiler/bytecode-analysis.cc ('k') | src/compiler/js-operator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/compiler/bytecode-graph-builder.h" 5 #include "src/compiler/bytecode-graph-builder.h"
6 6
7 #include "src/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/compiler/access-builder.h" 9 #include "src/compiler/access-builder.h"
10 #include "src/compiler/compiler-source-position-table.h" 10 #include "src/compiler/compiler-source-position-table.h"
(...skipping 2259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 index = NewNode( 2270 index = NewNode(
2271 simplified()->SpeculativeNumberAdd(NumberOperationHint::kSignedSmall), 2271 simplified()->SpeculativeNumberAdd(NumberOperationHint::kSignedSmall),
2272 index, jsgraph()->OneConstant()); 2272 index, jsgraph()->OneConstant());
2273 environment()->BindAccumulator(index, Environment::kAttachFrameState); 2273 environment()->BindAccumulator(index, Environment::kAttachFrameState);
2274 } 2274 }
2275 2275
2276 void BytecodeGraphBuilder::VisitSuspendGenerator() { 2276 void BytecodeGraphBuilder::VisitSuspendGenerator() {
2277 Node* state = environment()->LookupAccumulator(); 2277 Node* state = environment()->LookupAccumulator();
2278 Node* generator = environment()->LookupRegister( 2278 Node* generator = environment()->LookupRegister(
2279 bytecode_iterator().GetRegisterOperand(0)); 2279 bytecode_iterator().GetRegisterOperand(0));
2280 interpreter::Register first_reg = bytecode_iterator().GetRegisterOperand(1);
2281 // We assume we are storing a range starting from index 0.
2282 CHECK_EQ(0, first_reg.index());
2283 int register_count =
2284 static_cast<int>(bytecode_iterator().GetRegisterCountOperand(2));
2280 SuspendFlags flags = interpreter::SuspendGeneratorBytecodeFlags::Decode( 2285 SuspendFlags flags = interpreter::SuspendGeneratorBytecodeFlags::Decode(
2281 bytecode_iterator().GetFlagOperand(1)); 2286 bytecode_iterator().GetFlagOperand(3));
2287
2282 // The offsets used by the bytecode iterator are relative to a different base 2288 // The offsets used by the bytecode iterator are relative to a different base
2283 // than what is used in the interpreter, hence the addition. 2289 // than what is used in the interpreter, hence the addition.
2284 Node* offset = 2290 Node* offset =
2285 jsgraph()->Constant(bytecode_iterator().current_offset() + 2291 jsgraph()->Constant(bytecode_iterator().current_offset() +
2286 (BytecodeArray::kHeaderSize - kHeapObjectTag)); 2292 (BytecodeArray::kHeaderSize - kHeapObjectTag));
2287 2293
2288 int register_count = environment()->register_count();
2289 int value_input_count = 3 + register_count; 2294 int value_input_count = 3 + register_count;
2290 2295
2291 Node** value_inputs = local_zone()->NewArray<Node*>(value_input_count); 2296 Node** value_inputs = local_zone()->NewArray<Node*>(value_input_count);
2292 value_inputs[0] = generator; 2297 value_inputs[0] = generator;
2293 value_inputs[1] = state; 2298 value_inputs[1] = state;
2294 value_inputs[2] = offset; 2299 value_inputs[2] = offset;
2295 for (int i = 0; i < register_count; ++i) { 2300 for (int i = 0; i < register_count; ++i) {
2296 value_inputs[3 + i] = 2301 value_inputs[3 + i] =
2297 environment()->LookupRegister(interpreter::Register(i)); 2302 environment()->LookupRegister(interpreter::Register(i));
2298 } 2303 }
2299 2304
2300 MakeNode(javascript()->GeneratorStore(register_count, flags), 2305 MakeNode(javascript()->GeneratorStore(register_count, flags),
2301 value_input_count, value_inputs, false); 2306 value_input_count, value_inputs, false);
2302 } 2307 }
2303 2308
2304 void BytecodeGraphBuilder::VisitResumeGenerator() { 2309 void BytecodeGraphBuilder::VisitRestoreGeneratorState() {
2305 Node* generator = environment()->LookupRegister( 2310 Node* generator = environment()->LookupRegister(
2306 bytecode_iterator().GetRegisterOperand(0)); 2311 bytecode_iterator().GetRegisterOperand(0));
2307 2312
2308 // Bijection between registers and array indices must match that used in
2309 // InterpreterAssembler::ExportRegisterFile.
2310 for (int i = 0; i < environment()->register_count(); ++i) {
2311 Node* value = NewNode(javascript()->GeneratorRestoreRegister(i), generator);
2312 environment()->BindRegister(interpreter::Register(i), value);
2313 }
2314
2315 Node* state = 2313 Node* state =
2316 NewNode(javascript()->GeneratorRestoreContinuation(), generator); 2314 NewNode(javascript()->GeneratorRestoreContinuation(), generator);
2317 2315
2318 environment()->BindAccumulator(state); 2316 environment()->BindAccumulator(state, Environment::kAttachFrameState);
2317 }
2318
2319 void BytecodeGraphBuilder::VisitRestoreGeneratorRegisters() {
2320 Node* generator =
2321 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
2322 interpreter::Register first_reg = bytecode_iterator().GetRegisterOperand(1);
2323 // We assume we are restoring registers starting fromm index 0.
2324 CHECK_EQ(0, first_reg.index());
2325 int register_count =
2326 static_cast<int>(bytecode_iterator().GetRegisterCountOperand(2));
2327
2328 // Bijection between registers and array indices must match that used in
2329 // InterpreterAssembler::ExportRegisterFile.
2330 for (int i = 0; i < register_count; ++i) {
2331 Node* value = NewNode(javascript()->GeneratorRestoreRegister(i), generator);
2332 environment()->BindRegister(interpreter::Register(i), value);
2333 }
2319 } 2334 }
2320 2335
2321 void BytecodeGraphBuilder::VisitWide() { 2336 void BytecodeGraphBuilder::VisitWide() {
2322 // Consumed by the BytecodeArrayIterator. 2337 // Consumed by the BytecodeArrayIterator.
2323 UNREACHABLE(); 2338 UNREACHABLE();
2324 } 2339 }
2325 2340
2326 void BytecodeGraphBuilder::VisitExtraWide() { 2341 void BytecodeGraphBuilder::VisitExtraWide() {
2327 // Consumed by the BytecodeArrayIterator. 2342 // Consumed by the BytecodeArrayIterator.
2328 UNREACHABLE(); 2343 UNREACHABLE();
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 it->source_position().ScriptOffset(), start_position_.InliningId())); 2846 it->source_position().ScriptOffset(), start_position_.InliningId()));
2832 it->Advance(); 2847 it->Advance();
2833 } else { 2848 } else {
2834 DCHECK_GT(it->code_offset(), offset); 2849 DCHECK_GT(it->code_offset(), offset);
2835 } 2850 }
2836 } 2851 }
2837 2852
2838 } // namespace compiler 2853 } // namespace compiler
2839 } // namespace internal 2854 } // namespace internal
2840 } // namespace v8 2855 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-analysis.cc ('k') | src/compiler/js-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698