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

Side by Side Diff: src/heap.cc

Issue 371913002: Revert "Only create arguments-maps in the bootstrapper, remove now obsolete ValueType flag." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 | « src/heap.h ('k') | src/ia32/code-stubs-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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/once.h" 9 #include "src/base/once.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
(...skipping 3551 matching lines...) Expand 10 before | Expand all | Expand 10 after
3562 result->set_map_no_write_barrier(map); 3562 result->set_map_no_write_barrier(map);
3563 if (allocation_site != NULL) { 3563 if (allocation_site != NULL) {
3564 AllocationMemento* alloc_memento = reinterpret_cast<AllocationMemento*>( 3564 AllocationMemento* alloc_memento = reinterpret_cast<AllocationMemento*>(
3565 reinterpret_cast<Address>(result) + map->instance_size()); 3565 reinterpret_cast<Address>(result) + map->instance_size());
3566 InitializeAllocationMemento(alloc_memento, allocation_site); 3566 InitializeAllocationMemento(alloc_memento, allocation_site);
3567 } 3567 }
3568 return result; 3568 return result;
3569 } 3569 }
3570 3570
3571 3571
3572 AllocationResult Heap::AllocateArgumentsObject(Object* callee, int length) {
3573 // To get fast allocation and map sharing for arguments objects we
3574 // allocate them based on an arguments boilerplate.
3575
3576 JSObject* boilerplate;
3577 int arguments_object_size;
3578 bool strict_mode_callee = callee->IsJSFunction() &&
3579 JSFunction::cast(callee)->shared()->strict_mode() == STRICT;
3580 if (strict_mode_callee) {
3581 boilerplate =
3582 isolate()->context()->native_context()->strict_arguments_boilerplate();
3583 arguments_object_size = kStrictArgumentsObjectSize;
3584 } else {
3585 boilerplate =
3586 isolate()->context()->native_context()->sloppy_arguments_boilerplate();
3587 arguments_object_size = kSloppyArgumentsObjectSize;
3588 }
3589
3590 // Check that the size of the boilerplate matches our
3591 // expectations. The ArgumentsAccessStub::GenerateNewObject relies
3592 // on the size being a known constant.
3593 ASSERT(arguments_object_size == boilerplate->map()->instance_size());
3594
3595 // Do the allocation.
3596 HeapObject* result;
3597 { AllocationResult allocation =
3598 AllocateRaw(arguments_object_size, NEW_SPACE, OLD_POINTER_SPACE);
3599 if (!allocation.To(&result)) return allocation;
3600 }
3601
3602 // Copy the content. The arguments boilerplate doesn't have any
3603 // fields that point to new space so it's safe to skip the write
3604 // barrier here.
3605 CopyBlock(result->address(), boilerplate->address(), JSObject::kHeaderSize);
3606
3607 // Set the length property.
3608 JSObject* js_obj = JSObject::cast(result);
3609 js_obj->InObjectPropertyAtPut(
3610 kArgumentsLengthIndex, Smi::FromInt(length), SKIP_WRITE_BARRIER);
3611 // Set the callee property for sloppy mode arguments object only.
3612 if (!strict_mode_callee) {
3613 js_obj->InObjectPropertyAtPut(kArgumentsCalleeIndex, callee);
3614 }
3615
3616 // Check the state of the object
3617 ASSERT(js_obj->HasFastProperties());
3618 ASSERT(js_obj->HasFastObjectElements());
3619
3620 return js_obj;
3621 }
3622
3623
3572 void Heap::InitializeJSObjectFromMap(JSObject* obj, 3624 void Heap::InitializeJSObjectFromMap(JSObject* obj,
3573 FixedArray* properties, 3625 FixedArray* properties,
3574 Map* map) { 3626 Map* map) {
3575 obj->set_properties(properties); 3627 obj->set_properties(properties);
3576 obj->initialize_elements(); 3628 obj->initialize_elements();
3577 // TODO(1240798): Initialize the object's body using valid initial values 3629 // TODO(1240798): Initialize the object's body using valid initial values
3578 // according to the object's initial map. For example, if the map's 3630 // according to the object's initial map. For example, if the map's
3579 // instance type is JS_ARRAY_TYPE, the length field should be initialized 3631 // instance type is JS_ARRAY_TYPE, the length field should be initialized
3580 // to a number (e.g. Smi::FromInt(0)) and the elements initialized to a 3632 // to a number (e.g. Smi::FromInt(0)) and the elements initialized to a
3581 // fixed array (e.g. Heap::empty_fixed_array()). Currently, the object 3633 // fixed array (e.g. Heap::empty_fixed_array()). Currently, the object
(...skipping 2829 matching lines...) Expand 10 before | Expand all | Expand 10 after
6411 static_cast<int>(object_sizes_last_time_[index])); 6463 static_cast<int>(object_sizes_last_time_[index]));
6412 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6464 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6413 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6465 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6414 6466
6415 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6467 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6416 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6468 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6417 ClearObjectStats(); 6469 ClearObjectStats();
6418 } 6470 }
6419 6471
6420 } } // namespace v8::internal 6472 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698