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

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

Issue 11360116: Pass closure object as first implicit argument to closure functions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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/dart_api_impl.cc ('k') | runtime/vm/flow_graph_compiler_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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/dart_entry.h" 5 #include "vm/dart_entry.h"
6 6
7 #include "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/resolver.h" 10 #include "vm/resolver.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 ASSERT(Class::Handle(closure.clazz()).signature_function() != Object::null()); 92 ASSERT(Class::Handle(closure.clazz()).signature_function() != Object::null());
93 const Function& function = Function::Handle(Closure::function(closure)); 93 const Function& function = Function::Handle(Closure::function(closure));
94 const Context& context = Context::Handle(Closure::context(closure)); 94 const Context& context = Context::Handle(Closure::context(closure));
95 ASSERT(!function.IsNull()); 95 ASSERT(!function.IsNull());
96 if (!function.HasCode()) { 96 if (!function.HasCode()) {
97 const Error& error = Error::Handle(Compiler::CompileFunction(function)); 97 const Error& error = Error::Handle(Compiler::CompileFunction(function));
98 if (!error.IsNull()) { 98 if (!error.IsNull()) {
99 return error.raw(); 99 return error.raw();
100 } 100 }
101 } 101 }
102 // Set up arguments to include the closure as the first argument.
103 const int num_arguments = arguments.length() + 1;
104 GrowableArray<const Object*> args(num_arguments);
105 const Object& arg0 = Object::ZoneHandle(closure.raw());
106 args.Add(&arg0);
107 for (int i = 1; i < num_arguments; i++) {
108 args.Add(arguments[i - 1]);
109 }
102 // Now Call the invoke stub which will invoke the closure. 110 // Now Call the invoke stub which will invoke the closure.
103 invokestub entrypoint = reinterpret_cast<invokestub>( 111 invokestub entrypoint = reinterpret_cast<invokestub>(
104 StubCode::InvokeDartCodeEntryPoint()); 112 StubCode::InvokeDartCodeEntryPoint());
105 ASSERT(context.isolate() == Isolate::Current()); 113 ASSERT(context.isolate() == Isolate::Current());
106 const Code& code = Code::Handle(function.CurrentCode()); 114 const Code& code = Code::Handle(function.CurrentCode());
107 ASSERT(!code.IsNull()); 115 ASSERT(!code.IsNull());
108 return entrypoint( 116 return entrypoint(
109 code.EntryPoint(), 117 code.EntryPoint(),
110 ArgumentsDescriptor(arguments.length(), optional_arguments_names), 118 ArgumentsDescriptor(num_arguments, optional_arguments_names),
111 arguments.data(), 119 args.data(),
112 context); 120 context);
113 } 121 }
114 122
115 123
116 const Array& DartEntry::ArgumentsDescriptor( 124 const Array& DartEntry::ArgumentsDescriptor(
117 int num_arguments, 125 int num_arguments,
118 const Array& optional_arguments_names) { 126 const Array& optional_arguments_names) {
119 const intptr_t num_named_args = 127 const intptr_t num_named_args =
120 optional_arguments_names.IsNull() ? 0 : optional_arguments_names.Length(); 128 optional_arguments_names.IsNull() ? 0 : optional_arguments_names.Length();
121 const intptr_t num_pos_args = num_arguments - num_named_args; 129 const intptr_t num_pos_args = num_arguments - num_named_args;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 const String& func_name = String::Handle(Field::GetterName(field_name)); 322 const String& func_name = String::Handle(Field::GetterName(field_name));
315 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); 323 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name));
316 ASSERT(!func.IsNull()); 324 ASSERT(!func.IsNull());
317 GrowableArray<const Object*> arguments; 325 GrowableArray<const Object*> arguments;
318 const Array& kNoArgumentNames = Array::Handle(); 326 const Array& kNoArgumentNames = Array::Handle();
319 return DartEntry::InvokeDynamic(port, func, arguments, kNoArgumentNames); 327 return DartEntry::InvokeDynamic(port, func, arguments, kNoArgumentNames);
320 } 328 }
321 329
322 330
323 } // namespace dart 331 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/flow_graph_compiler_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698