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

Side by Side Diff: src/hydrogen.cc

Issue 68493005: Constant-folding through HForceRepresentation fix. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review notes fixed. Created 7 years, 1 month 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
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2060 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 } 2071 }
2072 ASSERT(fast_smi_only_elements || 2072 ASSERT(fast_smi_only_elements ||
2073 fast_elements || 2073 fast_elements ||
2074 IsFastDoubleElementsKind(elements_kind)); 2074 IsFastDoubleElementsKind(elements_kind));
2075 2075
2076 // In case val is stored into a fast smi array, assure that the value is a smi 2076 // In case val is stored into a fast smi array, assure that the value is a smi
2077 // before manipulating the backing store. Otherwise the actual store may 2077 // before manipulating the backing store. Otherwise the actual store may
2078 // deopt, leaving the backing store in an invalid state. 2078 // deopt, leaving the backing store in an invalid state.
2079 if (is_store && IsFastSmiElementsKind(elements_kind) && 2079 if (is_store && IsFastSmiElementsKind(elements_kind) &&
2080 !val->type().IsSmi()) { 2080 !val->type().IsSmi()) {
2081 val = Add<HForceRepresentation>(val, Representation::Smi()); 2081 val = AddUncasted<HForceRepresentation>(val, Representation::Smi());
2082 } 2082 }
2083 2083
2084 if (IsGrowStoreMode(store_mode)) { 2084 if (IsGrowStoreMode(store_mode)) {
2085 NoObservableSideEffectsScope no_effects(this); 2085 NoObservableSideEffectsScope no_effects(this);
2086 elements = BuildCheckForCapacityGrow(checked_object, elements, 2086 elements = BuildCheckForCapacityGrow(checked_object, elements,
2087 elements_kind, length, key, 2087 elements_kind, length, key,
2088 is_js_array); 2088 is_js_array);
2089 checked_key = key; 2089 checked_key = key;
2090 } else { 2090 } else {
2091 checked_key = Add<HBoundsCheck>(key, length); 2091 checked_key = Add<HBoundsCheck>(key, length);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
2188 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), 2188 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(),
2189 capacity); 2189 capacity);
2190 } 2190 }
2191 2191
2192 2192
2193 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader( 2193 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader(
2194 ElementsKind kind, 2194 ElementsKind kind,
2195 HValue* capacity) { 2195 HValue* capacity) {
2196 // The HForceRepresentation is to prevent possible deopt on int-smi 2196 // The HForceRepresentation is to prevent possible deopt on int-smi
2197 // conversion after allocation but before the new object fields are set. 2197 // conversion after allocation but before the new object fields are set.
2198 capacity = Add<HForceRepresentation>(capacity, Representation::Smi()); 2198 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi());
2199 HValue* new_elements = BuildAllocateElements(kind, capacity); 2199 HValue* new_elements = BuildAllocateElements(kind, capacity);
2200 BuildInitializeElementsHeader(new_elements, kind, capacity); 2200 BuildInitializeElementsHeader(new_elements, kind, capacity);
2201 return new_elements; 2201 return new_elements;
2202 } 2202 }
2203 2203
2204 2204
2205 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, 2205 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array,
2206 HValue* array_map, 2206 HValue* array_map,
2207 AllocationSiteMode mode, 2207 AllocationSiteMode mode,
2208 ElementsKind elements_kind, 2208 ElementsKind elements_kind,
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 } 2707 }
2708 2708
2709 2709
2710 HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* size_in_bytes, 2710 HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* size_in_bytes,
2711 HValue* capacity, 2711 HValue* capacity,
2712 HValue* length_field, 2712 HValue* length_field,
2713 FillMode fill_mode) { 2713 FillMode fill_mode) {
2714 // These HForceRepresentations are because we store these as fields in the 2714 // These HForceRepresentations are because we store these as fields in the
2715 // objects we construct, and an int32-to-smi HChange could deopt. Accept 2715 // objects we construct, and an int32-to-smi HChange could deopt. Accept
2716 // the deopt possibility now, before allocation occurs. 2716 // the deopt possibility now, before allocation occurs.
2717 capacity = builder()->Add<HForceRepresentation>(capacity, 2717 capacity =
2718 Representation::Smi()); 2718 builder()->AddUncasted<HForceRepresentation>(capacity,
2719 length_field = builder()->Add<HForceRepresentation>(length_field, 2719 Representation::Smi());
2720 Representation::Smi()); 2720 length_field =
2721 builder()->AddUncasted<HForceRepresentation>(length_field,
2722 Representation::Smi());
2721 // Allocate (dealing with failure appropriately) 2723 // Allocate (dealing with failure appropriately)
2722 HAllocate* new_object = builder()->Add<HAllocate>(size_in_bytes, 2724 HAllocate* new_object = builder()->Add<HAllocate>(size_in_bytes,
2723 HType::JSArray(), NOT_TENURED, JS_ARRAY_TYPE); 2725 HType::JSArray(), NOT_TENURED, JS_ARRAY_TYPE);
2724 2726
2725 // Folded array allocation should be aligned if it has fast double elements. 2727 // Folded array allocation should be aligned if it has fast double elements.
2726 if (IsFastDoubleElementsKind(kind_)) { 2728 if (IsFastDoubleElementsKind(kind_)) {
2727 new_object->MakeDoubleAligned(); 2729 new_object->MakeDoubleAligned();
2728 } 2730 }
2729 2731
2730 // Fill in the fields: map, properties, length 2732 // Fill in the fields: map, properties, length
(...skipping 5529 matching lines...) Expand 10 before | Expand all | Expand 10 after
8260 Representation rep = Representation::FromType(info); 8262 Representation rep = Representation::FromType(info);
8261 if (rep.IsNone() || rep.IsTagged()) { 8263 if (rep.IsNone() || rep.IsTagged()) {
8262 rep = Representation::Smi(); 8264 rep = Representation::Smi();
8263 } 8265 }
8264 8266
8265 if (returns_original_input) { 8267 if (returns_original_input) {
8266 // We need an explicit HValue representing ToNumber(input). The 8268 // We need an explicit HValue representing ToNumber(input). The
8267 // actual HChange instruction we need is (sometimes) added in a later 8269 // actual HChange instruction we need is (sometimes) added in a later
8268 // phase, so it is not available now to be used as an input to HAdd and 8270 // phase, so it is not available now to be used as an input to HAdd and
8269 // as the return value. 8271 // as the return value.
8270 HInstruction* number_input = Add<HForceRepresentation>(Pop(), rep); 8272 HInstruction* number_input = AddUncasted<HForceRepresentation>(Pop(), rep);
8271 if (!rep.IsDouble()) { 8273 if (!rep.IsDouble()) {
8272 number_input->SetFlag(HInstruction::kFlexibleRepresentation); 8274 number_input->SetFlag(HInstruction::kFlexibleRepresentation);
8273 number_input->SetFlag(HInstruction::kCannotBeTagged); 8275 number_input->SetFlag(HInstruction::kCannotBeTagged);
8274 } 8276 }
8275 Push(number_input); 8277 Push(number_input);
8276 } 8278 }
8277 8279
8278 // The addition has no side effects, so we do not need 8280 // The addition has no side effects, so we do not need
8279 // to simulate the expression stack after this instruction. 8281 // to simulate the expression stack after this instruction.
8280 // Any later failures deopt to the load of the input or earlier. 8282 // Any later failures deopt to the load of the input or earlier.
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
8507 return false; 8509 return false;
8508 } 8510 }
8509 } 8511 }
8510 return true; 8512 return true;
8511 } 8513 }
8512 8514
8513 8515
8514 HValue* HGraphBuilder::EnforceNumberType(HValue* number, 8516 HValue* HGraphBuilder::EnforceNumberType(HValue* number,
8515 Handle<Type> expected) { 8517 Handle<Type> expected) {
8516 if (expected->Is(Type::Smi())) { 8518 if (expected->Is(Type::Smi())) {
8517 return Add<HForceRepresentation>(number, Representation::Smi()); 8519 return AddUncasted<HForceRepresentation>(number, Representation::Smi());
8518 } 8520 }
8519 if (expected->Is(Type::Signed32())) { 8521 if (expected->Is(Type::Signed32())) {
8520 return Add<HForceRepresentation>(number, Representation::Integer32()); 8522 return AddUncasted<HForceRepresentation>(number,
8523 Representation::Integer32());
8521 } 8524 }
8522 return number; 8525 return number;
8523 } 8526 }
8524 8527
8525 8528
8526 HValue* HGraphBuilder::TruncateToNumber(HValue* value, Handle<Type>* expected) { 8529 HValue* HGraphBuilder::TruncateToNumber(HValue* value, Handle<Type>* expected) {
8527 if (value->IsConstant()) { 8530 if (value->IsConstant()) {
8528 HConstant* constant = HConstant::cast(value); 8531 HConstant* constant = HConstant::cast(value);
8529 Maybe<HConstant*> number = constant->CopyToTruncatedNumber(zone()); 8532 Maybe<HConstant*> number = constant->CopyToTruncatedNumber(zone());
8530 if (number.has_value) { 8533 if (number.has_value) {
(...skipping 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after
10620 if (ShouldProduceTraceOutput()) { 10623 if (ShouldProduceTraceOutput()) {
10621 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 10624 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
10622 } 10625 }
10623 10626
10624 #ifdef DEBUG 10627 #ifdef DEBUG
10625 graph_->Verify(false); // No full verify. 10628 graph_->Verify(false); // No full verify.
10626 #endif 10629 #endif
10627 } 10630 }
10628 10631
10629 } } // namespace v8::internal 10632 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698