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

Side by Side Diff: src/interpreter/bytecode-array-builder.cc

Issue 2242193002: [Interpreter] Avoid accessing Isolate from during bytecode generation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_sourceposition
Patch Set: Rebase Created 4 years, 4 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/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-array-writer.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/interpreter/bytecode-array-builder.h" 5 #include "src/interpreter/bytecode-array-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/globals.h" 8 #include "src/globals.h"
9 #include "src/interpreter/bytecode-array-writer.h" 9 #include "src/interpreter/bytecode-array-writer.h"
10 #include "src/interpreter/bytecode-dead-code-optimizer.h" 10 #include "src/interpreter/bytecode-dead-code-optimizer.h"
11 #include "src/interpreter/bytecode-label.h" 11 #include "src/interpreter/bytecode-label.h"
12 #include "src/interpreter/bytecode-peephole-optimizer.h" 12 #include "src/interpreter/bytecode-peephole-optimizer.h"
13 #include "src/interpreter/bytecode-register-optimizer.h" 13 #include "src/interpreter/bytecode-register-optimizer.h"
14 #include "src/interpreter/interpreter-intrinsics.h" 14 #include "src/interpreter/interpreter-intrinsics.h"
15 15
16 namespace v8 { 16 namespace v8 {
17 namespace internal { 17 namespace internal {
18 namespace interpreter { 18 namespace interpreter {
19 19
20 BytecodeArrayBuilder::BytecodeArrayBuilder( 20 BytecodeArrayBuilder::BytecodeArrayBuilder(
21 Isolate* isolate, Zone* zone, int parameter_count, int context_count, 21 Isolate* isolate, Zone* zone, int parameter_count, int context_count,
22 int locals_count, FunctionLiteral* literal, 22 int locals_count, FunctionLiteral* literal,
23 SourcePositionTableBuilder::RecordingMode source_position_mode) 23 SourcePositionTableBuilder::RecordingMode source_position_mode)
24 : isolate_(isolate), 24 : zone_(zone),
25 zone_(zone),
26 bytecode_generated_(false), 25 bytecode_generated_(false),
27 constant_array_builder_(isolate, zone), 26 constant_array_builder_(zone, isolate->factory()->the_hole_value()),
28 handler_table_builder_(isolate, zone), 27 handler_table_builder_(zone),
29 return_seen_in_block_(false), 28 return_seen_in_block_(false),
30 parameter_count_(parameter_count), 29 parameter_count_(parameter_count),
31 local_register_count_(locals_count), 30 local_register_count_(locals_count),
32 context_register_count_(context_count), 31 context_register_count_(context_count),
33 temporary_allocator_(zone, fixed_register_count()), 32 temporary_allocator_(zone, fixed_register_count()),
34 bytecode_array_writer_(isolate, zone, &constant_array_builder_, 33 bytecode_array_writer_(zone, &constant_array_builder_,
35 source_position_mode), 34 source_position_mode),
36 pipeline_(&bytecode_array_writer_) { 35 pipeline_(&bytecode_array_writer_) {
37 DCHECK_GE(parameter_count_, 0); 36 DCHECK_GE(parameter_count_, 0);
38 DCHECK_GE(context_register_count_, 0); 37 DCHECK_GE(context_register_count_, 0);
39 DCHECK_GE(local_register_count_, 0); 38 DCHECK_GE(local_register_count_, 0);
40 39
41 if (FLAG_ignition_deadcode) { 40 if (FLAG_ignition_deadcode) {
42 pipeline_ = new (zone) BytecodeDeadCodeOptimizer(pipeline_); 41 pipeline_ = new (zone) BytecodeDeadCodeOptimizer(pipeline_);
43 } 42 }
44 43
(...skipping 23 matching lines...) Expand all
68 67
69 Register BytecodeArrayBuilder::Parameter(int parameter_index) const { 68 Register BytecodeArrayBuilder::Parameter(int parameter_index) const {
70 DCHECK_GE(parameter_index, 0); 69 DCHECK_GE(parameter_index, 0);
71 return Register::FromParameterIndex(parameter_index, parameter_count()); 70 return Register::FromParameterIndex(parameter_index, parameter_count());
72 } 71 }
73 72
74 bool BytecodeArrayBuilder::RegisterIsParameterOrLocal(Register reg) const { 73 bool BytecodeArrayBuilder::RegisterIsParameterOrLocal(Register reg) const {
75 return reg.is_parameter() || reg.index() < locals_count(); 74 return reg.is_parameter() || reg.index() < locals_count();
76 } 75 }
77 76
78 Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() { 77 Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray(Isolate* isolate) {
79 DCHECK(return_seen_in_block_); 78 DCHECK(return_seen_in_block_);
80 DCHECK(!bytecode_generated_); 79 DCHECK(!bytecode_generated_);
81 bytecode_generated_ = true; 80 bytecode_generated_ = true;
82 81
83 Handle<FixedArray> handler_table = handler_table_builder()->ToHandlerTable(); 82 Handle<FixedArray> handler_table =
84 return pipeline_->ToBytecodeArray(fixed_register_count(), parameter_count(), 83 handler_table_builder()->ToHandlerTable(isolate);
85 handler_table); 84 return pipeline_->ToBytecodeArray(isolate, fixed_register_count(),
85 parameter_count(), handler_table);
86 } 86 }
87 87
88 namespace { 88 namespace {
89 89
90 static bool ExpressionPositionIsNeeded(Bytecode bytecode) { 90 static bool ExpressionPositionIsNeeded(Bytecode bytecode) {
91 // An expression position is always needed if filtering is turned 91 // An expression position is always needed if filtering is turned
92 // off. Otherwise an expression is only needed if the bytecode has 92 // off. Otherwise an expression is only needed if the bytecode has
93 // external side effects. 93 // external side effects.
94 return !FLAG_ignition_filter_expression_positions || 94 return !FLAG_ignition_filter_expression_positions ||
95 !Bytecodes::IsWithoutExternalSideEffects(bytecode); 95 !Bytecodes::IsWithoutExternalSideEffects(bytecode);
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 return Bytecode::kTailCall; 971 return Bytecode::kTailCall;
972 default: 972 default:
973 UNREACHABLE(); 973 UNREACHABLE();
974 } 974 }
975 return Bytecode::kIllegal; 975 return Bytecode::kIllegal;
976 } 976 }
977 977
978 } // namespace interpreter 978 } // namespace interpreter
979 } // namespace internal 979 } // namespace internal
980 } // namespace v8 980 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-array-writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698