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

Side by Side Diff: src/hydrogen.cc

Issue 308003015: Ensure that constant-capacity elements are initialized on copy (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
« 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 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 "hydrogen.h" 5 #include "hydrogen.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "v8.h" 9 #include "v8.h"
10 #include "allocation-site-scopes.h" 10 #include "allocation-site-scopes.h"
(...skipping 2518 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 int constant_capacity = -1; 2529 int constant_capacity = -1;
2530 if (capacity != NULL && 2530 if (capacity != NULL &&
2531 capacity->IsConstant() && 2531 capacity->IsConstant() &&
2532 HConstant::cast(capacity)->HasInteger32Value()) { 2532 HConstant::cast(capacity)->HasInteger32Value()) {
2533 int constant_candidate = HConstant::cast(capacity)->Integer32Value(); 2533 int constant_candidate = HConstant::cast(capacity)->Integer32Value();
2534 if (constant_candidate <= kElementLoopUnrollThreshold) { 2534 if (constant_candidate <= kElementLoopUnrollThreshold) {
2535 constant_capacity = constant_candidate; 2535 constant_capacity = constant_candidate;
2536 } 2536 }
2537 } 2537 }
2538 2538
2539 bool pre_fill_with_holes =
2540 IsFastDoubleElementsKind(from_elements_kind) &&
2541 IsFastObjectElementsKind(to_elements_kind);
2542 if (pre_fill_with_holes) {
2543 // If the copy might trigger a GC, make sure that the FixedArray is
2544 // pre-initialized with holes to make sure that it's always in a
2545 // consistent state.
2546 BuildFillElementsWithHole(to_elements, to_elements_kind,
2547 graph()->GetConstant0(), NULL);
2548 }
2549
2539 if (constant_capacity != -1) { 2550 if (constant_capacity != -1) {
2540 // Unroll the loop for small elements kinds. 2551 // Unroll the loop for small elements kinds.
2541 for (int i = 0; i < constant_capacity; i++) { 2552 for (int i = 0; i < constant_capacity; i++) {
2542 HValue* key_constant = Add<HConstant>(i); 2553 HValue* key_constant = Add<HConstant>(i);
2543 HInstruction* value = Add<HLoadKeyed>(from_elements, key_constant, 2554 HInstruction* value = Add<HLoadKeyed>(from_elements, key_constant,
2544 static_cast<HValue*>(NULL), 2555 static_cast<HValue*>(NULL),
2545 from_elements_kind); 2556 from_elements_kind);
2546 Add<HStoreKeyed>(to_elements, key_constant, value, to_elements_kind); 2557 Add<HStoreKeyed>(to_elements, key_constant, value, to_elements_kind);
2547 } 2558 }
2548 } else { 2559 } else {
2549 bool pre_fill_with_holes = 2560 if (!pre_fill_with_holes &&
2550 IsFastDoubleElementsKind(from_elements_kind) && 2561 (capacity == NULL || !length->Equals(capacity))) {
2551 IsFastObjectElementsKind(to_elements_kind);
2552
2553 if (pre_fill_with_holes) {
2554 // If the copy might trigger a GC, make sure that the FixedArray is
2555 // pre-initialized with holes to make sure that it's always in a
2556 // consistent state.
2557 BuildFillElementsWithHole(to_elements, to_elements_kind,
2558 graph()->GetConstant0(), NULL);
2559 } else if (capacity == NULL || !length->Equals(capacity)) {
2560 BuildFillElementsWithHole(to_elements, to_elements_kind, 2562 BuildFillElementsWithHole(to_elements, to_elements_kind,
2561 length, NULL); 2563 length, NULL);
2562 } 2564 }
2563 2565
2564 if (capacity == NULL) { 2566 if (capacity == NULL) {
2565 capacity = AddLoadFixedArrayLength(to_elements); 2567 capacity = AddLoadFixedArrayLength(to_elements);
2566 } 2568 }
2567 2569
2568 LoopBuilder builder(this, context(), LoopBuilder::kPostDecrement); 2570 LoopBuilder builder(this, context(), LoopBuilder::kPostDecrement);
2569 2571
(...skipping 9306 matching lines...) Expand 10 before | Expand all | Expand 10 after
11876 if (ShouldProduceTraceOutput()) { 11878 if (ShouldProduceTraceOutput()) {
11877 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 11879 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
11878 } 11880 }
11879 11881
11880 #ifdef DEBUG 11882 #ifdef DEBUG
11881 graph_->Verify(false); // No full verify. 11883 graph_->Verify(false); // No full verify.
11882 #endif 11884 #endif
11883 } 11885 }
11884 11886
11885 } } // namespace v8::internal 11887 } } // namespace v8::internal
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