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

Side by Side Diff: vm/dart_api_impl.cc

Issue 8618011: Check for presence of native resolver in library for classes which have native fields only in reg... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 9 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 | « vm/class_finalizer.cc ('k') | no next file » | 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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 } else { 434 } else {
435 SetupErrorResult(result); 435 SetupErrorResult(result);
436 } 436 }
437 isolate->set_long_jump_base(base); 437 isolate->set_long_jump_base(base);
438 } 438 }
439 } 439 }
440 440
441 441
442 // Return error if isolate is in an inconsistent state. 442 // Return error if isolate is in an inconsistent state.
443 // Return NULL when no error condition exists. 443 // Return NULL when no error condition exists.
444 static const char* CheckIsolateState(Isolate* isolate) { 444 static const char* CheckIsolateState(Isolate* isolate,
445 if (!ClassFinalizer::FinalizePendingClasses()) { 445 bool generating_snapshot) {
Ivan Posva 2011/11/22 00:42:53 This is almost a default parameter value.
siva 2011/11/22 01:19:37 Made a default parameter. On 2011/11/22 00:42:53,
446 bool result = (generating_snapshot) ?
447 ClassFinalizer::FinalizePendingClassesForSnapshotCreation() :
448 ClassFinalizer::FinalizePendingClasses();
449 if (!result) {
446 // Make a copy of the error message as the original message string 450 // Make a copy of the error message as the original message string
447 // may get deallocated when we return back from the Dart API call. 451 // may get deallocated when we return back from the Dart API call.
448 const String& err = 452 const String& err =
449 String::Handle(isolate->object_store()->sticky_error()); 453 String::Handle(isolate->object_store()->sticky_error());
450 const char* errmsg = err.ToCString(); 454 const char* errmsg = err.ToCString();
451 intptr_t errlen = strlen(errmsg) + 1; 455 intptr_t errlen = strlen(errmsg) + 1;
452 char* msg = reinterpret_cast<char*>(Api::Allocate(errlen)); 456 char* msg = reinterpret_cast<char*>(Api::Allocate(errlen));
453 OS::SNPrint(msg, errlen, "%s", errmsg); 457 OS::SNPrint(msg, errlen, "%s", errmsg);
454 return msg; 458 return msg;
455 } 459 }
456 return NULL; 460 return NULL;
457 } 461 }
458 462
459 463
460 DART_EXPORT Dart_Handle Dart_CompileAll() { 464 DART_EXPORT Dart_Handle Dart_CompileAll() {
461 Isolate* isolate = Isolate::Current(); 465 Isolate* isolate = Isolate::Current();
462 DARTSCOPE(isolate); 466 DARTSCOPE(isolate);
463 Dart_Handle result; 467 Dart_Handle result;
464 const char* msg = CheckIsolateState(isolate); 468 const char* msg = CheckIsolateState(isolate,
469 ClassFinalizer::kNotGeneratingSnapshot);
465 if (msg != NULL) { 470 if (msg != NULL) {
466 return Api::Error(msg); 471 return Api::Error(msg);
467 } 472 }
468 CompileAll(isolate, &result); 473 CompileAll(isolate, &result);
469 return result; 474 return result;
470 } 475 }
471 476
472 477
473 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object) { 478 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object) {
474 DARTSCOPE(Isolate::Current()); 479 DARTSCOPE(Isolate::Current());
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 Isolate* isolate = Isolate::Current(); 711 Isolate* isolate = Isolate::Current();
707 DARTSCOPE(isolate); 712 DARTSCOPE(isolate);
708 const Class& cls = Class::CheckedHandle(Api::UnwrapHandle(clazz)); 713 const Class& cls = Class::CheckedHandle(Api::UnwrapHandle(clazz));
709 if (cls.IsNull()) { 714 if (cls.IsNull()) {
710 return Api::Error("instanceof check against null class"); 715 return Api::Error("instanceof check against null class");
711 } 716 }
712 const Object& obj = Object::Handle(Api::UnwrapHandle(object)); 717 const Object& obj = Object::Handle(Api::UnwrapHandle(object));
713 Instance& instance = Instance::Handle(); 718 Instance& instance = Instance::Handle();
714 instance ^= obj.raw(); 719 instance ^= obj.raw();
715 // Finalize all classes. 720 // Finalize all classes.
716 const char* msg = CheckIsolateState(isolate); 721 const char* msg = CheckIsolateState(isolate,
722 ClassFinalizer::kNotGeneratingSnapshot);
717 if (msg != NULL) { 723 if (msg != NULL) {
718 return Api::Error(msg); 724 return Api::Error(msg);
719 } 725 }
720 const Type& type = Type::Handle(Type::NewNonParameterizedType(cls)); 726 const Type& type = Type::Handle(Type::NewNonParameterizedType(cls));
721 *value = instance.Is(type); 727 *value = instance.Is(type);
722 return Api::Success(); 728 return Api::Success();
723 } 729 }
724 730
725 731
726 // TODO(iposva): The argument should be an instance. 732 // TODO(iposva): The argument should be an instance.
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 1497
1492 1498
1493 DART_EXPORT Dart_Handle Dart_InvokeStatic(Dart_Handle library_in, 1499 DART_EXPORT Dart_Handle Dart_InvokeStatic(Dart_Handle library_in,
1494 Dart_Handle class_name_in, 1500 Dart_Handle class_name_in,
1495 Dart_Handle function_name_in, 1501 Dart_Handle function_name_in,
1496 int number_of_arguments, 1502 int number_of_arguments,
1497 Dart_Handle* arguments) { 1503 Dart_Handle* arguments) {
1498 Isolate* isolate = Isolate::Current(); 1504 Isolate* isolate = Isolate::Current();
1499 DARTSCOPE(isolate); 1505 DARTSCOPE(isolate);
1500 // Finalize all classes. 1506 // Finalize all classes.
1501 const char* msg = CheckIsolateState(isolate); 1507 const char* msg = CheckIsolateState(isolate,
1508 ClassFinalizer::kNotGeneratingSnapshot);
1502 if (msg != NULL) { 1509 if (msg != NULL) {
1503 return Api::Error(msg); 1510 return Api::Error(msg);
1504 } 1511 }
1505 1512
1506 // Now try to resolve and invoke the static function. 1513 // Now try to resolve and invoke the static function.
1507 const Library& library = 1514 const Library& library =
1508 Library::CheckedHandle(Api::UnwrapHandle(library_in)); 1515 Library::CheckedHandle(Api::UnwrapHandle(library_in));
1509 if (library.IsNull()) { 1516 if (library.IsNull()) {
1510 return Api::Error("No library specified"); 1517 return Api::Error("No library specified");
1511 } 1518 }
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 } 2010 }
2004 2011
2005 2012
2006 DART_EXPORT Dart_Handle Dart_CreateSnapshot(uint8_t** snapshot_buffer, 2013 DART_EXPORT Dart_Handle Dart_CreateSnapshot(uint8_t** snapshot_buffer,
2007 intptr_t* snapshot_size) { 2014 intptr_t* snapshot_size) {
2008 Isolate* isolate = Isolate::Current(); 2015 Isolate* isolate = Isolate::Current();
2009 DARTSCOPE(isolate); 2016 DARTSCOPE(isolate);
2010 if (snapshot_buffer == NULL || snapshot_size == NULL) { 2017 if (snapshot_buffer == NULL || snapshot_size == NULL) {
2011 return Api::Error("Invalid input parameters to Dart_CreateSnapshot"); 2018 return Api::Error("Invalid input parameters to Dart_CreateSnapshot");
2012 } 2019 }
2013 const char* msg = CheckIsolateState(isolate); 2020 const char* msg = CheckIsolateState(isolate,
2021 ClassFinalizer::kGeneratingSnapshot);
2014 if (msg != NULL) { 2022 if (msg != NULL) {
2015 return Api::Error(msg); 2023 return Api::Error(msg);
2016 } 2024 }
2017 // Since this is only a snapshot the root library should not be set. 2025 // Since this is only a snapshot the root library should not be set.
2018 isolate->object_store()->set_root_library(Library::Handle()); 2026 isolate->object_store()->set_root_library(Library::Handle());
2019 SnapshotWriter writer(true, snapshot_buffer, ApiAllocator); 2027 SnapshotWriter writer(true, snapshot_buffer, ApiAllocator);
2020 writer.WriteFullSnapshot(); 2028 writer.WriteFullSnapshot();
2021 *snapshot_size = writer.Size(); 2029 *snapshot_size = writer.Size();
2022 return Api::Success(); 2030 return Api::Success();
2023 } 2031 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 ASSERT(isolate != NULL); 2243 ASSERT(isolate != NULL);
2236 ApiState* state = isolate->api_state(); 2244 ApiState* state = isolate->api_state();
2237 ASSERT(state != NULL); 2245 ASSERT(state != NULL);
2238 ApiLocalScope* scope = state->top_scope(); 2246 ApiLocalScope* scope = state->top_scope();
2239 ASSERT(scope != NULL); 2247 ASSERT(scope != NULL);
2240 return scope->zone().Reallocate(ptr, old_size, new_size); 2248 return scope->zone().Reallocate(ptr, old_size, new_size);
2241 } 2249 }
2242 2250
2243 2251
2244 } // namespace dart 2252 } // namespace dart
OLDNEW
« no previous file with comments | « vm/class_finalizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698