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

Side by Side Diff: vm/dart_api_impl.cc

Issue 10783035: Create frequently used symbols in the vm isolate (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | « vm/dart.cc ('k') | vm/dart_entry.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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
11 #include "vm/dart_api_impl.h" 11 #include "vm/dart_api_impl.h"
12 #include "vm/dart_api_message.h" 12 #include "vm/dart_api_message.h"
13 #include "vm/dart_api_state.h" 13 #include "vm/dart_api_state.h"
14 #include "vm/dart_entry.h" 14 #include "vm/dart_entry.h"
15 #include "vm/debuginfo.h" 15 #include "vm/debuginfo.h"
16 #include "vm/exceptions.h" 16 #include "vm/exceptions.h"
17 #include "vm/flags.h" 17 #include "vm/flags.h"
18 #include "vm/growable_array.h" 18 #include "vm/growable_array.h"
19 #include "vm/message.h" 19 #include "vm/message.h"
20 #include "vm/native_entry.h" 20 #include "vm/native_entry.h"
21 #include "vm/native_message_handler.h" 21 #include "vm/native_message_handler.h"
22 #include "vm/object.h" 22 #include "vm/object.h"
23 #include "vm/object_store.h" 23 #include "vm/object_store.h"
24 #include "vm/port.h" 24 #include "vm/port.h"
25 #include "vm/resolver.h" 25 #include "vm/resolver.h"
26 #include "vm/stack_frame.h" 26 #include "vm/stack_frame.h"
27 #include "vm/symbols.h"
27 #include "vm/timer.h" 28 #include "vm/timer.h"
28 #include "vm/unicode.h" 29 #include "vm/unicode.h"
29 #include "vm/verifier.h" 30 #include "vm/verifier.h"
30 31
31 namespace dart { 32 namespace dart {
32 33
33 DECLARE_FLAG(bool, print_class_table); 34 DECLARE_FLAG(bool, print_class_table);
34 35
35 ThreadLocalKey Api::api_native_key_ = Thread::kUnsetThreadLocalKey; 36 ThreadLocalKey Api::api_native_key_ = Thread::kUnsetThreadLocalKey;
36 37
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id) { 1115 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id) {
1115 Isolate* isolate = Isolate::Current(); 1116 Isolate* isolate = Isolate::Current();
1116 DARTSCOPE(isolate); 1117 DARTSCOPE(isolate);
1117 Library& isolate_lib = Library::Handle(isolate, Library::IsolateLibrary()); 1118 Library& isolate_lib = Library::Handle(isolate, Library::IsolateLibrary());
1118 ASSERT(!isolate_lib.IsNull()); 1119 ASSERT(!isolate_lib.IsNull());
1119 const String& public_class_name = 1120 const String& public_class_name =
1120 String::Handle(isolate, String::New("_ReceivePortImpl")); 1121 String::Handle(isolate, String::New("_ReceivePortImpl"));
1121 const String& class_name = 1122 const String& class_name =
1122 String::Handle(isolate, isolate_lib.PrivateName(public_class_name)); 1123 String::Handle(isolate, isolate_lib.PrivateName(public_class_name));
1123 const String& function_name = 1124 const String& function_name =
1124 String::Handle(isolate, String::NewSymbol("_get_or_create")); 1125 String::Handle(isolate, Symbols::New("_get_or_create"));
1125 const int kNumArguments = 1; 1126 const int kNumArguments = 1;
1126 const Array& kNoArgumentNames = Array::Handle(isolate); 1127 const Array& kNoArgumentNames = Array::Handle(isolate);
1127 const Function& function = Function::Handle( 1128 const Function& function = Function::Handle(
1128 isolate, 1129 isolate,
1129 Resolver::ResolveStatic(isolate_lib, 1130 Resolver::ResolveStatic(isolate_lib,
1130 class_name, 1131 class_name,
1131 function_name, 1132 function_name,
1132 kNumArguments, 1133 kNumArguments,
1133 kNoArgumentNames, 1134 kNoArgumentNames,
1134 Resolver::kIsQualified)); 1135 Resolver::kIsQualified));
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after
2575 // --- Function and Variable Reflection --- 2576 // --- Function and Variable Reflection ---
2576 2577
2577 2578
2578 // Outside of the vm, we expose setter names with a trailing '='. 2579 // Outside of the vm, we expose setter names with a trailing '='.
2579 static bool HasExternalSetterSuffix(const String& name) { 2580 static bool HasExternalSetterSuffix(const String& name) {
2580 return name.CharAt(name.Length() - 1) == '='; 2581 return name.CharAt(name.Length() - 1) == '=';
2581 } 2582 }
2582 2583
2583 2584
2584 static RawString* AddExternalSetterSuffix(const String& name) { 2585 static RawString* AddExternalSetterSuffix(const String& name) {
2585 const String& equals = String::Handle(String::NewSymbol("=")); 2586 const String& equals = String::Handle(Symbols::New("="));
2586 return String::Concat(name, equals); 2587 return String::Concat(name, equals);
2587 } 2588 }
2588 2589
2589 2590
2590 static RawString* RemoveExternalSetterSuffix(const String& name) { 2591 static RawString* RemoveExternalSetterSuffix(const String& name) {
2591 ASSERT(HasExternalSetterSuffix(name)); 2592 ASSERT(HasExternalSetterSuffix(name));
2592 return String::SubString(name, 0, name.Length() - 1); 2593 return String::SubString(name, 0, name.Length() - 1);
2593 } 2594 }
2594 2595
2595 2596
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2690 2691
2691 // Case 3. Lookup the funciton with the getter prefix prepended. 2692 // Case 3. Lookup the funciton with the getter prefix prepended.
2692 if (func.IsNull()) { 2693 if (func.IsNull()) {
2693 tmp_name = Field::GetterName(func_name); 2694 tmp_name = Field::GetterName(func_name);
2694 func = cls.LookupFunction(tmp_name); 2695 func = cls.LookupFunction(tmp_name);
2695 } 2696 }
2696 2697
2697 // Case 4. Lookup the function with a . appended to find the 2698 // Case 4. Lookup the function with a . appended to find the
2698 // unnamed constructor. 2699 // unnamed constructor.
2699 if (func.IsNull()) { 2700 if (func.IsNull()) {
2700 const String& dot = String::Handle(String::NewSymbol(".")); 2701 const String& dot = String::Handle(Symbols::Dot());
2701 tmp_name = String::Concat(func_name, dot); 2702 tmp_name = String::Concat(func_name, dot);
2702 func = cls.LookupFunction(tmp_name); 2703 func = cls.LookupFunction(tmp_name);
2703 } 2704 }
2704 } else if (obj.IsLibrary()) { 2705 } else if (obj.IsLibrary()) {
2705 const Library& lib = Library::Cast(obj); 2706 const Library& lib = Library::Cast(obj);
2706 2707
2707 // Case 1. Lookup the unmodified function name. 2708 // Case 1. Lookup the unmodified function name.
2708 func = lib.LookupFunctionAllowPrivate(func_name); 2709 func = lib.LookupFunctionAllowPrivate(func_name);
2709 2710
2710 // Case 2. Lookup the function without the external setter suffix 2711 // Case 2. Lookup the function without the external setter suffix
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
3084 RETURN_TYPE_ERROR(isolate, clazz, Class); 3085 RETURN_TYPE_ERROR(isolate, clazz, Class);
3085 } 3086 }
3086 String& base_constructor_name = String::Handle(); 3087 String& base_constructor_name = String::Handle();
3087 base_constructor_name = cls.Name(); 3088 base_constructor_name = cls.Name();
3088 3089
3089 // And get the name of the constructor to invoke. 3090 // And get the name of the constructor to invoke.
3090 String& dot_name = String::Handle(isolate); 3091 String& dot_name = String::Handle(isolate);
3091 const Object& name_obj = 3092 const Object& name_obj =
3092 Object::Handle(isolate, Api::UnwrapHandle(constructor_name)); 3093 Object::Handle(isolate, Api::UnwrapHandle(constructor_name));
3093 if (name_obj.IsNull()) { 3094 if (name_obj.IsNull()) {
3094 dot_name = String::NewSymbol("."); 3095 dot_name = Symbols::Dot();
3095 } else if (name_obj.IsString()) { 3096 } else if (name_obj.IsString()) {
3096 const String& dot = String::Handle(isolate, String::NewSymbol(".")); 3097 const String& dot = String::Handle(isolate, Symbols::Dot());
3097 dot_name = String::Concat(dot, String::Cast(name_obj)); 3098 dot_name = String::Concat(dot, String::Cast(name_obj));
3098 } else { 3099 } else {
3099 return Api::NewError( 3100 return Api::NewError(
3100 "%s expects argument 'constructor_name' to be of type String.", 3101 "%s expects argument 'constructor_name' to be of type String.",
3101 CURRENT_FUNC); 3102 CURRENT_FUNC);
3102 } 3103 }
3103 3104
3104 const char* msg = CheckIsolateState(isolate); 3105 const char* msg = CheckIsolateState(isolate);
3105 if (msg != NULL) { 3106 if (msg != NULL) {
3106 return Api::NewError(msg); 3107 return Api::NewError(msg);
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
3603 int field_count) { 3604 int field_count) {
3604 Isolate* isolate = Isolate::Current(); 3605 Isolate* isolate = Isolate::Current();
3605 DARTSCOPE(isolate); 3606 DARTSCOPE(isolate);
3606 const Object& param = Object::Handle(isolate, Api::UnwrapHandle(name)); 3607 const Object& param = Object::Handle(isolate, Api::UnwrapHandle(name));
3607 if (param.IsNull() || !param.IsString() || field_count <= 0) { 3608 if (param.IsNull() || !param.IsString() || field_count <= 0) {
3608 return Api::NewError( 3609 return Api::NewError(
3609 "Invalid arguments passed to Dart_CreateNativeWrapperClass"); 3610 "Invalid arguments passed to Dart_CreateNativeWrapperClass");
3610 } 3611 }
3611 String& cls_name = String::Handle(isolate); 3612 String& cls_name = String::Handle(isolate);
3612 cls_name ^= param.raw(); 3613 cls_name ^= param.raw();
3613 cls_name = String::NewSymbol(cls_name); 3614 cls_name = Symbols::New(cls_name);
3614 Library& lib = Library::Handle(isolate); 3615 Library& lib = Library::Handle(isolate);
3615 lib ^= Api::UnwrapHandle(library); 3616 lib ^= Api::UnwrapHandle(library);
3616 if (lib.IsNull()) { 3617 if (lib.IsNull()) {
3617 return Api::NewError( 3618 return Api::NewError(
3618 "Invalid arguments passed to Dart_CreateNativeWrapperClass"); 3619 "Invalid arguments passed to Dart_CreateNativeWrapperClass");
3619 } 3620 }
3620 const Class& cls = Class::Handle( 3621 const Class& cls = Class::Handle(
3621 isolate, Class::NewNativeWrapper(&lib, cls_name, field_count)); 3622 isolate, Class::NewNativeWrapper(&lib, cls_name, field_count));
3622 if (cls.IsNull()) { 3623 if (cls.IsNull()) {
3623 return Api::NewError( 3624 return Api::NewError(
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
4149 *buffer_size = 0; 4150 *buffer_size = 0;
4150 } 4151 }
4151 } 4152 }
4152 4153
4153 4154
4154 DART_EXPORT void Dart_InitFlowGraphPrinting(FileWriterFunction function) { 4155 DART_EXPORT void Dart_InitFlowGraphPrinting(FileWriterFunction function) {
4155 Dart::set_flow_graph_writer(function); 4156 Dart::set_flow_graph_writer(function);
4156 } 4157 }
4157 4158
4158 } // namespace dart 4159 } // namespace dart
OLDNEW
« no previous file with comments | « vm/dart.cc ('k') | vm/dart_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698