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

Side by Side Diff: src/crankshaft/hydrogen.cc

Issue 2304573004: Port FastCloneShallowArrayStub to Turbofan (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cleanup mode a bit Created 4 years, 3 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
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/crankshaft/hydrogen.h" 5 #include "src/crankshaft/hydrogen.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 3250 matching lines...) Expand 10 before | Expand all | Expand 10 after
3261 store->SetFlag(HValue::kAllowUndefinedAsNaN); 3261 store->SetFlag(HValue::kAllowUndefinedAsNaN);
3262 } 3262 }
3263 3263
3264 builder.EndBody(); 3264 builder.EndBody();
3265 } 3265 }
3266 3266
3267 Counters* counters = isolate()->counters(); 3267 Counters* counters = isolate()->counters();
3268 AddIncrementCounter(counters->inlined_copied_elements()); 3268 AddIncrementCounter(counters->inlined_copied_elements());
3269 } 3269 }
3270 3270
3271
3272 HValue* HGraphBuilder::BuildCloneShallowArrayCow(HValue* boilerplate,
3273 HValue* allocation_site,
3274 AllocationSiteMode mode,
3275 ElementsKind kind) {
3276 HAllocate* array = AllocateJSArrayObject(mode);
3277
3278 HValue* map = AddLoadMap(boilerplate);
3279 HValue* elements = AddLoadElements(boilerplate);
3280 HValue* length = AddLoadArrayLength(boilerplate, kind);
3281
3282 BuildJSArrayHeader(array,
3283 map,
3284 elements,
3285 mode,
3286 FAST_ELEMENTS,
3287 allocation_site,
3288 length);
3289 return array;
3290 }
3291
3292
3293 HValue* HGraphBuilder::BuildCloneShallowArrayEmpty(HValue* boilerplate,
3294 HValue* allocation_site,
3295 AllocationSiteMode mode) {
3296 HAllocate* array = AllocateJSArrayObject(mode);
3297
3298 HValue* map = AddLoadMap(boilerplate);
3299
3300 BuildJSArrayHeader(array,
3301 map,
3302 NULL, // set elements to empty fixed array
3303 mode,
3304 FAST_ELEMENTS,
3305 allocation_site,
3306 graph()->GetConstant0());
3307 return array;
3308 }
3309
3310
3311 HValue* HGraphBuilder::BuildCloneShallowArrayNonEmpty(HValue* boilerplate,
3312 HValue* allocation_site,
3313 AllocationSiteMode mode,
3314 ElementsKind kind) {
3315 HValue* boilerplate_elements = AddLoadElements(boilerplate);
3316 HValue* capacity = AddLoadFixedArrayLength(boilerplate_elements);
3317
3318 // Generate size calculation code here in order to make it dominate
3319 // the JSArray allocation.
3320 HValue* elements_size = BuildCalculateElementsSize(kind, capacity);
3321
3322 // Create empty JSArray object for now, store elimination should remove
3323 // redundant initialization of elements and length fields and at the same
3324 // time the object will be fully prepared for GC if it happens during
3325 // elements allocation.
3326 HValue* result = BuildCloneShallowArrayEmpty(
3327 boilerplate, allocation_site, mode);
3328
3329 HAllocate* elements = BuildAllocateElements(kind, elements_size);
3330
3331 Add<HStoreNamedField>(result, HObjectAccess::ForElementsPointer(), elements);
3332
3333 // The allocation for the cloned array above causes register pressure on
3334 // machines with low register counts. Force a reload of the boilerplate
3335 // elements here to free up a register for the allocation to avoid unnecessary
3336 // spillage.
3337 boilerplate_elements = AddLoadElements(boilerplate);
3338 boilerplate_elements->SetFlag(HValue::kCantBeReplaced);
3339
3340 // Copy the elements array header.
3341 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) {
3342 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i);
3343 Add<HStoreNamedField>(
3344 elements, access,
3345 Add<HLoadNamedField>(boilerplate_elements, nullptr, access));
3346 }
3347
3348 // And the result of the length
3349 HValue* length = AddLoadArrayLength(boilerplate, kind);
3350 Add<HStoreNamedField>(result, HObjectAccess::ForArrayLength(kind), length);
3351
3352 BuildCopyElements(boilerplate_elements, kind, elements,
3353 kind, length, NULL);
3354 return result;
3355 }
3356
3357
3358 void HGraphBuilder::BuildCreateAllocationMemento( 3271 void HGraphBuilder::BuildCreateAllocationMemento(
3359 HValue* previous_object, 3272 HValue* previous_object,
3360 HValue* previous_object_size, 3273 HValue* previous_object_size,
3361 HValue* allocation_site) { 3274 HValue* allocation_site) {
3362 DCHECK(allocation_site != NULL); 3275 DCHECK(allocation_site != NULL);
3363 HInnerAllocatedObject* allocation_memento = Add<HInnerAllocatedObject>( 3276 HInnerAllocatedObject* allocation_memento = Add<HInnerAllocatedObject>(
3364 previous_object, previous_object_size, HType::HeapObject()); 3277 previous_object, previous_object_size, HType::HeapObject());
3365 AddStoreMapConstant( 3278 AddStoreMapConstant(
3366 allocation_memento, isolate()->factory()->allocation_memento_map()); 3279 allocation_memento, isolate()->factory()->allocation_memento_map());
3367 Add<HStoreNamedField>( 3280 Add<HStoreNamedField>(
(...skipping 10017 matching lines...) Expand 10 before | Expand all | Expand 10 after
13385 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13298 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13386 } 13299 }
13387 13300
13388 #ifdef DEBUG 13301 #ifdef DEBUG
13389 graph_->Verify(false); // No full verify. 13302 graph_->Verify(false); // No full verify.
13390 #endif 13303 #endif
13391 } 13304 }
13392 13305
13393 } // namespace internal 13306 } // namespace internal
13394 } // namespace v8 13307 } // namespace v8
OLDNEW
« src/code-stubs.cc ('K') | « src/crankshaft/hydrogen.h ('k') | src/deoptimize-reason.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698