OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 5352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5363 if (access.representation().IsDouble()) { | 5363 if (access.representation().IsDouble()) { |
5364 // Load the heap number. | 5364 // Load the heap number. |
5365 checked_object = Add<HLoadNamedField>( | 5365 checked_object = Add<HLoadNamedField>( |
5366 checked_object, static_cast<HValue*>(NULL), | 5366 checked_object, static_cast<HValue*>(NULL), |
5367 access.WithRepresentation(Representation::Tagged())); | 5367 access.WithRepresentation(Representation::Tagged())); |
5368 checked_object->set_type(HType::HeapNumber()); | 5368 checked_object->set_type(HType::HeapNumber()); |
5369 // Load the double value from it. | 5369 // Load the double value from it. |
5370 access = HObjectAccess::ForHeapNumberValue(); | 5370 access = HObjectAccess::ForHeapNumberValue(); |
5371 } | 5371 } |
5372 return New<HLoadNamedField>( | 5372 return New<HLoadNamedField>( |
5373 checked_object, static_cast<HValue*>(NULL), access, info->field_map()); | 5373 checked_object, static_cast<HValue*>(NULL), access); |
5374 } | 5374 } |
5375 | 5375 |
5376 | 5376 |
5377 HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField( | 5377 HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField( |
5378 PropertyAccessInfo* info, | 5378 PropertyAccessInfo* info, |
5379 HValue* checked_object, | 5379 HValue* checked_object, |
5380 HValue* value) { | 5380 HValue* value) { |
5381 bool transition_to_field = info->lookup()->IsTransition(); | 5381 bool transition_to_field = info->lookup()->IsTransition(); |
5382 // TODO(verwaest): Move this logic into PropertyAccessInfo. | 5382 // TODO(verwaest): Move this logic into PropertyAccessInfo. |
5383 HObjectAccess field_access = HObjectAccess::ForField( | 5383 HObjectAccess field_access = HObjectAccess::ForField( |
(...skipping 24 matching lines...) Expand all Loading... |
5408 } else { | 5408 } else { |
5409 // Already holds a HeapNumber; load the box and write its value field. | 5409 // Already holds a HeapNumber; load the box and write its value field. |
5410 HInstruction* heap_number = Add<HLoadNamedField>( | 5410 HInstruction* heap_number = Add<HLoadNamedField>( |
5411 checked_object, static_cast<HValue*>(NULL), heap_number_access); | 5411 checked_object, static_cast<HValue*>(NULL), heap_number_access); |
5412 heap_number->set_type(HType::HeapNumber()); | 5412 heap_number->set_type(HType::HeapNumber()); |
5413 instr = New<HStoreNamedField>(heap_number, | 5413 instr = New<HStoreNamedField>(heap_number, |
5414 HObjectAccess::ForHeapNumberValue(), | 5414 HObjectAccess::ForHeapNumberValue(), |
5415 value, STORE_TO_INITIALIZED_ENTRY); | 5415 value, STORE_TO_INITIALIZED_ENTRY); |
5416 } | 5416 } |
5417 } else { | 5417 } else { |
5418 if (!info->field_map().is_null()) { | |
5419 ASSERT(field_access.representation().IsHeapObject()); | |
5420 BuildCheckHeapObject(value); | |
5421 value = BuildCheckMap(value, info->field_map()); | |
5422 } | |
5423 | |
5424 // This is a normal store. | 5418 // This is a normal store. |
5425 instr = New<HStoreNamedField>( | 5419 instr = New<HStoreNamedField>( |
5426 checked_object->ActualValue(), field_access, value, | 5420 checked_object->ActualValue(), field_access, value, |
5427 transition_to_field ? INITIALIZING_STORE : STORE_TO_INITIALIZED_ENTRY); | 5421 transition_to_field ? INITIALIZING_STORE : STORE_TO_INITIALIZED_ENTRY); |
5428 } | 5422 } |
5429 | 5423 |
5430 if (transition_to_field) { | 5424 if (transition_to_field) { |
5431 HConstant* transition_constant = Add<HConstant>(info->transition()); | 5425 HConstant* transition_constant = Add<HConstant>(info->transition()); |
5432 instr->SetTransition(transition_constant, top_info()); | 5426 instr->SetTransition(transition_constant, top_info()); |
5433 instr->SetChangesFlag(kMaps); | 5427 instr->SetChangesFlag(kMaps); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5477 if (!info->lookup_.IsField()) return false; | 5471 if (!info->lookup_.IsField()) return false; |
5478 | 5472 |
5479 Representation r = access_.representation(); | 5473 Representation r = access_.representation(); |
5480 if (IsLoad()) { | 5474 if (IsLoad()) { |
5481 if (!info->access_.representation().IsCompatibleForLoad(r)) return false; | 5475 if (!info->access_.representation().IsCompatibleForLoad(r)) return false; |
5482 } else { | 5476 } else { |
5483 if (!info->access_.representation().IsCompatibleForStore(r)) return false; | 5477 if (!info->access_.representation().IsCompatibleForStore(r)) return false; |
5484 } | 5478 } |
5485 if (info->access_.offset() != access_.offset()) return false; | 5479 if (info->access_.offset() != access_.offset()) return false; |
5486 if (info->access_.IsInobject() != access_.IsInobject()) return false; | 5480 if (info->access_.IsInobject() != access_.IsInobject()) return false; |
5487 if (!field_map_.is_identical_to(info->field_map_)) { | |
5488 if (!IsLoad()) return false; | |
5489 | |
5490 // Throw away type information for merging polymorphic loads. | |
5491 field_map_ = info->field_map_ = Handle<Map>(); | |
5492 } | |
5493 info->GeneralizeRepresentation(r); | 5481 info->GeneralizeRepresentation(r); |
5494 return true; | 5482 return true; |
5495 } | 5483 } |
5496 | 5484 |
5497 | 5485 |
5498 bool HOptimizedGraphBuilder::PropertyAccessInfo::LookupDescriptor() { | 5486 bool HOptimizedGraphBuilder::PropertyAccessInfo::LookupDescriptor() { |
5499 if (!type_->IsClass()) return true; | 5487 if (!type_->IsClass()) return true; |
5500 map()->LookupDescriptor(NULL, *name_, &lookup_); | 5488 map()->LookupDescriptor(NULL, *name_, &lookup_); |
5501 return LoadResult(map()); | 5489 return LoadResult(map()); |
5502 } | 5490 } |
5503 | 5491 |
5504 | 5492 |
5505 bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle<Map> map) { | 5493 bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle<Map> map) { |
5506 if (!IsLoad() && lookup_.IsProperty() && | 5494 if (!IsLoad() && lookup_.IsProperty() && |
5507 (lookup_.IsReadOnly() || !lookup_.IsCacheable())) { | 5495 (lookup_.IsReadOnly() || !lookup_.IsCacheable())) { |
5508 return false; | 5496 return false; |
5509 } | 5497 } |
5510 | 5498 |
5511 if (lookup_.IsField()) { | 5499 if (lookup_.IsField()) { |
5512 // Construct the object field access. | |
5513 access_ = HObjectAccess::ForField(map, &lookup_, name_); | 5500 access_ = HObjectAccess::ForField(map, &lookup_, name_); |
5514 | |
5515 if (access_.representation().IsHeapObject()) { | |
5516 // Figure out the field type from the accessor map. | |
5517 HeapType* field_type = lookup_.GetFieldTypeFromMap(*map); | |
5518 if (field_type->IsClass()) { | |
5519 Handle<Map> field_map = field_type->AsClass(); | |
5520 if (field_map->is_stable()) { // TODO(bmeurer) | |
5521 field_map_ = field_map; | |
5522 field_map_->AddDependentCompilationInfo( | |
5523 DependentCode::kPrototypeCheckGroup, top_info()); | |
5524 | |
5525 // Add dependency on the map that introduced the field. | |
5526 Handle<Map> field_owner = handle(lookup_.GetFieldOwnerFromMap(*map)); | |
5527 field_owner->AddDependentCompilationInfo( | |
5528 DependentCode::kFieldTypeGroup, top_info()); | |
5529 } | |
5530 } | |
5531 } | |
5532 } else if (lookup_.IsPropertyCallbacks()) { | 5501 } else if (lookup_.IsPropertyCallbacks()) { |
5533 Handle<Object> callback(lookup_.GetValueFromMap(*map), isolate()); | 5502 Handle<Object> callback(lookup_.GetValueFromMap(*map), isolate()); |
5534 if (!callback->IsAccessorPair()) return false; | 5503 if (!callback->IsAccessorPair()) return false; |
5535 Object* raw_accessor = IsLoad() | 5504 Object* raw_accessor = IsLoad() |
5536 ? Handle<AccessorPair>::cast(callback)->getter() | 5505 ? Handle<AccessorPair>::cast(callback)->getter() |
5537 : Handle<AccessorPair>::cast(callback)->setter(); | 5506 : Handle<AccessorPair>::cast(callback)->setter(); |
5538 if (!raw_accessor->IsJSFunction()) return false; | 5507 if (!raw_accessor->IsJSFunction()) return false; |
5539 Handle<JSFunction> accessor = handle(JSFunction::cast(raw_accessor)); | 5508 Handle<JSFunction> accessor = handle(JSFunction::cast(raw_accessor)); |
5540 if (accessor->shared()->IsApiFunction()) { | 5509 if (accessor->shared()->IsApiFunction()) { |
5541 CallOptimization call_optimization(accessor); | 5510 CallOptimization call_optimization(accessor); |
(...skipping 6045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11587 if (ShouldProduceTraceOutput()) { | 11556 if (ShouldProduceTraceOutput()) { |
11588 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11557 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11589 } | 11558 } |
11590 | 11559 |
11591 #ifdef DEBUG | 11560 #ifdef DEBUG |
11592 graph_->Verify(false); // No full verify. | 11561 graph_->Verify(false); // No full verify. |
11593 #endif | 11562 #endif |
11594 } | 11563 } |
11595 | 11564 |
11596 } } // namespace v8::internal | 11565 } } // namespace v8::internal |
OLD | NEW |