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

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

Issue 1162033005: Fix http://dartbug.com/23578: (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update to ToT. Created 5 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 "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 intptr_t len = OS::SNPrint(NULL, 0, "%s$%s", script_uri, main) + 1; 1280 intptr_t len = OS::SNPrint(NULL, 0, "%s$%s", script_uri, main) + 1;
1281 chars = reinterpret_cast<char*>(malloc(len)); 1281 chars = reinterpret_cast<char*>(malloc(len));
1282 OS::SNPrint(chars, len, "%s$%s", script_uri, main); 1282 OS::SNPrint(chars, len, "%s$%s", script_uri, main);
1283 return chars; 1283 return chars;
1284 } 1284 }
1285 1285
1286 1286
1287 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri, 1287 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri,
1288 const char* main, 1288 const char* main,
1289 const uint8_t* snapshot, 1289 const uint8_t* snapshot,
1290 Dart_IsolateFlags* flags,
1290 void* callback_data, 1291 void* callback_data,
1291 char** error) { 1292 char** error) {
1292 CHECK_NO_ISOLATE(Isolate::Current()); 1293 CHECK_NO_ISOLATE(Isolate::Current());
1293 char* isolate_name = BuildIsolateName(script_uri, main); 1294 char* isolate_name = BuildIsolateName(script_uri, main);
1294 Thread::EnsureInit(); 1295 Thread::EnsureInit();
1295 Isolate* isolate = Dart::CreateIsolate(isolate_name); 1296
1297 // Setup default flags in case none were passed.
1298 Dart_IsolateFlags api_flags;
1299 if (flags == NULL) {
1300 Isolate::Flags vm_flags;
1301 vm_flags.CopyTo(&api_flags);
1302 flags = &api_flags;
1303 }
1304 Isolate* isolate = Dart::CreateIsolate(isolate_name, *flags);
1296 free(isolate_name); 1305 free(isolate_name);
1297 StackZone zone(isolate); 1306 StackZone zone(isolate);
1298 HANDLESCOPE(isolate); 1307 HANDLESCOPE(isolate);
1299 // We enter an API scope here as InitializeIsolate could compile some 1308 // We enter an API scope here as InitializeIsolate could compile some
1300 // bootstrap library files which call out to a tag handler that may create 1309 // bootstrap library files which call out to a tag handler that may create
1301 // Api Handles when an error is encountered. 1310 // Api Handles when an error is encountered.
1302 Dart_EnterScope(); 1311 Dart_EnterScope();
1303 const Error& error_obj = 1312 const Error& error_obj =
1304 Error::Handle(isolate, Dart::InitializeIsolate(snapshot, callback_data)); 1313 Error::Handle(isolate, Dart::InitializeIsolate(snapshot, callback_data));
1305 if (error_obj.IsNull()) { 1314 if (error_obj.IsNull()) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 profiler_data->Unblock(); 1407 profiler_data->Unblock();
1399 } 1408 }
1400 1409
1401 1410
1402 DART_EXPORT void Dart_ExitIsolate() { 1411 DART_EXPORT void Dart_ExitIsolate() {
1403 CHECK_ISOLATE(Isolate::Current()); 1412 CHECK_ISOLATE(Isolate::Current());
1404 Thread::ExitIsolate(); 1413 Thread::ExitIsolate();
1405 } 1414 }
1406 1415
1407 1416
1417 // TODO(iposva): Remove this API and instead expose the underlying flags.
1408 DART_EXPORT Dart_Handle Dart_IsolateSetStrictCompilation(bool value) { 1418 DART_EXPORT Dart_Handle Dart_IsolateSetStrictCompilation(bool value) {
1409 CHECK_ISOLATE(Isolate::Current()); 1419 CHECK_ISOLATE(Isolate::Current());
1410 Isolate* isolate = Isolate::Current(); 1420 Isolate* isolate = Isolate::Current();
1411 if (isolate->has_compiled()) { 1421 if (isolate->has_compiled()) {
1412 return Api::NewError( 1422 return Api::NewError(
1413 "%s expects that the isolate has not yet compiled code.", CURRENT_FUNC); 1423 "%s expects that the isolate has not yet compiled code.", CURRENT_FUNC);
1414 } 1424 }
1415 Isolate::Current()->set_strict_compilation(value); 1425 if (!value) {
1426 return Api::NewError(
1427 "%s expects that the value is set to true only.", CURRENT_FUNC);
1428 }
1429 Isolate::Current()->set_strict_compilation();
1416 return Api::Null(); 1430 return Api::Null();
1417 } 1431 }
1418 1432
1419 1433
1420 static uint8_t* ApiReallocate(uint8_t* ptr, 1434 static uint8_t* ApiReallocate(uint8_t* ptr,
1421 intptr_t old_size, 1435 intptr_t old_size,
1422 intptr_t new_size) { 1436 intptr_t new_size) {
1423 return Api::TopScope(Isolate::Current())->zone()->Realloc<uint8_t>( 1437 return Api::TopScope(Isolate::Current())->zone()->Realloc<uint8_t>(
1424 ptr, old_size, new_size); 1438 ptr, old_size, new_size);
1425 } 1439 }
(...skipping 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after
3992 Dart_Handle name, 4006 Dart_Handle name,
3993 int number_of_arguments, 4007 int number_of_arguments,
3994 Dart_Handle* arguments) { 4008 Dart_Handle* arguments) {
3995 Isolate* isolate = Isolate::Current(); 4009 Isolate* isolate = Isolate::Current();
3996 DARTSCOPE(isolate); 4010 DARTSCOPE(isolate);
3997 CHECK_CALLBACK_STATE(isolate); 4011 CHECK_CALLBACK_STATE(isolate);
3998 // TODO(turnidge): This is a bit simplistic. It overcounts when 4012 // TODO(turnidge): This is a bit simplistic. It overcounts when
3999 // other operations (gc, compilation) are active. 4013 // other operations (gc, compilation) are active.
4000 TIMERSCOPE(isolate, time_dart_execution); 4014 TIMERSCOPE(isolate, time_dart_execution);
4001 4015
4002 isolate->set_has_compiled(true);
4003
4004 const String& function_name = Api::UnwrapStringHandle(isolate, name); 4016 const String& function_name = Api::UnwrapStringHandle(isolate, name);
4005 if (function_name.IsNull()) { 4017 if (function_name.IsNull()) {
4006 RETURN_TYPE_ERROR(isolate, name, String); 4018 RETURN_TYPE_ERROR(isolate, name, String);
4007 } 4019 }
4008 if (number_of_arguments < 0) { 4020 if (number_of_arguments < 0) {
4009 return Api::NewError( 4021 return Api::NewError(
4010 "%s expects argument 'number_of_arguments' to be non-negative.", 4022 "%s expects argument 'number_of_arguments' to be non-negative.",
4011 CURRENT_FUNC); 4023 CURRENT_FUNC);
4012 } 4024 }
4013 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(target)); 4025 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(target));
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after
5581 5593
5582 5594
5583 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( 5595 DART_EXPORT void Dart_RegisterRootServiceRequestCallback(
5584 const char* name, 5596 const char* name,
5585 Dart_ServiceRequestCallback callback, 5597 Dart_ServiceRequestCallback callback,
5586 void* user_data) { 5598 void* user_data) {
5587 Service::RegisterRootEmbedderCallback(name, callback, user_data); 5599 Service::RegisterRootEmbedderCallback(name, callback, user_data);
5588 } 5600 }
5589 5601
5590 } // namespace dart 5602 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698