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

Side by Side Diff: src/hydrogen.cc

Issue 316023002: --debug-code: sanity-checking instrumentation for Lithium object accesses (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 8833 matching lines...) Expand 10 before | Expand all | Expand 10 after
8844 } 8844 }
8845 8845
8846 HAllocate* receiver = BuildAllocate( 8846 HAllocate* receiver = BuildAllocate(
8847 size_in_bytes, HType::JSObject(), JS_OBJECT_TYPE, allocation_mode); 8847 size_in_bytes, HType::JSObject(), JS_OBJECT_TYPE, allocation_mode);
8848 receiver->set_known_initial_map(initial_map); 8848 receiver->set_known_initial_map(initial_map);
8849 8849
8850 // Initialize map and fields of the newly allocated object. 8850 // Initialize map and fields of the newly allocated object.
8851 { NoObservableSideEffectsScope no_effects(this); 8851 { NoObservableSideEffectsScope no_effects(this);
8852 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); 8852 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE);
8853 Add<HStoreNamedField>(receiver, 8853 Add<HStoreNamedField>(receiver,
8854 HObjectAccess::ForMapAndOffset(initial_map, JSObject::kMapOffset), 8854 HObjectAccess::ForMap(),
8855 Add<HConstant>(initial_map)); 8855 Add<HConstant>(initial_map));
8856 HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array()); 8856 HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array());
8857 Add<HStoreNamedField>(receiver, 8857 Add<HStoreNamedField>(receiver,
8858 HObjectAccess::ForMapAndOffset(initial_map, 8858 HObjectAccess::ForPropertiesPointer(),
8859 JSObject::kPropertiesOffset), 8859 empty_fixed_array);
8860 empty_fixed_array);
8861 Add<HStoreNamedField>(receiver, 8860 Add<HStoreNamedField>(receiver,
8862 HObjectAccess::ForMapAndOffset(initial_map, 8861 HObjectAccess::ForElementsPointer(),
8863 JSObject::kElementsOffset), 8862 empty_fixed_array);
8864 empty_fixed_array);
8865 if (initial_map->inobject_properties() != 0) { 8863 if (initial_map->inobject_properties() != 0) {
8866 HConstant* undefined = graph()->GetConstantUndefined(); 8864 HConstant* undefined = graph()->GetConstantUndefined();
8867 for (int i = 0; i < initial_map->inobject_properties(); i++) { 8865 for (int i = 0; i < initial_map->inobject_properties(); i++) {
8868 int property_offset = initial_map->GetInObjectPropertyOffset(i); 8866 int property_offset = initial_map->GetInObjectPropertyOffset(i);
8869 Add<HStoreNamedField>(receiver, 8867 Add<HStoreNamedField>(receiver,
8870 HObjectAccess::ForMapAndOffset(initial_map, property_offset), 8868 HObjectAccess::ForMapAndOffset(initial_map, property_offset,
8869 HObjectAccess::FOR_FIELD),
8871 undefined); 8870 undefined);
8872 } 8871 }
8873 } 8872 }
8874 } 8873 }
8875 8874
8876 // Replace the constructor function with a newly allocated receiver using 8875 // Replace the constructor function with a newly allocated receiver using
8877 // the index of the receiver from the top of the expression stack. 8876 // the index of the receiver from the top of the expression stack.
8878 const int receiver_index = argument_count - 1; 8877 const int receiver_index = argument_count - 1;
8879 ASSERT(environment()->ExpressionStackAt(receiver_index) == function); 8878 ASSERT(environment()->ExpressionStackAt(receiver_index) == function);
8880 environment()->SetExpressionStackAt(receiver_index, receiver); 8879 environment()->SetExpressionStackAt(receiver_index, receiver);
(...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after
10489 10488
10490 HInstruction* object = Add<HAllocate>(object_size_constant, type, 10489 HInstruction* object = Add<HAllocate>(object_size_constant, type,
10491 pretenure_flag, instance_type, site_context->current()); 10490 pretenure_flag, instance_type, site_context->current());
10492 10491
10493 // If allocation folding reaches Page::kMaxRegularHeapObjectSize the 10492 // If allocation folding reaches Page::kMaxRegularHeapObjectSize the
10494 // elements array may not get folded into the object. Hence, we set the 10493 // elements array may not get folded into the object. Hence, we set the
10495 // elements pointer to empty fixed array and let store elimination remove 10494 // elements pointer to empty fixed array and let store elimination remove
10496 // this store in the folding case. 10495 // this store in the folding case.
10497 HConstant* empty_fixed_array = Add<HConstant>( 10496 HConstant* empty_fixed_array = Add<HConstant>(
10498 isolate()->factory()->empty_fixed_array()); 10497 isolate()->factory()->empty_fixed_array());
10499 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
10500 empty_fixed_array);
10501 10498
10502 BuildEmitObjectHeader(boilerplate_object, object); 10499 BuildEmitObjectHeader(boilerplate_object, object);
Igor Sheludko 2014/06/05 09:04:30 I think it is better to move BuildEmitObjectHeader
Jakob Kummerow 2014/06/05 14:33:31 Done.
10500 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
10501 empty_fixed_array, INITIALIZING_STORE);
Igor Sheludko 2014/06/05 09:04:30 I think it is cleaner not to pass INITIALIZING_STO
Jakob Kummerow 2014/06/05 14:33:31 Done. (I think this was a rebasing artifact, as I
10503 10502
10504 Handle<FixedArrayBase> elements(boilerplate_object->elements()); 10503 Handle<FixedArrayBase> elements(boilerplate_object->elements());
10505 int elements_size = (elements->length() > 0 && 10504 int elements_size = (elements->length() > 0 &&
10506 elements->map() != isolate()->heap()->fixed_cow_array_map()) ? 10505 elements->map() != isolate()->heap()->fixed_cow_array_map()) ?
10507 elements->Size() : 0; 10506 elements->Size() : 0;
10508 10507
10509 if (pretenure_flag == TENURED && 10508 if (pretenure_flag == TENURED &&
10510 elements->map() == isolate()->heap()->fixed_cow_array_map() && 10509 elements->map() == isolate()->heap()->fixed_cow_array_map() &&
10511 isolate()->heap()->InNewSpace(*elements)) { 10510 isolate()->heap()->InNewSpace(*elements)) {
10512 // If we would like to pretenure a fixed cow array, we must ensure that the 10511 // If we would like to pretenure a fixed cow array, we must ensure that the
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
10605 int index = descriptors->GetFieldIndex(i); 10604 int index = descriptors->GetFieldIndex(i);
10606 int property_offset = boilerplate_object->GetInObjectPropertyOffset(index); 10605 int property_offset = boilerplate_object->GetInObjectPropertyOffset(index);
10607 Handle<Name> name(descriptors->GetKey(i)); 10606 Handle<Name> name(descriptors->GetKey(i));
10608 Handle<Object> value = 10607 Handle<Object> value =
10609 Handle<Object>(boilerplate_object->InObjectPropertyAt(index), 10608 Handle<Object>(boilerplate_object->InObjectPropertyAt(index),
10610 isolate()); 10609 isolate());
10611 10610
10612 // The access for the store depends on the type of the boilerplate. 10611 // The access for the store depends on the type of the boilerplate.
10613 HObjectAccess access = boilerplate_object->IsJSArray() ? 10612 HObjectAccess access = boilerplate_object->IsJSArray() ?
10614 HObjectAccess::ForJSArrayOffset(property_offset) : 10613 HObjectAccess::ForJSArrayOffset(property_offset) :
10615 HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset); 10614 HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset,
10615 HObjectAccess::FOR_FIELD);
10616 10616
10617 if (value->IsJSObject()) { 10617 if (value->IsJSObject()) {
10618 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 10618 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
10619 Handle<AllocationSite> current_site = site_context->EnterNewScope(); 10619 Handle<AllocationSite> current_site = site_context->EnterNewScope();
10620 HInstruction* result = 10620 HInstruction* result =
10621 BuildFastLiteral(value_object, site_context); 10621 BuildFastLiteral(value_object, site_context);
10622 site_context->ExitScope(current_site, value_object); 10622 site_context->ExitScope(current_site, value_object);
10623 Add<HStoreNamedField>(object, access, result); 10623 Add<HStoreNamedField>(object, access, result);
10624 } else { 10624 } else {
10625 Representation representation = details.representation(); 10625 Representation representation = details.representation();
(...skipping 28 matching lines...) Expand all
10654 } 10654 }
10655 } 10655 }
10656 10656
10657 int inobject_properties = boilerplate_object->map()->inobject_properties(); 10657 int inobject_properties = boilerplate_object->map()->inobject_properties();
10658 HInstruction* value_instruction = 10658 HInstruction* value_instruction =
10659 Add<HConstant>(isolate()->factory()->one_pointer_filler_map()); 10659 Add<HConstant>(isolate()->factory()->one_pointer_filler_map());
10660 for (int i = copied_fields; i < inobject_properties; i++) { 10660 for (int i = copied_fields; i < inobject_properties; i++) {
10661 ASSERT(boilerplate_object->IsJSObject()); 10661 ASSERT(boilerplate_object->IsJSObject());
10662 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); 10662 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i);
10663 HObjectAccess access = 10663 HObjectAccess access =
10664 HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset); 10664 HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset,
10665 HObjectAccess::FOR_FIELD);
10665 Add<HStoreNamedField>(object, access, value_instruction); 10666 Add<HStoreNamedField>(object, access, value_instruction);
10666 } 10667 }
10667 } 10668 }
10668 10669
10669 10670
10670 void HOptimizedGraphBuilder::BuildEmitElements( 10671 void HOptimizedGraphBuilder::BuildEmitElements(
10671 Handle<JSObject> boilerplate_object, 10672 Handle<JSObject> boilerplate_object,
10672 Handle<FixedArrayBase> elements, 10673 Handle<FixedArrayBase> elements,
10673 HValue* object_elements, 10674 HValue* object_elements,
10674 AllocationSiteUsageContext* site_context) { 10675 AllocationSiteUsageContext* site_context) {
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
12038 if (ShouldProduceTraceOutput()) { 12039 if (ShouldProduceTraceOutput()) {
12039 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 12040 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
12040 } 12041 }
12041 12042
12042 #ifdef DEBUG 12043 #ifdef DEBUG
12043 graph_->Verify(false); // No full verify. 12044 graph_->Verify(false); // No full verify.
12044 #endif 12045 #endif
12045 } 12046 }
12046 12047
12047 } } // namespace v8::internal 12048 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | src/hydrogen-instructions.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698