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 5319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5330 if (access.representation().IsDouble()) { | 5330 if (access.representation().IsDouble()) { |
5331 // Load the heap number. | 5331 // Load the heap number. |
5332 checked_object = Add<HLoadNamedField>( | 5332 checked_object = Add<HLoadNamedField>( |
5333 checked_object, static_cast<HValue*>(NULL), | 5333 checked_object, static_cast<HValue*>(NULL), |
5334 access.WithRepresentation(Representation::Tagged())); | 5334 access.WithRepresentation(Representation::Tagged())); |
5335 checked_object->set_type(HType::HeapNumber()); | 5335 checked_object->set_type(HType::HeapNumber()); |
5336 // Load the double value from it. | 5336 // Load the double value from it. |
5337 access = HObjectAccess::ForHeapNumberValue(); | 5337 access = HObjectAccess::ForHeapNumberValue(); |
5338 } | 5338 } |
5339 return New<HLoadNamedField>( | 5339 return New<HLoadNamedField>( |
5340 checked_object, static_cast<HValue*>(NULL), access); | 5340 checked_object, static_cast<HValue*>(NULL), access, info->field_map()); |
5341 } | 5341 } |
5342 | 5342 |
5343 | 5343 |
5344 HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField( | 5344 HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField( |
5345 PropertyAccessInfo* info, | 5345 PropertyAccessInfo* info, |
5346 HValue* checked_object, | 5346 HValue* checked_object, |
5347 HValue* value) { | 5347 HValue* value) { |
5348 bool transition_to_field = info->lookup()->IsTransition(); | 5348 bool transition_to_field = info->lookup()->IsTransition(); |
5349 // TODO(verwaest): Move this logic into PropertyAccessInfo. | 5349 // TODO(verwaest): Move this logic into PropertyAccessInfo. |
5350 HObjectAccess field_access = HObjectAccess::ForField( | 5350 HObjectAccess field_access = HObjectAccess::ForField( |
(...skipping 24 matching lines...) Expand all Loading... | |
5375 } else { | 5375 } else { |
5376 // Already holds a HeapNumber; load the box and write its value field. | 5376 // Already holds a HeapNumber; load the box and write its value field. |
5377 HInstruction* heap_number = Add<HLoadNamedField>( | 5377 HInstruction* heap_number = Add<HLoadNamedField>( |
5378 checked_object, static_cast<HValue*>(NULL), heap_number_access); | 5378 checked_object, static_cast<HValue*>(NULL), heap_number_access); |
5379 heap_number->set_type(HType::HeapNumber()); | 5379 heap_number->set_type(HType::HeapNumber()); |
5380 instr = New<HStoreNamedField>(heap_number, | 5380 instr = New<HStoreNamedField>(heap_number, |
5381 HObjectAccess::ForHeapNumberValue(), | 5381 HObjectAccess::ForHeapNumberValue(), |
5382 value, STORE_TO_INITIALIZED_ENTRY); | 5382 value, STORE_TO_INITIALIZED_ENTRY); |
5383 } | 5383 } |
5384 } else { | 5384 } else { |
5385 if (!info->field_map().is_null()) { | |
5386 ASSERT(field_access.representation().IsHeapObject()); | |
5387 value = BuildCheckMap(value, info->field_map()); | |
5388 } | |
5389 | |
5385 // This is a normal store. | 5390 // This is a normal store. |
5386 instr = New<HStoreNamedField>( | 5391 instr = New<HStoreNamedField>( |
5387 checked_object->ActualValue(), field_access, value, | 5392 checked_object->ActualValue(), field_access, value, |
5388 transition_to_field ? INITIALIZING_STORE : STORE_TO_INITIALIZED_ENTRY); | 5393 transition_to_field ? INITIALIZING_STORE : STORE_TO_INITIALIZED_ENTRY); |
5389 } | 5394 } |
5390 | 5395 |
5391 if (transition_to_field) { | 5396 if (transition_to_field) { |
5392 HConstant* transition_constant = Add<HConstant>(info->transition()); | 5397 HConstant* transition_constant = Add<HConstant>(info->transition()); |
5393 instr->SetTransition(transition_constant, top_info()); | 5398 instr->SetTransition(transition_constant, top_info()); |
5394 instr->SetChangesFlag(kMaps); | 5399 instr->SetChangesFlag(kMaps); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5438 if (!info->lookup_.IsField()) return false; | 5443 if (!info->lookup_.IsField()) return false; |
5439 | 5444 |
5440 Representation r = access_.representation(); | 5445 Representation r = access_.representation(); |
5441 if (IsLoad()) { | 5446 if (IsLoad()) { |
5442 if (!info->access_.representation().IsCompatibleForLoad(r)) return false; | 5447 if (!info->access_.representation().IsCompatibleForLoad(r)) return false; |
5443 } else { | 5448 } else { |
5444 if (!info->access_.representation().IsCompatibleForStore(r)) return false; | 5449 if (!info->access_.representation().IsCompatibleForStore(r)) return false; |
5445 } | 5450 } |
5446 if (info->access_.offset() != access_.offset()) return false; | 5451 if (info->access_.offset() != access_.offset()) return false; |
5447 if (info->access_.IsInobject() != access_.IsInobject()) return false; | 5452 if (info->access_.IsInobject() != access_.IsInobject()) return false; |
5453 if (!field_map_.is_identical_to(info->field_map_)) { | |
5454 if (!IsLoad()) return false; | |
5455 | |
5456 // Throw away type information for merging polymorphic loads. | |
5457 field_map_ = info->field_map_ = Handle<Map>(); | |
5458 } | |
5448 info->GeneralizeRepresentation(r); | 5459 info->GeneralizeRepresentation(r); |
5449 return true; | 5460 return true; |
5450 } | 5461 } |
5451 | 5462 |
5452 | 5463 |
5453 bool HOptimizedGraphBuilder::PropertyAccessInfo::LookupDescriptor() { | 5464 bool HOptimizedGraphBuilder::PropertyAccessInfo::LookupDescriptor() { |
5454 if (!type_->IsClass()) return true; | 5465 if (!type_->IsClass()) return true; |
5455 map()->LookupDescriptor(NULL, *name_, &lookup_); | 5466 map()->LookupDescriptor(NULL, *name_, &lookup_); |
5456 return LoadResult(map()); | 5467 return LoadResult(map()); |
5457 } | 5468 } |
5458 | 5469 |
5459 | 5470 |
5460 bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle<Map> map) { | 5471 bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle<Map> map) { |
5461 if (!IsLoad() && lookup_.IsProperty() && | 5472 if (!IsLoad() && lookup_.IsProperty() && |
5462 (lookup_.IsReadOnly() || !lookup_.IsCacheable())) { | 5473 (lookup_.IsReadOnly() || !lookup_.IsCacheable())) { |
5463 return false; | 5474 return false; |
5464 } | 5475 } |
5465 | 5476 |
5466 if (lookup_.IsField()) { | 5477 if (lookup_.IsField()) { |
5478 // Construct the object field access. | |
5467 access_ = HObjectAccess::ForField(map, &lookup_, name_); | 5479 access_ = HObjectAccess::ForField(map, &lookup_, name_); |
5480 | |
5481 // Figure out the field type from the accessor map. | |
5482 HeapType* field_type = lookup_.GetFieldTypeFromMap(*map); | |
5483 if (field_type->IsClass()) { | |
5484 ASSERT(access_.representation().IsHeapObject()); | |
5485 | |
5486 Handle<Map> field_map = field_type->AsClass(); | |
5487 if (field_map->is_stable()) { // TODO(bmeurer) | |
5488 field_map_ = field_map; | |
5489 field_map_->AddDependentCompilationInfo( | |
Toon Verwaest
2014/03/21 14:33:37
You really only need to add a dependency on these
| |
5490 DependentCode::kPrototypeCheckGroup, top_info()); | |
5491 | |
5492 // Add dependency on the map that introduced the field. | |
5493 Handle<Map> field_owner = handle(lookup_.GetFieldOwnerFromMap(*map)); | |
5494 field_owner->AddDependentCompilationInfo( | |
5495 DependentCode::kFieldTypeGroup, top_info()); | |
5496 } | |
5497 } | |
5468 } else if (lookup_.IsPropertyCallbacks()) { | 5498 } else if (lookup_.IsPropertyCallbacks()) { |
5469 Handle<Object> callback(lookup_.GetValueFromMap(*map), isolate()); | 5499 Handle<Object> callback(lookup_.GetValueFromMap(*map), isolate()); |
5470 if (!callback->IsAccessorPair()) return false; | 5500 if (!callback->IsAccessorPair()) return false; |
5471 Object* raw_accessor = IsLoad() | 5501 Object* raw_accessor = IsLoad() |
5472 ? Handle<AccessorPair>::cast(callback)->getter() | 5502 ? Handle<AccessorPair>::cast(callback)->getter() |
5473 : Handle<AccessorPair>::cast(callback)->setter(); | 5503 : Handle<AccessorPair>::cast(callback)->setter(); |
5474 if (!raw_accessor->IsJSFunction()) return false; | 5504 if (!raw_accessor->IsJSFunction()) return false; |
5475 Handle<JSFunction> accessor = handle(JSFunction::cast(raw_accessor)); | 5505 Handle<JSFunction> accessor = handle(JSFunction::cast(raw_accessor)); |
5476 if (accessor->shared()->IsApiFunction()) { | 5506 if (accessor->shared()->IsApiFunction()) { |
5477 CallOptimization call_optimization(accessor); | 5507 CallOptimization call_optimization(accessor); |
(...skipping 5826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11304 if (ShouldProduceTraceOutput()) { | 11334 if (ShouldProduceTraceOutput()) { |
11305 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11335 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11306 } | 11336 } |
11307 | 11337 |
11308 #ifdef DEBUG | 11338 #ifdef DEBUG |
11309 graph_->Verify(false); // No full verify. | 11339 graph_->Verify(false); // No full verify. |
11310 #endif | 11340 #endif |
11311 } | 11341 } |
11312 | 11342 |
11313 } } // namespace v8::internal | 11343 } } // namespace v8::internal |
OLD | NEW |