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

Side by Side Diff: runtime/vm/object.cc

Issue 2821233005: Allow signature functions to be allocated in new space. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « runtime/vm/object.h ('k') | 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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/become.h" 10 #include "vm/become.h"
(...skipping 6458 matching lines...) Expand 10 before | Expand all | Expand 10 after
6469 return true; 6469 return true;
6470 } 6470 }
6471 6471
6472 6472
6473 RawFunction* Function::InstantiateSignatureFrom( 6473 RawFunction* Function::InstantiateSignatureFrom(
6474 const TypeArguments& instantiator_type_arguments, 6474 const TypeArguments& instantiator_type_arguments,
6475 const TypeArguments& function_type_arguments, 6475 const TypeArguments& function_type_arguments,
6476 Heap::Space space) const { 6476 Heap::Space space) const {
6477 Zone* zone = Thread::Current()->zone(); 6477 Zone* zone = Thread::Current()->zone();
6478 const Object& owner = Object::Handle(zone, RawOwner()); 6478 const Object& owner = Object::Handle(zone, RawOwner());
6479 // TODO(regis): Should we change Function::New() to accept a space, since
6480 // InstantiateFrom is sometimes called with Heap::kNew?
6481 ASSERT(!HasInstantiatedSignature()); 6479 ASSERT(!HasInstantiatedSignature());
6482 Function& sig = Function::Handle( 6480 Function& sig = Function::Handle(
6483 zone, Function::NewSignatureFunction(owner, TokenPosition::kNoSource)); 6481 zone,
6482 Function::NewSignatureFunction(owner, TokenPosition::kNoSource, space));
6483 // TODO(regis): If type parameter bounds are not IsInstantiated(kFunctions),
6484 // clone finalized type parameters and instantiate bounds.
6484 sig.set_type_parameters(TypeArguments::Handle(zone, type_parameters())); 6485 sig.set_type_parameters(TypeArguments::Handle(zone, type_parameters()));
6485 AbstractType& type = AbstractType::Handle(zone, result_type()); 6486 AbstractType& type = AbstractType::Handle(zone, result_type());
6486 if (!type.IsInstantiated()) { 6487 if (!type.IsInstantiated()) {
6487 type = 6488 type =
6488 type.InstantiateFrom(instantiator_type_arguments, 6489 type.InstantiateFrom(instantiator_type_arguments,
6489 function_type_arguments, NULL, NULL, NULL, space); 6490 function_type_arguments, NULL, NULL, NULL, space);
6490 } 6491 }
6491 sig.set_result_type(type); 6492 sig.set_result_type(type);
6492 const intptr_t num_params = NumParameters(); 6493 const intptr_t num_params = NumParameters();
6493 sig.set_num_fixed_parameters(num_fixed_parameters()); 6494 sig.set_num_fixed_parameters(num_fixed_parameters());
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
6675 return (parent_function->ptr()->data_ == reinterpret_cast<RawObject*>(func)); 6676 return (parent_function->ptr()->data_ == reinterpret_cast<RawObject*>(func));
6676 } 6677 }
6677 6678
6678 6679
6679 bool Function::IsConstructorClosureFunction() const { 6680 bool Function::IsConstructorClosureFunction() const {
6680 return IsClosureFunction() && 6681 return IsClosureFunction() &&
6681 String::Handle(name()).StartsWith(Symbols::ConstructorClosurePrefix()); 6682 String::Handle(name()).StartsWith(Symbols::ConstructorClosurePrefix());
6682 } 6683 }
6683 6684
6684 6685
6685 RawFunction* Function::New() { 6686 RawFunction* Function::New(Heap::Space space) {
6686 ASSERT(Object::function_class() != Class::null()); 6687 ASSERT(Object::function_class() != Class::null());
6687 RawObject* raw = Object::Allocate(Function::kClassId, 6688 RawObject* raw =
6688 Function::InstanceSize(), Heap::kOld); 6689 Object::Allocate(Function::kClassId, Function::InstanceSize(), space);
6689 return reinterpret_cast<RawFunction*>(raw); 6690 return reinterpret_cast<RawFunction*>(raw);
6690 } 6691 }
6691 6692
6692 6693
6693 RawFunction* Function::New(const String& name, 6694 RawFunction* Function::New(const String& name,
6694 RawFunction::Kind kind, 6695 RawFunction::Kind kind,
6695 bool is_static, 6696 bool is_static,
6696 bool is_const, 6697 bool is_const,
6697 bool is_abstract, 6698 bool is_abstract,
6698 bool is_external, 6699 bool is_external,
6699 bool is_native, 6700 bool is_native,
6700 const Object& owner, 6701 const Object& owner,
6701 TokenPosition token_pos) { 6702 TokenPosition token_pos,
6703 Heap::Space space) {
6702 ASSERT(!owner.IsNull() || (kind == RawFunction::kSignatureFunction)); 6704 ASSERT(!owner.IsNull() || (kind == RawFunction::kSignatureFunction));
6703 const Function& result = Function::Handle(Function::New()); 6705 const Function& result = Function::Handle(Function::New(space));
6704 result.set_parameter_types(Object::empty_array()); 6706 result.set_parameter_types(Object::empty_array());
6705 result.set_parameter_names(Object::empty_array()); 6707 result.set_parameter_names(Object::empty_array());
6706 result.set_name(name); 6708 result.set_name(name);
6707 result.set_kind(kind); 6709 result.set_kind(kind);
6708 result.set_recognized_kind(MethodRecognizer::kUnknown); 6710 result.set_recognized_kind(MethodRecognizer::kUnknown);
6709 result.set_modifier(RawFunction::kNoModifier); 6711 result.set_modifier(RawFunction::kNoModifier);
6710 result.set_is_static(is_static); 6712 result.set_is_static(is_static);
6711 result.set_is_const(is_const); 6713 result.set_is_const(is_const);
6712 result.set_is_abstract(is_abstract); 6714 result.set_is_abstract(is_abstract);
6713 result.set_is_external(is_external); 6715 result.set_is_external(is_external);
(...skipping 17 matching lines...) Expand all
6731 NOT_IN_PRECOMPILED(result.set_optimized_instruction_count(0)); 6733 NOT_IN_PRECOMPILED(result.set_optimized_instruction_count(0));
6732 NOT_IN_PRECOMPILED(result.set_optimized_call_site_count(0)); 6734 NOT_IN_PRECOMPILED(result.set_optimized_call_site_count(0));
6733 result.set_kernel_function(NULL); 6735 result.set_kernel_function(NULL);
6734 result.set_is_optimizable(is_native ? false : true); 6736 result.set_is_optimizable(is_native ? false : true);
6735 result.set_is_inlinable(true); 6737 result.set_is_inlinable(true);
6736 result.set_allows_hoisting_check_class(true); 6738 result.set_allows_hoisting_check_class(true);
6737 result.set_allows_bounds_check_generalization(true); 6739 result.set_allows_bounds_check_generalization(true);
6738 result.SetInstructionsSafe( 6740 result.SetInstructionsSafe(
6739 Code::Handle(StubCode::LazyCompile_entry()->code())); 6741 Code::Handle(StubCode::LazyCompile_entry()->code()));
6740 if (kind == RawFunction::kClosureFunction) { 6742 if (kind == RawFunction::kClosureFunction) {
6743 ASSERT(space == Heap::kOld);
6741 const ClosureData& data = ClosureData::Handle(ClosureData::New()); 6744 const ClosureData& data = ClosureData::Handle(ClosureData::New());
6742 result.set_data(data); 6745 result.set_data(data);
6743 } else if (kind == RawFunction::kSignatureFunction) { 6746 } else if (kind == RawFunction::kSignatureFunction) {
6744 const SignatureData& data = SignatureData::Handle(SignatureData::New()); 6747 const SignatureData& data =
6748 SignatureData::Handle(SignatureData::New(space));
6745 result.set_data(data); 6749 result.set_data(data);
6750 } else {
6751 // Functions other than signature functions have no reason to be allocated
6752 // in new space.
6753 ASSERT(space == Heap::kOld);
6746 } 6754 }
6747 return result.raw(); 6755 return result.raw();
6748 } 6756 }
6749 6757
6750 6758
6751 RawFunction* Function::Clone(const Class& new_owner) const { 6759 RawFunction* Function::Clone(const Class& new_owner) const {
6752 ASSERT(!IsGenerativeConstructor()); 6760 ASSERT(!IsGenerativeConstructor());
6753 Function& clone = Function::Handle(); 6761 Function& clone = Function::Handle();
6754 clone ^= Object::Clone(*this, Heap::kOld); 6762 clone ^= Object::Clone(*this, Heap::kOld);
6755 const Class& origin = Class::Handle(this->origin()); 6763 const Class& origin = Class::Handle(this->origin());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
6796 /* is_const = */ false, 6804 /* is_const = */ false,
6797 /* is_abstract = */ false, 6805 /* is_abstract = */ false,
6798 /* is_external = */ false, 6806 /* is_external = */ false,
6799 /* is_native = */ false, parent_owner, token_pos)); 6807 /* is_native = */ false, parent_owner, token_pos));
6800 result.set_parent_function(parent); 6808 result.set_parent_function(parent);
6801 return result.raw(); 6809 return result.raw();
6802 } 6810 }
6803 6811
6804 6812
6805 RawFunction* Function::NewSignatureFunction(const Object& owner, 6813 RawFunction* Function::NewSignatureFunction(const Object& owner,
6806 TokenPosition token_pos) { 6814 TokenPosition token_pos,
6815 Heap::Space space) {
6807 const Function& result = Function::Handle(Function::New( 6816 const Function& result = Function::Handle(Function::New(
6808 Symbols::AnonymousSignature(), RawFunction::kSignatureFunction, 6817 Symbols::AnonymousSignature(), RawFunction::kSignatureFunction,
6809 /* is_static = */ false, 6818 /* is_static = */ false,
6810 /* is_const = */ false, 6819 /* is_const = */ false,
6811 /* is_abstract = */ false, 6820 /* is_abstract = */ false,
6812 /* is_external = */ false, 6821 /* is_external = */ false,
6813 /* is_native = */ false, 6822 /* is_native = */ false,
6814 owner, // Same as function type scope class. 6823 owner, // Same as function type scope class.
6815 token_pos)); 6824 token_pos, space));
6816 result.set_is_reflectable(false); 6825 result.set_is_reflectable(false);
6817 result.set_is_visible(false); 6826 result.set_is_visible(false);
6818 result.set_is_debuggable(false); 6827 result.set_is_debuggable(false);
6819 return result.raw(); 6828 return result.raw();
6820 } 6829 }
6821 6830
6822 6831
6823 RawFunction* Function::NewEvalFunction(const Class& owner, 6832 RawFunction* Function::NewEvalFunction(const Class& owner,
6824 const Script& script, 6833 const Script& script,
6825 bool is_static) { 6834 bool is_static) {
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
7479 void SignatureData::set_parent_function(const Function& value) const { 7488 void SignatureData::set_parent_function(const Function& value) const {
7480 StorePointer(&raw_ptr()->parent_function_, value.raw()); 7489 StorePointer(&raw_ptr()->parent_function_, value.raw());
7481 } 7490 }
7482 7491
7483 7492
7484 void SignatureData::set_signature_type(const Type& value) const { 7493 void SignatureData::set_signature_type(const Type& value) const {
7485 StorePointer(&raw_ptr()->signature_type_, value.raw()); 7494 StorePointer(&raw_ptr()->signature_type_, value.raw());
7486 } 7495 }
7487 7496
7488 7497
7489 RawSignatureData* SignatureData::New() { 7498 RawSignatureData* SignatureData::New(Heap::Space space) {
7490 ASSERT(Object::signature_data_class() != Class::null()); 7499 ASSERT(Object::signature_data_class() != Class::null());
7491 RawObject* raw = Object::Allocate(SignatureData::kClassId, 7500 RawObject* raw = Object::Allocate(SignatureData::kClassId,
7492 SignatureData::InstanceSize(), Heap::kOld); 7501 SignatureData::InstanceSize(), space);
7493 return reinterpret_cast<RawSignatureData*>(raw); 7502 return reinterpret_cast<RawSignatureData*>(raw);
7494 } 7503 }
7495 7504
7496 7505
7497 const char* SignatureData::ToCString() const { 7506 const char* SignatureData::ToCString() const {
7498 if (IsNull()) { 7507 if (IsNull()) {
7499 return "SignatureData: null"; 7508 return "SignatureData: null";
7500 } 7509 }
7501 const Function& parent = Function::Handle(parent_function()); 7510 const Function& parent = Function::Handle(parent_function());
7502 const Type& type = Type::Handle(signature_type()); 7511 const Type& type = Type::Handle(signature_type());
(...skipping 15694 matching lines...) Expand 10 before | Expand all | Expand 10 after
23197 return UserTag::null(); 23206 return UserTag::null();
23198 } 23207 }
23199 23208
23200 23209
23201 const char* UserTag::ToCString() const { 23210 const char* UserTag::ToCString() const {
23202 const String& tag_label = String::Handle(label()); 23211 const String& tag_label = String::Handle(label());
23203 return tag_label.ToCString(); 23212 return tag_label.ToCString();
23204 } 23213 }
23205 23214
23206 } // namespace dart 23215 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698