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

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

Issue 99373002: Mark native functions when they are created. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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 | « runtime/vm/object.h ('k') | runtime/vm/object_test.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 (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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 RawFunction* Class::CreateInvocationDispatcher(const String& target_name, 2122 RawFunction* Class::CreateInvocationDispatcher(const String& target_name,
2123 const Array& args_desc, 2123 const Array& args_desc,
2124 RawFunction::Kind kind) const { 2124 RawFunction::Kind kind) const {
2125 Function& invocation = Function::Handle( 2125 Function& invocation = Function::Handle(
2126 Function::New(String::Handle(Symbols::New(target_name)), 2126 Function::New(String::Handle(Symbols::New(target_name)),
2127 kind, 2127 kind,
2128 false, // Not static. 2128 false, // Not static.
2129 false, // Not const. 2129 false, // Not const.
2130 false, // Not abstract. 2130 false, // Not abstract.
2131 false, // Not external. 2131 false, // Not external.
2132 false, // Not native.
2132 *this, 2133 *this,
2133 0)); // No token position. 2134 0)); // No token position.
2134 ArgumentsDescriptor desc(args_desc); 2135 ArgumentsDescriptor desc(args_desc);
2135 invocation.set_num_fixed_parameters(desc.PositionalCount()); 2136 invocation.set_num_fixed_parameters(desc.PositionalCount());
2136 invocation.SetNumOptionalParameters(desc.NamedCount(), 2137 invocation.SetNumOptionalParameters(desc.NamedCount(),
2137 false); // Not positional. 2138 false); // Not positional.
2138 invocation.set_parameter_types(Array::Handle(Array::New(desc.Count(), 2139 invocation.set_parameter_types(Array::Handle(Array::New(desc.Count(),
2139 Heap::kOld))); 2140 Heap::kOld)));
2140 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(), 2141 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(),
2141 Heap::kOld))); 2142 Heap::kOld)));
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2330 const PatchClass& temp_class = 2331 const PatchClass& temp_class =
2331 PatchClass::Handle(MakeTempPatchClass(*this, expr)); 2332 PatchClass::Handle(MakeTempPatchClass(*this, expr));
2332 const String& eval_func_name = String::Handle(Symbols::New(":eval")); 2333 const String& eval_func_name = String::Handle(Symbols::New(":eval"));
2333 const Function& eval_func = 2334 const Function& eval_func =
2334 Function::Handle(Function::New(eval_func_name, 2335 Function::Handle(Function::New(eval_func_name,
2335 RawFunction::kRegularFunction, 2336 RawFunction::kRegularFunction,
2336 true, // Static. 2337 true, // Static.
2337 false, // Not const. 2338 false, // Not const.
2338 false, // Not abstract. 2339 false, // Not abstract.
2339 false, // Not external. 2340 false, // Not external.
2341 false, // Not native.
2340 temp_class, 2342 temp_class,
2341 0)); 2343 0));
2342 eval_func.set_result_type(Type::Handle(Type::DynamicType())); 2344 eval_func.set_result_type(Type::Handle(Type::DynamicType()));
2343 eval_func.set_num_fixed_parameters(0); 2345 eval_func.set_num_fixed_parameters(0);
2344 eval_func.SetNumOptionalParameters(0, true); 2346 eval_func.SetNumOptionalParameters(0, true);
2345 eval_func.set_is_optimizable(false); 2347 eval_func.set_is_optimizable(false);
2346 2348
2347 const Array& args = Array::Handle(Array::New(0)); 2349 const Array& args = Array::Handle(Array::New(0));
2348 const Object& result = 2350 const Object& result =
2349 Object::Handle(DartEntry::InvokeFunction(eval_func, args)); 2351 Object::Handle(DartEntry::InvokeFunction(eval_func, args));
(...skipping 2685 matching lines...) Expand 10 before | Expand all | Expand 10 after
5035 return reinterpret_cast<RawFunction*>(raw); 5037 return reinterpret_cast<RawFunction*>(raw);
5036 } 5038 }
5037 5039
5038 5040
5039 RawFunction* Function::New(const String& name, 5041 RawFunction* Function::New(const String& name,
5040 RawFunction::Kind kind, 5042 RawFunction::Kind kind,
5041 bool is_static, 5043 bool is_static,
5042 bool is_const, 5044 bool is_const,
5043 bool is_abstract, 5045 bool is_abstract,
5044 bool is_external, 5046 bool is_external,
5047 bool is_native,
5045 const Object& owner, 5048 const Object& owner,
5046 intptr_t token_pos) { 5049 intptr_t token_pos) {
5047 ASSERT(!owner.IsNull()); 5050 ASSERT(!owner.IsNull());
5048 const Function& result = Function::Handle(Function::New()); 5051 const Function& result = Function::Handle(Function::New());
5049 result.set_parameter_types(Object::empty_array()); 5052 result.set_parameter_types(Object::empty_array());
5050 result.set_parameter_names(Object::empty_array()); 5053 result.set_parameter_names(Object::empty_array());
5051 result.set_name(name); 5054 result.set_name(name);
5052 result.set_kind(kind); 5055 result.set_kind(kind);
5053 result.set_is_static(is_static); 5056 result.set_is_static(is_static);
5054 result.set_is_const(is_const); 5057 result.set_is_const(is_const);
5055 result.set_is_abstract(is_abstract); 5058 result.set_is_abstract(is_abstract);
5056 result.set_is_external(is_external); 5059 result.set_is_external(is_external);
5060 result.set_is_native(is_native);
5057 result.set_is_visible(true); // Will be computed later. 5061 result.set_is_visible(true); // Will be computed later.
5058 result.set_is_intrinsic(false); 5062 result.set_is_intrinsic(false);
5059 result.set_is_recognized(false); 5063 result.set_is_recognized(false);
5060 result.set_is_redirecting(false); 5064 result.set_is_redirecting(false);
5061 result.set_owner(owner); 5065 result.set_owner(owner);
5062 result.set_token_pos(token_pos); 5066 result.set_token_pos(token_pos);
5063 result.set_end_token_pos(token_pos); 5067 result.set_end_token_pos(token_pos);
5064 result.set_num_fixed_parameters(0); 5068 result.set_num_fixed_parameters(0);
5065 result.set_num_optional_parameters(0); 5069 result.set_num_optional_parameters(0);
5066 result.set_usage_counter(0); 5070 result.set_usage_counter(0);
5067 result.set_deoptimization_counter(0); 5071 result.set_deoptimization_counter(0);
5068 result.set_optimized_instruction_count(0); 5072 result.set_optimized_instruction_count(0);
5069 result.set_optimized_call_site_count(0); 5073 result.set_optimized_call_site_count(0);
5070 result.set_is_optimizable(true); 5074 result.set_is_optimizable(true);
5071 result.set_has_finally(false); 5075 result.set_has_finally(false);
5072 result.set_is_native(false);
5073 result.set_is_inlinable(true); 5076 result.set_is_inlinable(true);
5074 if (kind == RawFunction::kClosureFunction) { 5077 if (kind == RawFunction::kClosureFunction) {
5075 const ClosureData& data = ClosureData::Handle(ClosureData::New()); 5078 const ClosureData& data = ClosureData::Handle(ClosureData::New());
5076 result.set_data(data); 5079 result.set_data(data);
5077 } 5080 }
5078 return result.raw(); 5081 return result.raw();
5079 } 5082 }
5080 5083
5081 5084
5082 RawFunction* Function::Clone(const Class& new_owner) const { 5085 RawFunction* Function::Clone(const Class& new_owner) const {
(...skipping 21 matching lines...) Expand all
5104 // Use the owner defining the parent function and not the class containing it. 5107 // Use the owner defining the parent function and not the class containing it.
5105 const Object& parent_owner = Object::Handle(parent.raw_ptr()->owner_); 5108 const Object& parent_owner = Object::Handle(parent.raw_ptr()->owner_);
5106 ASSERT(!parent_owner.IsNull()); 5109 ASSERT(!parent_owner.IsNull());
5107 const Function& result = Function::Handle( 5110 const Function& result = Function::Handle(
5108 Function::New(name, 5111 Function::New(name,
5109 RawFunction::kClosureFunction, 5112 RawFunction::kClosureFunction,
5110 /* is_static = */ parent.is_static(), 5113 /* is_static = */ parent.is_static(),
5111 /* is_const = */ false, 5114 /* is_const = */ false,
5112 /* is_abstract = */ false, 5115 /* is_abstract = */ false,
5113 /* is_external = */ false, 5116 /* is_external = */ false,
5117 parent.is_native(),
5114 parent_owner, 5118 parent_owner,
5115 token_pos)); 5119 token_pos));
5116 result.set_parent_function(parent); 5120 result.set_parent_function(parent);
5117 return result.raw(); 5121 return result.raw();
5118 } 5122 }
5119 5123
5120 5124
5121 RawFunction* Function::ImplicitClosureFunction() const { 5125 RawFunction* Function::ImplicitClosureFunction() const {
5122 // Return the existing implicit closure function if any. 5126 // Return the existing implicit closure function if any.
5123 if (implicit_closure_function() != Function::null()) { 5127 if (implicit_closure_function() != Function::null()) {
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
5490 const String& init_name = 5494 const String& init_name =
5491 String::Handle(Symbols::New(String::Handle( 5495 String::Handle(Symbols::New(String::Handle(
5492 String::Concat(Symbols::InitPrefix(), field_name)))); 5496 String::Concat(Symbols::InitPrefix(), field_name))));
5493 const Function& init_function = Function::ZoneHandle( 5497 const Function& init_function = Function::ZoneHandle(
5494 Function::New(init_name, 5498 Function::New(init_name,
5495 RawFunction::kStaticInitializer, 5499 RawFunction::kStaticInitializer,
5496 true, // static 5500 true, // static
5497 false, // !const 5501 false, // !const
5498 false, // !abstract 5502 false, // !abstract
5499 false, // !external 5503 false, // !external
5504 false, // !native
5500 Class::Handle(field.owner()), 5505 Class::Handle(field.owner()),
5501 field.token_pos())); 5506 field.token_pos()));
5502 init_function.set_result_type(AbstractType::Handle(field.type())); 5507 init_function.set_result_type(AbstractType::Handle(field.type()));
5503 // Static initializer functions are generated by the VM and are therfore 5508 // Static initializer functions are generated by the VM and are therfore
5504 // hidden from the user. Since they are only executed once, we avoid 5509 // hidden from the user. Since they are only executed once, we avoid
5505 // optimizing and inlining them. After the field is initialized, the 5510 // optimizing and inlining them. After the field is initialized, the
5506 // optimizing compiler can eliminate the call to the static initializer 5511 // optimizing compiler can eliminate the call to the static initializer
5507 // via constant folding. 5512 // via constant folding.
5508 init_function.set_is_visible(false); 5513 init_function.set_is_visible(false);
5509 init_function.set_is_optimizable(false); 5514 init_function.set_is_optimizable(false);
(...skipping 5523 matching lines...) Expand 10 before | Expand all | Expand 10 after
11033 const PatchClass& temp_class = 11038 const PatchClass& temp_class =
11034 PatchClass::Handle(MakeTempPatchClass(cls, expr)); 11039 PatchClass::Handle(MakeTempPatchClass(cls, expr));
11035 const String& eval_func_name = String::Handle(Symbols::New(":eval")); 11040 const String& eval_func_name = String::Handle(Symbols::New(":eval"));
11036 const Function& eval_func = 11041 const Function& eval_func =
11037 Function::Handle(Function::New(eval_func_name, 11042 Function::Handle(Function::New(eval_func_name,
11038 RawFunction::kRegularFunction, 11043 RawFunction::kRegularFunction,
11039 false, // Not static. 11044 false, // Not static.
11040 false, // Not const. 11045 false, // Not const.
11041 false, // Not abstract. 11046 false, // Not abstract.
11042 false, // Not external. 11047 false, // Not external.
11048 false, // Not native.
11043 temp_class, 11049 temp_class,
11044 0)); 11050 0));
11045 eval_func.set_result_type(Type::Handle(Type::DynamicType())); 11051 eval_func.set_result_type(Type::Handle(Type::DynamicType()));
11046 eval_func.set_num_fixed_parameters(1); 11052 eval_func.set_num_fixed_parameters(1);
11047 eval_func.SetNumOptionalParameters(0, true); 11053 eval_func.SetNumOptionalParameters(0, true);
11048 eval_func.set_is_optimizable(false); 11054 eval_func.set_is_optimizable(false);
11049 11055
11050 const Array& args = Array::Handle(Array::New(1)); 11056 const Array& args = Array::Handle(Array::New(1));
11051 args.SetAt(0, *this); 11057 args.SetAt(0, *this);
11052 const Object& result = 11058 const Object& result =
(...skipping 4996 matching lines...) Expand 10 before | Expand all | Expand 10 after
16049 return "_MirrorReference"; 16055 return "_MirrorReference";
16050 } 16056 }
16051 16057
16052 16058
16053 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 16059 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
16054 Instance::PrintToJSONStream(stream, ref); 16060 Instance::PrintToJSONStream(stream, ref);
16055 } 16061 }
16056 16062
16057 16063
16058 } // namespace dart 16064 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698