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

Side by Side Diff: src/heap.cc

Issue 32323013: Introduce JSFunction::EnsureHasInitialMap method. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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/objects.h » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4588 matching lines...) Expand 10 before | Expand all | Expand 10 after
4599 4599
4600 // Initialize the JSObject. 4600 // Initialize the JSObject.
4601 InitializeJSObjectFromMap(JSObject::cast(obj), properties, map); 4601 InitializeJSObjectFromMap(JSObject::cast(obj), properties, map);
4602 ASSERT(JSObject::cast(obj)->HasFastElements()); 4602 ASSERT(JSObject::cast(obj)->HasFastElements());
4603 return obj; 4603 return obj;
4604 } 4604 }
4605 4605
4606 4606
4607 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor, 4607 MaybeObject* Heap::AllocateJSObject(JSFunction* constructor,
4608 PretenureFlag pretenure) { 4608 PretenureFlag pretenure) {
4609 // Allocate the initial map if absent. 4609 ASSERT(constructor->has_initial_map());
4610 if (!constructor->has_initial_map()) {
4611 Object* initial_map;
4612 { MaybeObject* maybe_initial_map = AllocateInitialMap(constructor);
4613 if (!maybe_initial_map->ToObject(&initial_map)) return maybe_initial_map;
4614 }
4615 constructor->set_initial_map(Map::cast(initial_map));
4616 Map::cast(initial_map)->set_constructor(constructor);
4617 }
4618 // Allocate the object based on the constructors initial map. 4610 // Allocate the object based on the constructors initial map.
4619 MaybeObject* result = AllocateJSObjectFromMap( 4611 MaybeObject* result = AllocateJSObjectFromMap(
4620 constructor->initial_map(), pretenure); 4612 constructor->initial_map(), pretenure);
4621 #ifdef DEBUG 4613 #ifdef DEBUG
4622 // Make sure result is NOT a global object if valid. 4614 // Make sure result is NOT a global object if valid.
4623 Object* non_failure; 4615 Object* non_failure;
4624 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject()); 4616 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject());
4625 #endif 4617 #endif
4626 return result; 4618 return result;
4627 } 4619 }
4628 4620
4629 4621
4630 MaybeObject* Heap::AllocateJSObjectWithAllocationSite(JSFunction* constructor, 4622 MaybeObject* Heap::AllocateJSObjectWithAllocationSite(JSFunction* constructor,
4631 Handle<AllocationSite> allocation_site) { 4623 Handle<AllocationSite> allocation_site) {
4632 // Allocate the initial map if absent. 4624 ASSERT(constructor->has_initial_map());
4633 if (!constructor->has_initial_map()) {
4634 Object* initial_map;
4635 { MaybeObject* maybe_initial_map = AllocateInitialMap(constructor);
4636 if (!maybe_initial_map->ToObject(&initial_map)) return maybe_initial_map;
4637 }
4638 constructor->set_initial_map(Map::cast(initial_map));
4639 Map::cast(initial_map)->set_constructor(constructor);
4640 }
4641 // Allocate the object based on the constructors initial map, or the payload 4625 // Allocate the object based on the constructors initial map, or the payload
4642 // advice 4626 // advice
4643 Map* initial_map = constructor->initial_map(); 4627 Map* initial_map = constructor->initial_map();
4644 4628
4645 Smi* smi = Smi::cast(allocation_site->transition_info()); 4629 Smi* smi = Smi::cast(allocation_site->transition_info());
4646 ElementsKind to_kind = static_cast<ElementsKind>(smi->value()); 4630 ElementsKind to_kind = static_cast<ElementsKind>(smi->value());
4647 AllocationSiteMode mode = TRACK_ALLOCATION_SITE; 4631 AllocationSiteMode mode = TRACK_ALLOCATION_SITE;
4648 if (to_kind != initial_map->elements_kind()) { 4632 if (to_kind != initial_map->elements_kind()) {
4649 MaybeObject* maybe_new_map = initial_map->AsElementsKind(to_kind); 4633 MaybeObject* maybe_new_map = initial_map->AsElementsKind(to_kind);
4650 if (!maybe_new_map->To(&initial_map)) return maybe_new_map; 4634 if (!maybe_new_map->To(&initial_map)) return maybe_new_map;
(...skipping 11 matching lines...) Expand all
4662 } 4646 }
4663 #ifdef DEBUG 4647 #ifdef DEBUG
4664 // Make sure result is NOT a global object if valid. 4648 // Make sure result is NOT a global object if valid.
4665 Object* non_failure; 4649 Object* non_failure;
4666 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject()); 4650 ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject());
4667 #endif 4651 #endif
4668 return result; 4652 return result;
4669 } 4653 }
4670 4654
4671 4655
4672 MaybeObject* Heap::AllocateJSGeneratorObject(JSFunction *function) {
4673 ASSERT(function->shared()->is_generator());
4674 Map *map;
4675 if (function->has_initial_map()) {
4676 map = function->initial_map();
4677 } else {
4678 // Allocate the initial map if absent.
4679 MaybeObject* maybe_map = AllocateInitialMap(function);
4680 if (!maybe_map->To(&map)) return maybe_map;
4681 function->set_initial_map(map);
4682 map->set_constructor(function);
4683 }
4684 ASSERT(map->instance_type() == JS_GENERATOR_OBJECT_TYPE);
4685 return AllocateJSObjectFromMap(map);
4686 }
4687
4688
4689 MaybeObject* Heap::AllocateJSModule(Context* context, ScopeInfo* scope_info) { 4656 MaybeObject* Heap::AllocateJSModule(Context* context, ScopeInfo* scope_info) {
4690 // Allocate a fresh map. Modules do not have a prototype. 4657 // Allocate a fresh map. Modules do not have a prototype.
4691 Map* map; 4658 Map* map;
4692 MaybeObject* maybe_map = AllocateMap(JS_MODULE_TYPE, JSModule::kSize); 4659 MaybeObject* maybe_map = AllocateMap(JS_MODULE_TYPE, JSModule::kSize);
4693 if (!maybe_map->To(&map)) return maybe_map; 4660 if (!maybe_map->To(&map)) return maybe_map;
4694 // Allocate the object based on the map. 4661 // Allocate the object based on the map.
4695 JSModule* module; 4662 JSModule* module;
4696 MaybeObject* maybe_module = AllocateJSObjectFromMap(map, TENURED); 4663 MaybeObject* maybe_module = AllocateJSObjectFromMap(map, TENURED);
4697 if (!maybe_module->To(&module)) return maybe_module; 4664 if (!maybe_module->To(&module)) return maybe_module;
4698 module->set_context(context); 4665 module->set_context(context);
(...skipping 3240 matching lines...) Expand 10 before | Expand all | Expand 10 after
7939 if (FLAG_concurrent_recompilation) { 7906 if (FLAG_concurrent_recompilation) {
7940 heap_->relocation_mutex_->Lock(); 7907 heap_->relocation_mutex_->Lock();
7941 #ifdef DEBUG 7908 #ifdef DEBUG
7942 heap_->relocation_mutex_locked_by_optimizer_thread_ = 7909 heap_->relocation_mutex_locked_by_optimizer_thread_ =
7943 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); 7910 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread();
7944 #endif // DEBUG 7911 #endif // DEBUG
7945 } 7912 }
7946 } 7913 }
7947 7914
7948 } } // namespace v8::internal 7915 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698