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

Unified 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: removed throw_exception boolean. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/isolate.cc
diff --git a/runtime/lib/isolate.cc b/runtime/lib/isolate.cc
index 154ad01b042ac93b625d4ea7373a792dec59cf08..0f7da54201652a3f4787731a780d952e7e8f8023 100644
--- a/runtime/lib/isolate.cc
+++ b/runtime/lib/isolate.cc
@@ -215,30 +215,22 @@ static RawObject* Spawn(NativeArguments* arguments, IsolateSpawnState* state) {
DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(0));
- bool throw_exception = false;
- Function& func = Function::Handle();
if (closure.IsClosure()) {
+ Function& func = Function::Handle();
func = Closure::function(closure);
- const Class& cls = Class::Handle(func.Owner());
- if (!func.IsClosureFunction() || !func.is_static() || !cls.IsTopLevel()) {
- throw_exception = true;
- }
- } else {
- throw_exception = true;
- }
- if (throw_exception) {
- const String& msg = String::Handle(String::New(
- "Isolate.spawn expects to be passed a top-level function"));
- Exceptions::ThrowArgumentError(msg);
- }
-
+ if (func.IsImplicitClosureFunction() && func.is_static()) {
#if defined(DEBUG)
- Context& ctx = Context::Handle();
- ctx = Closure::context(closure);
- ASSERT(ctx.num_variables() == 0);
+ Context& ctx = Context::Handle();
+ ctx = Closure::context(closure);
+ ASSERT(ctx.num_variables() == 0);
#endif
-
- return Spawn(arguments, new IsolateSpawnState(func));
+ return Spawn(arguments, new IsolateSpawnState(func));
+ }
+ }
+ const String& msg = String::Handle(String::New(
+ "Isolate.spawn expects to be passed a static or top-level function"));
+ Exceptions::ThrowArgumentError(msg);
+ return Object::null();
}
« 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