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

Side by Side Diff: src/hydrogen.cc

Issue 1109333003: Use a stub in crankshaft for grow store arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix ARM failure. Created 5 years, 7 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
« no previous file with comments | « src/hydrogen.h ('k') | src/ia32/interface-descriptors-ia32.cc » ('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 // 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 <sstream> 7 #include <sstream>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 HConstant::cast(function)->handle(isolate())->IsJSFunction()) { 1293 HConstant::cast(function)->handle(isolate())->IsJSFunction()) {
1294 Handle<JSFunction> f = Handle<JSFunction>::cast( 1294 Handle<JSFunction> f = Handle<JSFunction>::cast(
1295 HConstant::cast(function)->handle(isolate())); 1295 HConstant::cast(function)->handle(isolate()));
1296 SharedFunctionInfo* shared = f->shared(); 1296 SharedFunctionInfo* shared = f->shared();
1297 if (is_strict(shared->language_mode()) || shared->native()) return object; 1297 if (is_strict(shared->language_mode()) || shared->native()) return object;
1298 } 1298 }
1299 return Add<HWrapReceiver>(object, function); 1299 return Add<HWrapReceiver>(object, function);
1300 } 1300 }
1301 1301
1302 1302
1303 HValue* HGraphBuilder::BuildCheckAndGrowElementsCapacity(
1304 HValue* object, HValue* elements, ElementsKind kind, HValue* length,
1305 HValue* capacity, HValue* key) {
1306 HValue* max_gap = Add<HConstant>(static_cast<int32_t>(JSObject::kMaxGap));
1307 HValue* max_capacity = AddUncasted<HAdd>(capacity, max_gap);
1308 Add<HBoundsCheck>(key, max_capacity);
1309
1310 HValue* new_capacity = BuildNewElementsCapacity(key);
1311 HValue* new_elements = BuildGrowElementsCapacity(object, elements, kind, kind,
1312 length, new_capacity);
1313 return new_elements;
1314 }
1315
1316
1303 HValue* HGraphBuilder::BuildCheckForCapacityGrow( 1317 HValue* HGraphBuilder::BuildCheckForCapacityGrow(
1304 HValue* object, 1318 HValue* object,
1305 HValue* elements, 1319 HValue* elements,
1306 ElementsKind kind, 1320 ElementsKind kind,
1307 HValue* length, 1321 HValue* length,
1308 HValue* key, 1322 HValue* key,
1309 bool is_js_array, 1323 bool is_js_array,
1310 PropertyAccessType access_type) { 1324 PropertyAccessType access_type) {
1311 IfBuilder length_checker(this); 1325 IfBuilder length_checker(this);
1312 1326
1313 Token::Value token = IsHoleyElementsKind(kind) ? Token::GTE : Token::EQ; 1327 Token::Value token = IsHoleyElementsKind(kind) ? Token::GTE : Token::EQ;
1314 length_checker.If<HCompareNumericAndBranch>(key, length, token); 1328 length_checker.If<HCompareNumericAndBranch>(key, length, token);
1315 1329
1316 length_checker.Then(); 1330 length_checker.Then();
1317 1331
1318 HValue* current_capacity = AddLoadFixedArrayLength(elements); 1332 HValue* current_capacity = AddLoadFixedArrayLength(elements);
1319 1333
1320 IfBuilder capacity_checker(this); 1334 IfBuilder capacity_checker(this);
1321 1335
1322 capacity_checker.If<HCompareNumericAndBranch>(key, current_capacity, 1336 capacity_checker.If<HCompareNumericAndBranch>(key, current_capacity,
1323 Token::GTE); 1337 Token::GTE);
1324 capacity_checker.Then(); 1338 capacity_checker.Then();
1325 1339
1326 HValue* max_gap = Add<HConstant>(static_cast<int32_t>(JSObject::kMaxGap)); 1340 // BuildCheckAndGrowElementsCapacity could de-opt without profitable feedback
1327 HValue* max_capacity = AddUncasted<HAdd>(current_capacity, max_gap); 1341 // therefore we defer calling it to a stub in optimized functions. It is
1342 // okay to call directly in a code stub though, because a bailout to the
1343 // runtime is tolerable in the corner cases.
1344 if (top_info()->IsStub()) {
1345 HValue* new_elements = BuildCheckAndGrowElementsCapacity(
1346 object, elements, kind, length, current_capacity, key);
1347 environment()->Push(new_elements);
1348 } else {
1349 GrowArrayElementsStub stub(isolate(), is_js_array, kind);
1350 GrowArrayElementsDescriptor descriptor(isolate());
1351 HConstant* target = Add<HConstant>(stub.GetCode());
1352 HValue* op_vals[] = {context(), object, key, current_capacity};
1353 HValue* new_elements = Add<HCallWithDescriptor>(
1354 target, 0, descriptor, Vector<HValue*>(op_vals, 4));
1355 // If the object changed to a dictionary, GrowArrayElements will return a
1356 // smi to signal that deopt is required.
1357 Add<HCheckHeapObject>(new_elements);
1358 environment()->Push(new_elements);
1359 }
1328 1360
1329 Add<HBoundsCheck>(key, max_capacity);
1330
1331 HValue* new_capacity = BuildNewElementsCapacity(key);
1332 HValue* new_elements = BuildGrowElementsCapacity(object, elements,
1333 kind, kind, length,
1334 new_capacity);
1335
1336 environment()->Push(new_elements);
1337 capacity_checker.Else(); 1361 capacity_checker.Else();
1338 1362
1339 environment()->Push(elements); 1363 environment()->Push(elements);
1340 capacity_checker.End(); 1364 capacity_checker.End();
1341 1365
1342 if (is_js_array) { 1366 if (is_js_array) {
1343 HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1()); 1367 HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1());
1344 new_length->ClearFlag(HValue::kCanOverflow); 1368 new_length->ClearFlag(HValue::kCanOverflow);
1345 1369
1346 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind), 1370 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind),
(...skipping 11759 matching lines...) Expand 10 before | Expand all | Expand 10 after
13106 if (ShouldProduceTraceOutput()) { 13130 if (ShouldProduceTraceOutput()) {
13107 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13131 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13108 } 13132 }
13109 13133
13110 #ifdef DEBUG 13134 #ifdef DEBUG
13111 graph_->Verify(false); // No full verify. 13135 graph_->Verify(false); // No full verify.
13112 #endif 13136 #endif
13113 } 13137 }
13114 13138
13115 } } // namespace v8::internal 13139 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/ia32/interface-descriptors-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698