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

Side by Side Diff: src/compiler/js-create-lowering.cc

Issue 2533353003: [turbofan] Add size DCHECK for inline allocations. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/compiler/js-create-lowering.h" 5 #include "src/compiler/js-create-lowering.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compilation-dependencies.h" 9 #include "src/compilation-dependencies.h"
10 #include "src/compiler/access-builder.h" 10 #include "src/compiler/access-builder.h"
(...skipping 20 matching lines...) Expand all
31 public: 31 public:
32 AllocationBuilder(JSGraph* jsgraph, Node* effect, Node* control) 32 AllocationBuilder(JSGraph* jsgraph, Node* effect, Node* control)
33 : jsgraph_(jsgraph), 33 : jsgraph_(jsgraph),
34 allocation_(nullptr), 34 allocation_(nullptr),
35 effect_(effect), 35 effect_(effect),
36 control_(control) {} 36 control_(control) {}
37 37
38 // Primitive allocation of static size. 38 // Primitive allocation of static size.
39 void Allocate(int size, PretenureFlag pretenure = NOT_TENURED, 39 void Allocate(int size, PretenureFlag pretenure = NOT_TENURED,
40 Type* type = Type::Any()) { 40 Type* type = Type::Any()) {
41 DCHECK_LE(size, kMaxRegularHeapObjectSize);
41 effect_ = graph()->NewNode( 42 effect_ = graph()->NewNode(
42 common()->BeginRegion(RegionObservability::kNotObservable), effect_); 43 common()->BeginRegion(RegionObservability::kNotObservable), effect_);
43 allocation_ = 44 allocation_ =
44 graph()->NewNode(simplified()->Allocate(pretenure), 45 graph()->NewNode(simplified()->Allocate(pretenure),
45 jsgraph()->Constant(size), effect_, control_); 46 jsgraph()->Constant(size), effect_, control_);
46 // TODO(turbofan): Maybe we should put the Type* onto the Allocate operator 47 // TODO(turbofan): Maybe we should put the Type* onto the Allocate operator
47 // at some point, or maybe we should have a completely differnt story. 48 // at some point, or maybe we should have a completely differnt story.
48 NodeProperties::SetType(allocation_, type); 49 NodeProperties::SetType(allocation_, type);
49 effect_ = allocation_; 50 effect_ = allocation_;
50 } 51 }
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 Handle<Object> boilerplate_value(boilerplate->RawFastPropertyAt(index), 1098 Handle<Object> boilerplate_value(boilerplate->RawFastPropertyAt(index),
1098 isolate()); 1099 isolate());
1099 if (boilerplate_value->IsJSObject()) { 1100 if (boilerplate_value->IsJSObject()) {
1100 Handle<JSObject> boilerplate_object = 1101 Handle<JSObject> boilerplate_object =
1101 Handle<JSObject>::cast(boilerplate_value); 1102 Handle<JSObject>::cast(boilerplate_value);
1102 Handle<AllocationSite> current_site = site_context->EnterNewScope(); 1103 Handle<AllocationSite> current_site = site_context->EnterNewScope();
1103 value = effect = AllocateFastLiteral(effect, control, 1104 value = effect = AllocateFastLiteral(effect, control,
1104 boilerplate_object, site_context); 1105 boilerplate_object, site_context);
1105 site_context->ExitScope(current_site, boilerplate_object); 1106 site_context->ExitScope(current_site, boilerplate_object);
1106 } else if (property_details.representation().IsDouble()) { 1107 } else if (property_details.representation().IsDouble()) {
1108 double number = Handle<HeapNumber>::cast(boilerplate_value)->value();
1107 // Allocate a mutable HeapNumber box and store the value into it. 1109 // Allocate a mutable HeapNumber box and store the value into it.
1108 effect = graph()->NewNode( 1110 AllocationBuilder builder(jsgraph(), effect, control);
1109 common()->BeginRegion(RegionObservability::kNotObservable), effect); 1111 builder.Allocate(HeapNumber::kSize, pretenure);
1110 value = effect = graph()->NewNode( 1112 builder.Store(AccessBuilder::ForMap(),
1111 simplified()->Allocate(pretenure), 1113 factory()->mutable_heap_number_map());
1112 jsgraph()->Constant(HeapNumber::kSize), effect, control); 1114 builder.Store(AccessBuilder::ForHeapNumberValue(),
1113 effect = graph()->NewNode( 1115 jsgraph()->Constant(number));
1114 simplified()->StoreField(AccessBuilder::ForMap()), value, 1116 value = effect = builder.Finish();
1115 jsgraph()->HeapConstant(factory()->mutable_heap_number_map()),
1116 effect, control);
1117 effect = graph()->NewNode(
1118 simplified()->StoreField(AccessBuilder::ForHeapNumberValue()),
1119 value, jsgraph()->Constant(
1120 Handle<HeapNumber>::cast(boilerplate_value)->value()),
1121 effect, control);
1122 value = effect =
1123 graph()->NewNode(common()->FinishRegion(), value, effect);
1124 } else if (property_details.representation().IsSmi()) { 1117 } else if (property_details.representation().IsSmi()) {
1125 // Ensure that value is stored as smi. 1118 // Ensure that value is stored as smi.
1126 value = boilerplate_value->IsUninitialized(isolate()) 1119 value = boilerplate_value->IsUninitialized(isolate())
1127 ? jsgraph()->ZeroConstant() 1120 ? jsgraph()->ZeroConstant()
1128 : jsgraph()->Constant(boilerplate_value); 1121 : jsgraph()->Constant(boilerplate_value);
1129 } else { 1122 } else {
1130 value = jsgraph()->Constant(boilerplate_value); 1123 value = jsgraph()->Constant(boilerplate_value);
1131 } 1124 }
1132 } 1125 }
1133 inobject_fields.push_back(std::make_pair(access, value)); 1126 inobject_fields.push_back(std::make_pair(access, value));
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 return jsgraph()->simplified(); 1277 return jsgraph()->simplified();
1285 } 1278 }
1286 1279
1287 MachineOperatorBuilder* JSCreateLowering::machine() const { 1280 MachineOperatorBuilder* JSCreateLowering::machine() const {
1288 return jsgraph()->machine(); 1281 return jsgraph()->machine();
1289 } 1282 }
1290 1283
1291 } // namespace compiler 1284 } // namespace compiler
1292 } // namespace internal 1285 } // namespace internal
1293 } // namespace v8 1286 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698