OLD | NEW |
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/js-type-feedback.h" | 5 #include "src/compiler/js-type-feedback.h" |
6 | 6 |
7 #include "src/property-details.h" | 7 #include "src/property-details.h" |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/ast.h" | 10 #include "src/ast.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 NodeProperties::MergeControlToEnd(graph(), common(), deopt); | 184 NodeProperties::MergeControlToEnd(graph(), common(), deopt); |
185 ReplaceWithValue(node, load, load, check_success); | 185 ReplaceWithValue(node, load, load, check_success); |
186 return Replace(load); | 186 return Replace(load); |
187 } | 187 } |
188 | 188 |
189 | 189 |
190 Reduction JSTypeFeedbackSpecializer::ReduceJSLoadGlobal(Node* node) { | 190 Reduction JSTypeFeedbackSpecializer::ReduceJSLoadGlobal(Node* node) { |
191 DCHECK(node->opcode() == IrOpcode::kJSLoadGlobal); | 191 DCHECK(node->opcode() == IrOpcode::kJSLoadGlobal); |
192 Handle<String> name = | 192 Handle<String> name = |
193 Handle<String>::cast(LoadGlobalParametersOf(node->op()).name()); | 193 Handle<String>::cast(LoadGlobalParametersOf(node->op()).name()); |
194 // Try to optimize loads from the global object. | |
195 Handle<Object> constant_value = | |
196 jsgraph()->isolate()->factory()->GlobalConstantFor(name); | |
197 if (!constant_value.is_null()) { | |
198 // Always optimize global constants. | |
199 Node* constant = jsgraph()->Constant(constant_value); | |
200 ReplaceWithValue(node, constant); | |
201 return Replace(constant); | |
202 } | |
203 | |
204 if (global_object_.is_null()) { | 194 if (global_object_.is_null()) { |
205 // Nothing else can be done if we don't have a global object. | 195 // Nothing else can be done if we don't have a global object. |
206 return NoChange(); | 196 return NoChange(); |
207 } | 197 } |
208 | 198 |
209 if (mode() == kDeoptimizationEnabled) { | 199 if (mode() == kDeoptimizationEnabled) { |
210 // Handle lookups in the script context. | 200 // Handle lookups in the script context. |
211 { | 201 { |
212 Handle<ScriptContextTable> script_contexts( | 202 Handle<ScriptContextTable> script_contexts( |
213 global_object_->native_context()->script_context_table()); | 203 global_object_->native_context()->script_context_table()); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 BailoutId id = OpParameter<FrameStateInfo>(node).bailout_id(); | 345 BailoutId id = OpParameter<FrameStateInfo>(node).bailout_id(); |
356 if (id != BailoutId::None()) return frame_state; | 346 if (id != BailoutId::None()) return frame_state; |
357 } | 347 } |
358 } | 348 } |
359 return nullptr; | 349 return nullptr; |
360 } | 350 } |
361 | 351 |
362 } // namespace compiler | 352 } // namespace compiler |
363 } // namespace internal | 353 } // namespace internal |
364 } // namespace v8 | 354 } // namespace v8 |
OLD | NEW |