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

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

Issue 2933603002: 1. Dynamic compute the main closure that needs to be run by the main isolate (Closed)
Patch Set: Address review comments. Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "lib/stacktrace.h" 9 #include "lib/stacktrace.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 2325 matching lines...) Expand 10 before | Expand all | Expand 10 after
2336 DARTSCOPE(Thread::Current()); 2336 DARTSCOPE(Thread::Current());
2337 const Double& obj = Api::UnwrapDoubleHandle(Z, double_obj); 2337 const Double& obj = Api::UnwrapDoubleHandle(Z, double_obj);
2338 if (obj.IsNull()) { 2338 if (obj.IsNull()) {
2339 RETURN_TYPE_ERROR(Z, double_obj, Double); 2339 RETURN_TYPE_ERROR(Z, double_obj, Double);
2340 } 2340 }
2341 *value = obj.value(); 2341 *value = obj.value();
2342 return Api::Success(); 2342 return Api::Success();
2343 } 2343 }
2344 2344
2345 2345
2346 DART_EXPORT Dart_Handle Dart_GetClosure(Dart_Handle library,
2347 Dart_Handle function_name) {
2348 DARTSCOPE(Thread::Current());
2349 const Library& lib = Api::UnwrapLibraryHandle(Z, library);
2350 if (lib.IsNull()) {
2351 RETURN_TYPE_ERROR(Z, library, Library);
2352 }
2353 const String& name = Api::UnwrapStringHandle(Z, function_name);
2354 if (name.IsNull()) {
2355 RETURN_TYPE_ERROR(Z, function_name, String);
2356 }
2357 return Api::NewHandle(T, lib.GetFunctionClosure(name));
2358 }
2359
2360
2346 // --- Booleans ---- 2361 // --- Booleans ----
2347 2362
2348 DART_EXPORT Dart_Handle Dart_True() { 2363 DART_EXPORT Dart_Handle Dart_True() {
2349 ASSERT(Isolate::Current() != NULL); 2364 ASSERT(Isolate::Current() != NULL);
2350 return Api::True(); 2365 return Api::True();
2351 } 2366 }
2352 2367
2353 2368
2354 DART_EXPORT Dart_Handle Dart_False() { 2369 DART_EXPORT Dart_Handle Dart_False() {
2355 ASSERT(Isolate::Current() != NULL); 2370 ASSERT(Isolate::Current() != NULL);
(...skipping 3059 matching lines...) Expand 10 before | Expand all | Expand 10 after
5415 5430
5416 // NOTE: Now the VM owns the [kernel_program] memory! Currently we do not 5431 // NOTE: Now the VM owns the [kernel_program] memory! Currently we do not
5417 // free it because (similar to the token stream) it will be used to repeatedly 5432 // free it because (similar to the token stream) it will be used to repeatedly
5418 // run the `kernel::FlowGraphBuilder()`. 5433 // run the `kernel::FlowGraphBuilder()`.
5419 kernel::KernelReader reader( 5434 kernel::KernelReader reader(
5420 reinterpret_cast<kernel::Program*>(kernel_program)); 5435 reinterpret_cast<kernel::Program*>(kernel_program));
5421 const Object& tmp = reader.ReadProgram(); 5436 const Object& tmp = reader.ReadProgram();
5422 if (tmp.IsError()) { 5437 if (tmp.IsError()) {
5423 return Api::NewHandle(T, tmp.raw()); 5438 return Api::NewHandle(T, tmp.raw());
5424 } 5439 }
5440 // TODO(kernel): Setting root library based on whether it has 'main' or not
5441 // is not correct because main can be in the exported namespace of a library
5442 // or it could be a getter.
5425 if (tmp.IsNull()) { 5443 if (tmp.IsNull()) {
5426 return Api::NewError("%s: The binary program does not contain 'main'.", 5444 return Api::NewError("%s: The binary program does not contain 'main'.",
5427 CURRENT_FUNC); 5445 CURRENT_FUNC);
5428 } 5446 }
5429 library ^= tmp.raw(); 5447 library ^= tmp.raw();
5430 I->object_store()->set_root_library(library); 5448 I->object_store()->set_root_library(library);
5431 return Api::NewHandle(T, library.raw()); 5449 return Api::NewHandle(T, library.raw());
5432 #endif 5450 #endif
5433 } 5451 }
5434 5452
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after
6948 } 6966 }
6949 6967
6950 6968
6951 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { 6969 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) {
6952 #ifndef PRODUCT 6970 #ifndef PRODUCT
6953 Profiler::DumpStackTrace(context); 6971 Profiler::DumpStackTrace(context);
6954 #endif 6972 #endif
6955 } 6973 }
6956 6974
6957 } // namespace dart 6975 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698