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

Side by Side Diff: runtime/lib/isolate.cc

Issue 68813002: Fix VM not accepting static methods for Isolate.spawn. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Mark test as failing on drt/dartium due to using spawnFunction. Created 7 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 | « no previous file | runtime/vm/isolate.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 (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 "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/dart.h" 8 #include "vm/dart.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 state->isolate()->set_spawn_data(reinterpret_cast<uword>(state)); 208 state->isolate()->set_spawn_data(reinterpret_cast<uword>(state));
209 if (state->isolate()->is_runnable()) { 209 if (state->isolate()->is_runnable()) {
210 state->isolate()->Run(); 210 state->isolate()->Run();
211 } 211 }
212 212
213 return port.raw(); 213 return port.raw();
214 } 214 }
215 215
216 216
217 DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 1) { 217 DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 1) {
218 GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(0)); 218 GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(0));
Ivan Posva 2013/11/19 22:20:15 This whole control flow can be simplified. Feel fr
Lasse Reichstein Nielsen 2013/11/20 09:09:10 Done. Just rearranged the blocks, so if you know a
219 bool throw_exception = false; 219 bool throw_exception = false;
220 Function& func = Function::Handle(); 220 Function& func = Function::Handle();
221 if (closure.IsClosure()) { 221 if (closure.IsClosure()) {
222 func = Closure::function(closure); 222 func = Closure::function(closure);
223 const Class& cls = Class::Handle(func.Owner()); 223 if (!(func.IsImplicitClosureFunction() && func.is_static())) {
224 if (!func.IsClosureFunction() || !func.is_static() || !cls.IsTopLevel()) {
225 throw_exception = true; 224 throw_exception = true;
226 } 225 }
227 } else { 226 } else {
228 throw_exception = true; 227 throw_exception = true;
229 } 228 }
230 if (throw_exception) { 229 if (throw_exception) {
231 const String& msg = String::Handle(String::New( 230 const String& msg = String::Handle(String::New(
232 "Isolate.spawn expects to be passed a top-level function")); 231 "Isolate.spawn expects to be passed a static or top-level function"));
233 Exceptions::ThrowArgumentError(msg); 232 Exceptions::ThrowArgumentError(msg);
234 } 233 }
235 234
236 #if defined(DEBUG) 235 #if defined(DEBUG)
237 Context& ctx = Context::Handle(); 236 Context& ctx = Context::Handle();
238 ctx = Closure::context(closure); 237 ctx = Closure::context(closure);
239 ASSERT(ctx.num_variables() == 0); 238 ASSERT(ctx.num_variables() == 0);
240 #endif 239 #endif
241 240
242 return Spawn(arguments, new IsolateSpawnState(func)); 241 return Spawn(arguments, new IsolateSpawnState(func));
(...skipping 26 matching lines...) Expand all
269 268
270 // The control port is being accessed as a regular port from Dart code. This 269 // The control port is being accessed as a regular port from Dart code. This
271 // is most likely due to the _startIsolate code in dart:isolate. Account for 270 // is most likely due to the _startIsolate code in dart:isolate. Account for
272 // this by increasing the number of open control ports. 271 // this by increasing the number of open control ports.
273 isolate->message_handler()->increment_control_ports(); 272 isolate->message_handler()->increment_control_ports();
274 273
275 return port.raw(); 274 return port.raw();
276 } 275 }
277 276
278 } // namespace dart 277 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698