OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/hydrogen.h" | 5 #include "src/hydrogen.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 5323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5334 // Handle known global constants like 'undefined' specially to avoid a | 5334 // Handle known global constants like 'undefined' specially to avoid a |
5335 // load from a global cell for them. | 5335 // load from a global cell for them. |
5336 Handle<Object> constant_value = | 5336 Handle<Object> constant_value = |
5337 isolate()->factory()->GlobalConstantFor(variable->name()); | 5337 isolate()->factory()->GlobalConstantFor(variable->name()); |
5338 if (!constant_value.is_null()) { | 5338 if (!constant_value.is_null()) { |
5339 HConstant* instr = New<HConstant>(constant_value); | 5339 HConstant* instr = New<HConstant>(constant_value); |
5340 return ast_context()->ReturnInstruction(instr, expr->id()); | 5340 return ast_context()->ReturnInstruction(instr, expr->id()); |
5341 } | 5341 } |
5342 | 5342 |
5343 Handle<GlobalObject> global(current_info()->global_object()); | 5343 Handle<GlobalObject> global(current_info()->global_object()); |
5344 LookupIterator it(global, variable->name(), | 5344 LookupIterator it(global, variable->name(), LookupIterator::OWN_PROPERTY); |
5345 LookupIterator::CHECK_PROPERTY); | |
5346 GlobalPropertyAccess type = LookupGlobalProperty(variable, &it, LOAD); | 5345 GlobalPropertyAccess type = LookupGlobalProperty(variable, &it, LOAD); |
5347 | 5346 |
5348 if (type == kUseCell && | 5347 if (type == kUseCell && |
5349 current_info()->global_object()->IsAccessCheckNeeded()) { | 5348 current_info()->global_object()->IsAccessCheckNeeded()) { |
5350 type = kUseGeneric; | 5349 type = kUseGeneric; |
5351 } | 5350 } |
5352 | 5351 |
5353 if (type == kUseCell) { | 5352 if (type == kUseCell) { |
5354 Handle<PropertyCell> cell = it.GetPropertyCell(); | 5353 Handle<PropertyCell> cell = it.GetPropertyCell(); |
5355 if (cell->type()->IsConstant()) { | 5354 if (cell->type()->IsConstant()) { |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5790 HInstruction* HOptimizedGraphBuilder::BuildLoadNamedField( | 5789 HInstruction* HOptimizedGraphBuilder::BuildLoadNamedField( |
5791 PropertyAccessInfo* info, | 5790 PropertyAccessInfo* info, |
5792 HValue* checked_object) { | 5791 HValue* checked_object) { |
5793 // See if this is a load for an immutable property | 5792 // See if this is a load for an immutable property |
5794 if (checked_object->ActualValue()->IsConstant() && info->IsCacheable() && | 5793 if (checked_object->ActualValue()->IsConstant() && info->IsCacheable() && |
5795 info->IsReadOnly() && !info->IsConfigurable()) { | 5794 info->IsReadOnly() && !info->IsConfigurable()) { |
5796 Handle<Object> object( | 5795 Handle<Object> object( |
5797 HConstant::cast(checked_object->ActualValue())->handle(isolate())); | 5796 HConstant::cast(checked_object->ActualValue())->handle(isolate())); |
5798 | 5797 |
5799 if (object->IsJSObject()) { | 5798 if (object->IsJSObject()) { |
5800 LookupIterator it(object, info->name(), LookupIterator::CHECK_PROPERTY); | 5799 LookupIterator it(object, info->name(), LookupIterator::OWN_PROPERTY); |
5801 Handle<Object> value = JSObject::GetDataProperty(&it); | 5800 Handle<Object> value = JSObject::GetDataProperty(&it); |
5802 CHECK(it.IsFound()); | 5801 CHECK(it.IsFound()); |
5803 return New<HConstant>(value); | 5802 return New<HConstant>(value); |
5804 } | 5803 } |
5805 } | 5804 } |
5806 | 5805 |
5807 HObjectAccess access = info->access(); | 5806 HObjectAccess access = info->access(); |
5808 if (access.representation().IsDouble()) { | 5807 if (access.representation().IsDouble()) { |
5809 // Load the heap number. | 5808 // Load the heap number. |
5810 checked_object = Add<HLoadNamedField>( | 5809 checked_object = Add<HLoadNamedField>( |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6456 | 6455 |
6457 | 6456 |
6458 // Because not every expression has a position and there is not common | 6457 // Because not every expression has a position and there is not common |
6459 // superclass of Assignment and CountOperation, we cannot just pass the | 6458 // superclass of Assignment and CountOperation, we cannot just pass the |
6460 // owning expression instead of position and ast_id separately. | 6459 // owning expression instead of position and ast_id separately. |
6461 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( | 6460 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( |
6462 Variable* var, | 6461 Variable* var, |
6463 HValue* value, | 6462 HValue* value, |
6464 BailoutId ast_id) { | 6463 BailoutId ast_id) { |
6465 Handle<GlobalObject> global(current_info()->global_object()); | 6464 Handle<GlobalObject> global(current_info()->global_object()); |
6466 LookupIterator it(global, var->name(), LookupIterator::CHECK_PROPERTY); | 6465 LookupIterator it(global, var->name(), LookupIterator::OWN_PROPERTY); |
6467 GlobalPropertyAccess type = LookupGlobalProperty(var, &it, STORE); | 6466 GlobalPropertyAccess type = LookupGlobalProperty(var, &it, STORE); |
6468 if (type == kUseCell) { | 6467 if (type == kUseCell) { |
6469 Handle<PropertyCell> cell = it.GetPropertyCell(); | 6468 Handle<PropertyCell> cell = it.GetPropertyCell(); |
6470 if (cell->type()->IsConstant()) { | 6469 if (cell->type()->IsConstant()) { |
6471 Handle<Object> constant = cell->type()->AsConstant()->Value(); | 6470 Handle<Object> constant = cell->type()->AsConstant()->Value(); |
6472 if (value->IsConstant()) { | 6471 if (value->IsConstant()) { |
6473 HConstant* c_value = HConstant::cast(value); | 6472 HConstant* c_value = HConstant::cast(value); |
6474 if (!constant.is_identical_to(c_value->handle(isolate()))) { | 6473 if (!constant.is_identical_to(c_value->handle(isolate()))) { |
6475 Add<HDeoptimize>("Constant global variable assignment", | 6474 Add<HDeoptimize>("Constant global variable assignment", |
6476 Deoptimizer::EAGER); | 6475 Deoptimizer::EAGER); |
(...skipping 2571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9048 // evaluation of the arguments. | 9047 // evaluation of the arguments. |
9049 CHECK_ALIVE(VisitForValue(expr->expression())); | 9048 CHECK_ALIVE(VisitForValue(expr->expression())); |
9050 HValue* function = Top(); | 9049 HValue* function = Top(); |
9051 if (expr->global_call()) { | 9050 if (expr->global_call()) { |
9052 Variable* var = proxy->var(); | 9051 Variable* var = proxy->var(); |
9053 bool known_global_function = false; | 9052 bool known_global_function = false; |
9054 // If there is a global property cell for the name at compile time and | 9053 // If there is a global property cell for the name at compile time and |
9055 // access check is not enabled we assume that the function will not change | 9054 // access check is not enabled we assume that the function will not change |
9056 // and generate optimized code for calling the function. | 9055 // and generate optimized code for calling the function. |
9057 Handle<GlobalObject> global(current_info()->global_object()); | 9056 Handle<GlobalObject> global(current_info()->global_object()); |
9058 LookupIterator it(global, var->name(), LookupIterator::CHECK_PROPERTY); | 9057 LookupIterator it(global, var->name(), LookupIterator::OWN_PROPERTY); |
9059 GlobalPropertyAccess type = LookupGlobalProperty(var, &it, LOAD); | 9058 GlobalPropertyAccess type = LookupGlobalProperty(var, &it, LOAD); |
9060 if (type == kUseCell && | 9059 if (type == kUseCell && |
9061 !current_info()->global_object()->IsAccessCheckNeeded()) { | 9060 !current_info()->global_object()->IsAccessCheckNeeded()) { |
9062 Handle<GlobalObject> global(current_info()->global_object()); | 9061 Handle<GlobalObject> global(current_info()->global_object()); |
9063 known_global_function = expr->ComputeGlobalTarget(global, &it); | 9062 known_global_function = expr->ComputeGlobalTarget(global, &it); |
9064 } | 9063 } |
9065 if (known_global_function) { | 9064 if (known_global_function) { |
9066 Add<HCheckValue>(function, expr->target()); | 9065 Add<HCheckValue>(function, expr->target()); |
9067 | 9066 |
9068 // Placeholder for the receiver. | 9067 // Placeholder for the receiver. |
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10692 // residing in new space. If it is we assume that the function will stay the | 10691 // residing in new space. If it is we assume that the function will stay the |
10693 // same. | 10692 // same. |
10694 Handle<JSFunction> target = Handle<JSFunction>::null(); | 10693 Handle<JSFunction> target = Handle<JSFunction>::null(); |
10695 VariableProxy* proxy = expr->right()->AsVariableProxy(); | 10694 VariableProxy* proxy = expr->right()->AsVariableProxy(); |
10696 bool global_function = (proxy != NULL) && proxy->var()->IsUnallocated(); | 10695 bool global_function = (proxy != NULL) && proxy->var()->IsUnallocated(); |
10697 if (global_function && | 10696 if (global_function && |
10698 current_info()->has_global_object() && | 10697 current_info()->has_global_object() && |
10699 !current_info()->global_object()->IsAccessCheckNeeded()) { | 10698 !current_info()->global_object()->IsAccessCheckNeeded()) { |
10700 Handle<String> name = proxy->name(); | 10699 Handle<String> name = proxy->name(); |
10701 Handle<GlobalObject> global(current_info()->global_object()); | 10700 Handle<GlobalObject> global(current_info()->global_object()); |
10702 LookupIterator it(global, name, LookupIterator::CHECK_PROPERTY); | 10701 LookupIterator it(global, name, LookupIterator::OWN_PROPERTY); |
10703 Handle<Object> value = JSObject::GetDataProperty(&it); | 10702 Handle<Object> value = JSObject::GetDataProperty(&it); |
10704 if (it.IsFound() && value->IsJSFunction()) { | 10703 if (it.IsFound() && value->IsJSFunction()) { |
10705 Handle<JSFunction> candidate = Handle<JSFunction>::cast(value); | 10704 Handle<JSFunction> candidate = Handle<JSFunction>::cast(value); |
10706 // If the function is in new space we assume it's more likely to | 10705 // If the function is in new space we assume it's more likely to |
10707 // change and thus prefer the general IC code. | 10706 // change and thus prefer the general IC code. |
10708 if (!isolate()->heap()->InNewSpace(*candidate)) { | 10707 if (!isolate()->heap()->InNewSpace(*candidate)) { |
10709 target = candidate; | 10708 target = candidate; |
10710 } | 10709 } |
10711 } | 10710 } |
10712 } | 10711 } |
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12492 if (ShouldProduceTraceOutput()) { | 12491 if (ShouldProduceTraceOutput()) { |
12493 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12492 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12494 } | 12493 } |
12495 | 12494 |
12496 #ifdef DEBUG | 12495 #ifdef DEBUG |
12497 graph_->Verify(false); // No full verify. | 12496 graph_->Verify(false); // No full verify. |
12498 #endif | 12497 #endif |
12499 } | 12498 } |
12500 | 12499 |
12501 } } // namespace v8::internal | 12500 } } // namespace v8::internal |
OLD | NEW |