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

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

Issue 1012333002: Keep zone cached in SnapshotReader to allow removing ZoneHandle(Isolate*) interface. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/flow_graph.cc » ('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) 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 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 } 1706 }
1707 1707
1708 1708
1709 DART_EXPORT bool Dart_IsNull(Dart_Handle object) { 1709 DART_EXPORT bool Dart_IsNull(Dart_Handle object) {
1710 return Api::UnwrapHandle(object) == Object::null(); 1710 return Api::UnwrapHandle(object) == Object::null();
1711 } 1711 }
1712 1712
1713 1713
1714 DART_EXPORT Dart_Handle Dart_ObjectEquals(Dart_Handle obj1, Dart_Handle obj2, 1714 DART_EXPORT Dart_Handle Dart_ObjectEquals(Dart_Handle obj1, Dart_Handle obj2,
1715 bool* value) { 1715 bool* value) {
1716 Isolate* isolate = Isolate::Current(); 1716 Thread* thread = Thread::Current();
1717 Isolate* isolate = thread->isolate();
1718 Zone* zone = thread->zone();
1717 DARTSCOPE(isolate); 1719 DARTSCOPE(isolate);
1718 CHECK_CALLBACK_STATE(isolate); 1720 CHECK_CALLBACK_STATE(isolate);
1719 const Instance& expected = 1721 const Instance& expected =
1720 Instance::CheckedHandle(isolate, Api::UnwrapHandle(obj1)); 1722 Instance::CheckedHandle(zone, Api::UnwrapHandle(obj1));
1721 const Instance& actual = 1723 const Instance& actual =
1722 Instance::CheckedHandle(isolate, Api::UnwrapHandle(obj2)); 1724 Instance::CheckedHandle(zone, Api::UnwrapHandle(obj2));
1723 const Object& result = 1725 const Object& result =
1724 Object::Handle(isolate, DartLibraryCalls::Equals(expected, actual)); 1726 Object::Handle(zone, DartLibraryCalls::Equals(expected, actual));
1725 if (result.IsBool()) { 1727 if (result.IsBool()) {
1726 *value = Bool::Cast(result).value(); 1728 *value = Bool::Cast(result).value();
1727 return Api::Success(); 1729 return Api::Success();
1728 } else if (result.IsError()) { 1730 } else if (result.IsError()) {
1729 return Api::NewHandle(isolate, result.raw()); 1731 return Api::NewHandle(isolate, result.raw());
1730 } else { 1732 } else {
1731 return Api::NewError("Expected boolean result from =="); 1733 return Api::NewError("Expected boolean result from ==");
1732 } 1734 }
1733 } 1735 }
1734 1736
(...skipping 3265 matching lines...) Expand 10 before | Expand all | Expand 10 after
5000 CompileSource(isolate, library, script, &result); 5002 CompileSource(isolate, library, script, &result);
5001 return result; 5003 return result;
5002 } 5004 }
5003 5005
5004 5006
5005 DART_EXPORT Dart_Handle Dart_LoadScriptFromSnapshot(const uint8_t* buffer, 5007 DART_EXPORT Dart_Handle Dart_LoadScriptFromSnapshot(const uint8_t* buffer,
5006 intptr_t buffer_len) { 5008 intptr_t buffer_len) {
5007 Isolate* isolate = Isolate::Current(); 5009 Isolate* isolate = Isolate::Current();
5008 DARTSCOPE(isolate); 5010 DARTSCOPE(isolate);
5009 TIMERSCOPE(isolate, time_script_loading); 5011 TIMERSCOPE(isolate, time_script_loading);
5012 StackZone zone(isolate);
5010 if (buffer == NULL) { 5013 if (buffer == NULL) {
5011 RETURN_NULL_ERROR(buffer); 5014 RETURN_NULL_ERROR(buffer);
5012 } 5015 }
5013 NoHeapGrowthControlScope no_growth_control; 5016 NoHeapGrowthControlScope no_growth_control;
5014 5017
5015 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); 5018 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer);
5016 if (!snapshot->IsScriptSnapshot()) { 5019 if (!snapshot->IsScriptSnapshot()) {
5017 return Api::NewError("%s expects parameter 'buffer' to be a script type" 5020 return Api::NewError("%s expects parameter 'buffer' to be a script type"
5018 " snapshot.", CURRENT_FUNC); 5021 " snapshot.", CURRENT_FUNC);
5019 } 5022 }
5020 if (snapshot->length() != buffer_len) { 5023 if (snapshot->length() != buffer_len) {
5021 return Api::NewError("%s: 'buffer_len' of %" Pd " is not equal to %" Pd 5024 return Api::NewError("%s: 'buffer_len' of %" Pd " is not equal to %" Pd
5022 " which is the expected length in the snapshot.", 5025 " which is the expected length in the snapshot.",
5023 CURRENT_FUNC, buffer_len, snapshot->length()); 5026 CURRENT_FUNC, buffer_len, snapshot->length());
5024 } 5027 }
5025 Library& library = 5028 Library& library =
5026 Library::Handle(isolate, isolate->object_store()->root_library()); 5029 Library::Handle(isolate, isolate->object_store()->root_library());
5027 if (!library.IsNull()) { 5030 if (!library.IsNull()) {
5028 const String& library_url = String::Handle(isolate, library.url()); 5031 const String& library_url = String::Handle(isolate, library.url());
5029 return Api::NewError("%s: A script has already been loaded from '%s'.", 5032 return Api::NewError("%s: A script has already been loaded from '%s'.",
5030 CURRENT_FUNC, library_url.ToCString()); 5033 CURRENT_FUNC, library_url.ToCString());
5031 } 5034 }
5032 CHECK_CALLBACK_STATE(isolate); 5035 CHECK_CALLBACK_STATE(isolate);
5033 5036
5034 SnapshotReader reader(snapshot->content(), 5037 SnapshotReader reader(snapshot->content(),
5035 snapshot->length(), 5038 snapshot->length(),
5036 snapshot->kind(), 5039 snapshot->kind(),
5037 isolate); 5040 isolate,
5041 zone.GetZone());
5038 const Object& tmp = Object::Handle(isolate, reader.ReadScriptSnapshot()); 5042 const Object& tmp = Object::Handle(isolate, reader.ReadScriptSnapshot());
5039 if (tmp.IsError()) { 5043 if (tmp.IsError()) {
5040 return Api::NewHandle(isolate, tmp.raw()); 5044 return Api::NewHandle(isolate, tmp.raw());
5041 } 5045 }
5042 library ^= tmp.raw(); 5046 library ^= tmp.raw();
5043 library.set_debuggable(true); 5047 library.set_debuggable(true);
5044 isolate->object_store()->set_root_library(library); 5048 isolate->object_store()->set_root_library(library);
5045 return Api::NewHandle(isolate, library.raw()); 5049 return Api::NewHandle(isolate, library.raw());
5046 } 5050 }
5047 5051
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
5516 5520
5517 5521
5518 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( 5522 DART_EXPORT void Dart_RegisterRootServiceRequestCallback(
5519 const char* name, 5523 const char* name,
5520 Dart_ServiceRequestCallback callback, 5524 Dart_ServiceRequestCallback callback,
5521 void* user_data) { 5525 void* user_data) {
5522 Service::RegisterRootEmbedderCallback(name, callback, user_data); 5526 Service::RegisterRootEmbedderCallback(name, callback, user_data);
5523 } 5527 }
5524 5528
5525 } // namespace dart 5529 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/flow_graph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698