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

Side by Side Diff: src/hydrogen.cc

Issue 368263003: Use a stub in crankshaft for grow store arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase. Created 6 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 | « src/hydrogen.h ('k') | src/hydrogen-instructions.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 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 HConstant::cast(function)->handle(isolate())->IsJSFunction()) { 1290 HConstant::cast(function)->handle(isolate())->IsJSFunction()) {
1291 Handle<JSFunction> f = Handle<JSFunction>::cast( 1291 Handle<JSFunction> f = Handle<JSFunction>::cast(
1292 HConstant::cast(function)->handle(isolate())); 1292 HConstant::cast(function)->handle(isolate()));
1293 SharedFunctionInfo* shared = f->shared(); 1293 SharedFunctionInfo* shared = f->shared();
1294 if (shared->strict_mode() == STRICT || shared->native()) return object; 1294 if (shared->strict_mode() == STRICT || shared->native()) return object;
1295 } 1295 }
1296 return Add<HWrapReceiver>(object, function); 1296 return Add<HWrapReceiver>(object, function);
1297 } 1297 }
1298 1298
1299 1299
1300 HValue* HGraphBuilder::BuildCheckAndGrowElementsCapacity(
1301 HValue* object, HValue* elements, ElementsKind kind, HValue* length,
1302 HValue* capacity, HValue* key) {
1303 HValue* max_gap = Add<HConstant>(static_cast<int32_t>(JSObject::kMaxGap));
1304 HValue* max_capacity = AddUncasted<HAdd>(capacity, max_gap);
1305 Add<HBoundsCheck>(key, max_capacity);
1306
1307 HValue* new_capacity = BuildNewElementsCapacity(key);
1308 HValue* new_elements = BuildGrowElementsCapacity(object, elements, kind, kind,
1309 length, new_capacity);
1310 return new_elements;
1311 }
1312
1313
1300 HValue* HGraphBuilder::BuildCheckForCapacityGrow( 1314 HValue* HGraphBuilder::BuildCheckForCapacityGrow(
1301 HValue* object, 1315 HValue* object,
1302 HValue* elements, 1316 HValue* elements,
1303 ElementsKind kind, 1317 ElementsKind kind,
1304 HValue* length, 1318 HValue* length,
1305 HValue* key, 1319 HValue* key,
1306 bool is_js_array, 1320 bool is_js_array,
1307 PropertyAccessType access_type) { 1321 PropertyAccessType access_type) {
1308 IfBuilder length_checker(this); 1322 IfBuilder length_checker(this);
1309 1323
1310 Token::Value token = IsHoleyElementsKind(kind) ? Token::GTE : Token::EQ; 1324 Token::Value token = IsHoleyElementsKind(kind) ? Token::GTE : Token::EQ;
1311 length_checker.If<HCompareNumericAndBranch>(key, length, token); 1325 length_checker.If<HCompareNumericAndBranch>(key, length, token);
1312 1326
1313 length_checker.Then(); 1327 length_checker.Then();
1314 1328
1315 HValue* current_capacity = AddLoadFixedArrayLength(elements); 1329 HValue* current_capacity = AddLoadFixedArrayLength(elements);
1316 1330
1317 IfBuilder capacity_checker(this); 1331 IfBuilder capacity_checker(this);
1318 1332
1319 capacity_checker.If<HCompareNumericAndBranch>(key, current_capacity, 1333 capacity_checker.If<HCompareNumericAndBranch>(key, current_capacity,
1320 Token::GTE); 1334 Token::GTE);
1321 capacity_checker.Then(); 1335 capacity_checker.Then();
1322 1336
1323 HValue* max_gap = Add<HConstant>(static_cast<int32_t>(JSObject::kMaxGap)); 1337 // BuildCheckAndGrowElementsCapacity could de-opt without profitable feedback,
1324 HValue* max_capacity = AddUncasted<HAdd>(current_capacity, max_gap); 1338 // therefore we defer calling it to a stub in optimized functions. It is
1339 // okay to call directly in a code stub though, because a bailout to the
1340 // runtime is tolerable in the corner cases.
1341 if (top_info()->IsStub()) {
1342 environment()->Push(BuildCheckAndGrowElementsCapacity(
1343 object, elements, kind, length, current_capacity, key));
1344 } else {
1345 GrowArrayElementsStub stub(isolate(), is_js_array, kind);
1346 GrowArrayElementsDescriptor descriptor(isolate());
1347 HConstant* target = Add<HConstant>(stub.GetCode());
1348 HValue* op_vals[] = {context(), object, key, current_capacity};
1349 HValue* new_elements = Add<HCallWithDescriptor>(
1350 target, 0, descriptor, Vector<HValue*>(op_vals, 4));
1351 // If the object changed to a dictionary, GrowArrayElements will return a
1352 // smi to signal that deopt is required.
1353 Add<HCheckHeapObject>(new_elements);
1354 environment()->Push(new_elements);
1355 }
1325 1356
1326 Add<HBoundsCheck>(key, max_capacity);
1327
1328 HValue* new_capacity = BuildNewElementsCapacity(key);
1329 HValue* new_elements = BuildGrowElementsCapacity(object, elements,
1330 kind, kind, length,
1331 new_capacity);
1332
1333 environment()->Push(new_elements);
1334 capacity_checker.Else(); 1357 capacity_checker.Else();
1335 1358
1336 environment()->Push(elements); 1359 environment()->Push(elements);
1337 capacity_checker.End(); 1360 capacity_checker.End();
1338 1361
1339 if (is_js_array) { 1362 if (is_js_array) {
1340 HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1()); 1363 HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1());
1341 new_length->ClearFlag(HValue::kCanOverflow); 1364 new_length->ClearFlag(HValue::kCanOverflow);
1342 1365
1343 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind), 1366 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind),
(...skipping 11389 matching lines...) Expand 10 before | Expand all | Expand 10 after
12733 if (ShouldProduceTraceOutput()) { 12756 if (ShouldProduceTraceOutput()) {
12734 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 12757 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
12735 } 12758 }
12736 12759
12737 #ifdef DEBUG 12760 #ifdef DEBUG
12738 graph_->Verify(false); // No full verify. 12761 graph_->Verify(false); // No full verify.
12739 #endif 12762 #endif
12740 } 12763 }
12741 12764
12742 } } // namespace v8::internal 12765 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698