mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 20:51:19 +00:00
Changes to pass the current isolate to all runtime and native calls.
Review URL: http://codereview.chromium.org//8528010 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1499 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
67a5aded5a
commit
5cf3ad018a
|
@ -146,8 +146,8 @@ static void RunIsolate(uword parameter) {
|
|||
LongJump jump;
|
||||
isolate->set_long_jump_base(&jump);
|
||||
if (setjmp(*jump.Set()) == 0) {
|
||||
Zone zone;
|
||||
HandleScope handle_scope;
|
||||
Zone zone(isolate);
|
||||
HandleScope handle_scope(isolate);
|
||||
ASSERT(ClassFinalizer::FinalizePendingClasses());
|
||||
// Lookup the target class by name, create an instance and call the run
|
||||
// method.
|
||||
|
@ -206,8 +206,8 @@ static void RunIsolate(uword parameter) {
|
|||
isolate->StandardRunLoop();
|
||||
|
||||
} else {
|
||||
Zone zone;
|
||||
HandleScope handle_scope;
|
||||
Zone zone(isolate);
|
||||
HandleScope handle_scope(isolate);
|
||||
const String& error = String::Handle(
|
||||
Isolate::Current()->object_store()->sticky_error());
|
||||
const char* errmsg = error.ToCString();
|
||||
|
@ -220,8 +220,9 @@ static void RunIsolate(uword parameter) {
|
|||
|
||||
|
||||
static bool CheckArguments(const char* library_url, const char* class_name) {
|
||||
Zone zone;
|
||||
HandleScope handle_scope;
|
||||
Isolate* isolate = Isolate::Current();
|
||||
Zone zone(isolate);
|
||||
HandleScope handle_scope(isolate);
|
||||
String& name = String::Handle();
|
||||
if (!ClassFinalizer::FinalizePendingClasses()) {
|
||||
return false;
|
||||
|
@ -289,8 +290,8 @@ DEFINE_NATIVE_ENTRY(IsolateNatives_start, 2) {
|
|||
// Make sure to grab the error message out of the isolate before it has
|
||||
// been shutdown and to allocate it in the preserved isolates zone.
|
||||
{
|
||||
Zone zone;
|
||||
HandleScope scope;
|
||||
Zone zone(spawned_isolate);
|
||||
HandleScope scope(spawned_isolate);
|
||||
const String& error = String::Handle(
|
||||
spawned_isolate->object_store()->sticky_error());
|
||||
const char* temp_error_msg = error.ToCString();
|
||||
|
|
|
@ -10,17 +10,16 @@
|
|||
|
||||
namespace dart {
|
||||
|
||||
StackResource::StackResource() {
|
||||
isolate_ = Isolate::Current();
|
||||
previous_ = isolate_->top_resource();
|
||||
isolate_->set_top_resource(this);
|
||||
StackResource::StackResource(Isolate* isolate) : isolate_(isolate) {
|
||||
previous_ = isolate->top_resource();
|
||||
isolate->set_top_resource(this);
|
||||
}
|
||||
|
||||
|
||||
StackResource::~StackResource() {
|
||||
StackResource* top = isolate_->top_resource();
|
||||
StackResource* top = isolate()->top_resource();
|
||||
ASSERT(top == this);
|
||||
isolate_->set_top_resource(previous_);
|
||||
isolate()->set_top_resource(previous_);
|
||||
}
|
||||
|
||||
ZoneAllocated::~ZoneAllocated() {
|
||||
|
|
|
@ -35,7 +35,7 @@ class ValueObject {
|
|||
// to a stack frame above the frame where these objects were allocated.
|
||||
class StackResource {
|
||||
public:
|
||||
StackResource();
|
||||
explicit StackResource(Isolate* isolate);
|
||||
virtual ~StackResource();
|
||||
|
||||
Isolate* isolate() const { return isolate_; }
|
||||
|
|
|
@ -31,7 +31,8 @@ class TestValueObject : public ValueObject {
|
|||
|
||||
class TestStackResource : public StackResource {
|
||||
public:
|
||||
explicit TestStackResource(int* ptr) : ptr_(ptr) {
|
||||
explicit TestStackResource(int* ptr)
|
||||
: StackResource(Isolate::Current()), ptr_(ptr) {
|
||||
EXPECT_EQ(1, *ptr_);
|
||||
*ptr_ = 2;
|
||||
}
|
||||
|
@ -51,7 +52,8 @@ class TestStackResource : public StackResource {
|
|||
|
||||
class TestStackedStackResource : public StackResource {
|
||||
public:
|
||||
explicit TestStackedStackResource(int* ptr) : ptr_(ptr) {
|
||||
explicit TestStackedStackResource(int* ptr)
|
||||
: StackResource(Isolate::Current()), ptr_(ptr) {
|
||||
EXPECT_EQ(3, *ptr_);
|
||||
*ptr_ = 4;
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ DEFINE_RUNTIME_ENTRY(AllocateClosure, 2) {
|
|||
ASSERT(type_arguments.IsNull() || type_arguments.IsInstantiated());
|
||||
// The current context was saved in the Isolate structure when entering the
|
||||
// runtime.
|
||||
const Context& context = Context::Handle(Isolate::Current()->top_context());
|
||||
const Context& context = Context::Handle(isolate->top_context());
|
||||
ASSERT(!context.IsNull());
|
||||
const Closure& closure = Closure::Handle(Closure::New(function, context));
|
||||
closure.SetTypeArguments(type_arguments);
|
||||
|
@ -249,7 +249,7 @@ DEFINE_RUNTIME_ENTRY(AllocateClosure, 2) {
|
|||
DEFINE_RUNTIME_ENTRY(AllocateImplicitStaticClosure, 1) {
|
||||
ASSERT(arguments.Count() ==
|
||||
kAllocateImplicitStaticClosureRuntimeEntry.argument_count());
|
||||
ObjectStore* object_store = Isolate::Current()->object_store();
|
||||
ObjectStore* object_store = isolate->object_store();
|
||||
ASSERT(object_store != NULL);
|
||||
const Function& function = Function::CheckedHandle(arguments.At(0));
|
||||
ASSERT(function.IsImplicitStaticClosureFunction());
|
||||
|
@ -384,7 +384,8 @@ DEFINE_RUNTIME_ENTRY(PatchStaticCall, 0) {
|
|||
// Resolves and compiles the target function of an instance call, updates
|
||||
// function cache of the receiver's class and returns the compiled code or null.
|
||||
// Only the number of named arguments is checked, but not the actual names.
|
||||
static RawCode* ResolveCompileInstanceCallTarget(const Instance& receiver) {
|
||||
static RawCode* ResolveCompileInstanceCallTarget(Isolate* isolate,
|
||||
const Instance& receiver) {
|
||||
DartFrameIterator iterator;
|
||||
DartFrame* caller_frame = iterator.NextFrame();
|
||||
ASSERT(caller_frame != NULL);
|
||||
|
@ -401,7 +402,7 @@ static RawCode* ResolveCompileInstanceCallTarget(const Instance& receiver) {
|
|||
Class& receiver_class = Class::Handle();
|
||||
if (receiver.IsNull()) {
|
||||
// TODO(srdjan): Clarify behavior of null objects.
|
||||
receiver_class = Isolate::Current()->object_store()->object_class();
|
||||
receiver_class = isolate->object_store()->object_class();
|
||||
} else {
|
||||
receiver_class = receiver.clazz();
|
||||
}
|
||||
|
@ -457,7 +458,8 @@ DEFINE_RUNTIME_ENTRY(ResolveCompileInstanceFunction, 1) {
|
|||
ASSERT(arguments.Count() ==
|
||||
kResolveCompileInstanceFunctionRuntimeEntry.argument_count());
|
||||
const Instance& receiver = Instance::CheckedHandle(arguments.At(0));
|
||||
const Code& code = Code::Handle(ResolveCompileInstanceCallTarget(receiver));
|
||||
const Code& code = Code::Handle(
|
||||
ResolveCompileInstanceCallTarget(isolate, receiver));
|
||||
arguments.SetReturn(Code::Handle(code.raw()));
|
||||
}
|
||||
|
||||
|
@ -472,7 +474,7 @@ DEFINE_RUNTIME_ENTRY(InlineCacheMissHandler, 1) {
|
|||
kInlineCacheMissHandlerRuntimeEntry.argument_count());
|
||||
const Instance& receiver = Instance::CheckedHandle(arguments.At(0));
|
||||
const Code& target_code =
|
||||
Code::Handle(ResolveCompileInstanceCallTarget(receiver));
|
||||
Code::Handle(ResolveCompileInstanceCallTarget(isolate, receiver));
|
||||
if (target_code.IsNull()) {
|
||||
// Let the megamorphic stub handle special cases: NoSuchMethod,
|
||||
// closure calls.
|
||||
|
@ -517,12 +519,13 @@ DEFINE_RUNTIME_ENTRY(InlineCacheMissHandler, 1) {
|
|||
}
|
||||
|
||||
|
||||
static RawFunction* LookupDynamicFunction(const Class& in_cls,
|
||||
static RawFunction* LookupDynamicFunction(Isolate* isolate,
|
||||
const Class& in_cls,
|
||||
const String& name) {
|
||||
Class& cls = Class::Handle();
|
||||
// For lookups treat null as an instance of class Object.
|
||||
if (in_cls.IsNullClass()) {
|
||||
cls = Isolate::Current()->object_store()->object_class();
|
||||
cls = isolate->object_store()->object_class();
|
||||
} else {
|
||||
cls = in_cls.raw();
|
||||
}
|
||||
|
@ -568,8 +571,8 @@ DEFINE_RUNTIME_ENTRY(ResolveImplicitClosureFunction, 2) {
|
|||
String& func_name = String::Handle();
|
||||
func_name = String::SubString(original_function_name, getter_prefix.Length());
|
||||
func_name = String::NewSymbol(func_name);
|
||||
const Function& function =
|
||||
Function::Handle(LookupDynamicFunction(receiver_class, func_name));
|
||||
const Function& function = Function::Handle(
|
||||
LookupDynamicFunction(isolate, receiver_class, func_name));
|
||||
if (function.IsNull()) {
|
||||
// There is no function of the same name so can't be the case where
|
||||
// we are trying to create an implicit closure of an instance function.
|
||||
|
@ -789,13 +792,13 @@ DEFINE_RUNTIME_ENTRY(ClosureArgumentMismatch, 0) {
|
|||
DEFINE_RUNTIME_ENTRY(StackOverflow, 0) {
|
||||
ASSERT(arguments.Count() ==
|
||||
kStackOverflowRuntimeEntry.argument_count());
|
||||
uword old_stack_limit = Isolate::Current()->stack_limit();
|
||||
Isolate::Current()->AdjustStackLimitForException();
|
||||
uword old_stack_limit = isolate->stack_limit();
|
||||
isolate->AdjustStackLimitForException();
|
||||
// Recursive stack overflow check.
|
||||
ASSERT(old_stack_limit != Isolate::Current()->stack_limit());
|
||||
ASSERT(old_stack_limit != isolate->stack_limit());
|
||||
GrowableArray<const Object*> args;
|
||||
Exceptions::ThrowByType(Exceptions::kStackOverflow, args);
|
||||
Isolate::Current()->ResetStackLimitAfterException();
|
||||
isolate->ResetStackLimitAfterException();
|
||||
}
|
||||
|
||||
|
||||
|
@ -870,7 +873,7 @@ DEFINE_RUNTIME_ENTRY(Deoptimize, 0) {
|
|||
DartFrameIterator iterator;
|
||||
DartFrame* caller_frame = iterator.NextFrame();
|
||||
ASSERT(caller_frame != NULL);
|
||||
CodeIndexTable* ci_table = Isolate::Current()->code_index_table();
|
||||
CodeIndexTable* ci_table = isolate->code_index_table();
|
||||
const Code& optimized_code =
|
||||
Code::Handle(ci_table->LookupCode(caller_frame->pc()));
|
||||
const Function& function = Function::Handle(optimized_code.function());
|
||||
|
|
|
@ -36,7 +36,9 @@ DECLARE_FLAG(bool, trace_compiler);
|
|||
class CodeGeneratorState : public StackResource {
|
||||
public:
|
||||
explicit CodeGeneratorState(CodeGenerator* codegen)
|
||||
: codegen_(codegen), parent_(codegen->state()) {
|
||||
: StackResource(Isolate::Current()),
|
||||
codegen_(codegen),
|
||||
parent_(codegen->state()) {
|
||||
if (parent_ != NULL) {
|
||||
root_node_ = parent_->root_node_;
|
||||
loop_level_ = parent_->loop_level_;
|
||||
|
|
|
@ -37,8 +37,8 @@ bool Dart::InitOnce(int argc, char** argv,
|
|||
{
|
||||
ASSERT(vm_isolate_ == NULL);
|
||||
vm_isolate_ = Isolate::Init();
|
||||
Zone zone;
|
||||
HandleScope handle_scope;
|
||||
Zone zone(vm_isolate_);
|
||||
HandleScope handle_scope(vm_isolate_);
|
||||
Heap::Init(vm_isolate_);
|
||||
ObjectStore::Init(vm_isolate_);
|
||||
Object::InitOnce();
|
||||
|
@ -64,8 +64,8 @@ void Dart::InitializeIsolate(const Dart_Snapshot* snapshot_buffer, void* data) {
|
|||
// Initialize the new isolate.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
ASSERT(isolate != NULL);
|
||||
Zone zone;
|
||||
HandleScope handle_scope;
|
||||
Zone zone(isolate);
|
||||
HandleScope handle_scope(isolate);
|
||||
Heap::Init(isolate);
|
||||
ObjectStore::Init(isolate);
|
||||
|
||||
|
|
|
@ -55,17 +55,14 @@ static const char* CanonicalFunction(const char* func) {
|
|||
|
||||
|
||||
DART_EXPORT bool Dart_IsError(const Dart_Handle& handle) {
|
||||
ASSERT(Isolate::Current() != NULL);
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(handle));
|
||||
return obj.IsApiError();
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT bool Dart_ErrorHasException(Dart_Handle handle) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(handle));
|
||||
if (obj.IsApiError()) {
|
||||
const ApiError& error = ApiError::CheckedHandle(obj.raw());
|
||||
|
@ -77,8 +74,7 @@ DART_EXPORT bool Dart_ErrorHasException(Dart_Handle handle) {
|
|||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_ErrorGetException(Dart_Handle handle) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(handle));
|
||||
if (obj.IsApiError()) {
|
||||
const ApiError& error = ApiError::CheckedHandle(obj.raw());
|
||||
|
@ -98,8 +94,7 @@ DART_EXPORT Dart_Handle Dart_ErrorGetException(Dart_Handle handle) {
|
|||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_ErrorGetStacktrace(Dart_Handle handle) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(handle));
|
||||
if (obj.IsApiError()) {
|
||||
ApiError& failure = ApiError::Handle();
|
||||
|
@ -158,9 +153,8 @@ static const char* MakeUnhandledExceptionCString(
|
|||
|
||||
|
||||
DART_EXPORT const char* Dart_GetError(const Dart_Handle& handle) {
|
||||
ASSERT(Isolate::Current() != NULL);
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(handle));
|
||||
if (!obj.IsApiError()) {
|
||||
return "";
|
||||
|
@ -192,8 +186,7 @@ DART_EXPORT const char* Dart_GetError(const Dart_Handle& handle) {
|
|||
// TODO(turnidge): This clonse Api::Error. I need to use va_copy to
|
||||
// fix this but not sure if it available on all of our builds.
|
||||
DART_EXPORT Dart_Handle Dart_Error(const char* format, ...) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
@ -234,10 +227,9 @@ DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot,
|
|||
return reinterpret_cast<Dart_Isolate>(isolate);
|
||||
} else {
|
||||
{
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(isolate);
|
||||
const String& error =
|
||||
String::Handle(Isolate::Current()->object_store()->sticky_error());
|
||||
String::Handle(isolate->object_store()->sticky_error());
|
||||
// TODO(asiva): Need to return this as a error.
|
||||
OS::PrintErr(error.ToCString());
|
||||
}
|
||||
|
@ -311,8 +303,8 @@ static RawInstance* DeserializeMessage(void* data) {
|
|||
DART_EXPORT Dart_Handle Dart_HandleMessage(Dart_Port dest_port,
|
||||
Dart_Port reply_port,
|
||||
Dart_Message dart_message) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
|
||||
const Instance& msg = Instance::Handle(DeserializeMessage(dart_message));
|
||||
const String& class_name =
|
||||
String::Handle(String::NewSymbol("ReceivePortImpl"));
|
||||
|
@ -342,10 +334,9 @@ DART_EXPORT Dart_Handle Dart_HandleMessage(Dart_Port dest_port,
|
|||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_RunLoop() {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
|
||||
LongJump* base = isolate->long_jump_base();
|
||||
LongJump jump;
|
||||
Dart_Handle result;
|
||||
|
@ -364,13 +355,13 @@ DART_EXPORT Dart_Handle Dart_RunLoop() {
|
|||
// NOTE: Need to pass 'result' as a parameter here in order to avoid
|
||||
// warning: variable 'result' might be clobbered by 'longjmp' or 'vfork'
|
||||
// which shows up because of the use of setjmp.
|
||||
static void CompileSource(const Library& lib,
|
||||
static void CompileSource(Isolate* isolate,
|
||||
const Library& lib,
|
||||
const String& url,
|
||||
const String& source,
|
||||
RawScript::Kind kind,
|
||||
Dart_Handle* result) {
|
||||
const Script& script = Script::Handle(Script::New(url, source, kind));
|
||||
Isolate* isolate = Isolate::Current();
|
||||
ASSERT(isolate != NULL);
|
||||
LongJump* base = isolate->long_jump_base();
|
||||
LongJump jump;
|
||||
|
@ -389,9 +380,7 @@ DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
|
|||
Dart_Handle source,
|
||||
Dart_LibraryTagHandler handler) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
ASSERT(isolate != NULL);
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(isolate);
|
||||
TIMERSCOPE(time_script_loading);
|
||||
const String& url_str = String::CheckedHandle(Api::UnwrapHandle(url));
|
||||
const String& source_str = String::CheckedHandle(Api::UnwrapHandle(source));
|
||||
|
@ -404,17 +393,21 @@ DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
|
|||
library.Register();
|
||||
isolate->object_store()->set_root_library(library);
|
||||
Dart_Handle result;
|
||||
CompileSource(library, url_str, source_str, RawScript::kScript, &result);
|
||||
CompileSource(isolate,
|
||||
library,
|
||||
url_str,
|
||||
source_str,
|
||||
RawScript::kScript,
|
||||
&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
DEFINE_FLAG(bool, compile_all, false, "Eagerly compile all code.");
|
||||
|
||||
static void CompileAll(Dart_Handle* result) {
|
||||
static void CompileAll(Isolate* isolate, Dart_Handle* result) {
|
||||
*result = Api::Success();
|
||||
if (FLAG_compile_all) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
ASSERT(isolate != NULL);
|
||||
LongJump* base = isolate->long_jump_base();
|
||||
LongJump jump;
|
||||
|
@ -431,12 +424,12 @@ static void CompileAll(Dart_Handle* result) {
|
|||
|
||||
// Return error if isolate is in an inconsistent state.
|
||||
// Return NULL when no error condition exists.
|
||||
static const char* CheckIsolateState() {
|
||||
static const char* CheckIsolateState(Isolate* isolate) {
|
||||
if (!ClassFinalizer::FinalizePendingClasses()) {
|
||||
// Make a copy of the error message as the original message string
|
||||
// may get deallocated when we return back from the Dart API call.
|
||||
const String& err =
|
||||
String::Handle(Isolate::Current()->object_store()->sticky_error());
|
||||
String::Handle(isolate->object_store()->sticky_error());
|
||||
const char* errmsg = err.ToCString();
|
||||
intptr_t errlen = strlen(errmsg) + 1;
|
||||
char* msg = reinterpret_cast<char*>(Api::Allocate(errlen));
|
||||
|
@ -448,29 +441,27 @@ static const char* CheckIsolateState() {
|
|||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_CompileAll() {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
Dart_Handle result;
|
||||
const char* msg = CheckIsolateState();
|
||||
const char* msg = CheckIsolateState(isolate);
|
||||
if (msg != NULL) {
|
||||
return Api::Error(msg);
|
||||
}
|
||||
CompileAll(&result);
|
||||
CompileAll(isolate, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT bool Dart_IsLibrary(Dart_Handle object) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
return obj.IsLibrary();
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Library& lib = Library::CheckedHandle(Api::UnwrapHandle(library));
|
||||
if (lib.IsNull()) {
|
||||
return Api::Error("Null library");
|
||||
|
@ -483,8 +474,7 @@ DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library) {
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library_in,
|
||||
Dart_Handle import_in) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Library& library =
|
||||
Library::CheckedHandle(Api::UnwrapHandle(library_in));
|
||||
if (library.IsNull()) {
|
||||
|
@ -498,8 +488,7 @@ DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library_in,
|
|||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
String& url_str = String::Handle();
|
||||
UNWRAP_NONNULL(url, url_str, String);
|
||||
const Library& library = Library::Handle(Library::LookupLibrary(url_str));
|
||||
|
@ -513,8 +502,8 @@ DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) {
|
|||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, Dart_Handle source) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const String& url_str = String::CheckedHandle(Api::UnwrapHandle(url));
|
||||
const String& source_str = String::CheckedHandle(Api::UnwrapHandle(source));
|
||||
Library& library = Library::Handle(Library::LookupLibrary(url_str));
|
||||
|
@ -523,7 +512,12 @@ DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, Dart_Handle source) {
|
|||
library.Register();
|
||||
}
|
||||
Dart_Handle result;
|
||||
CompileSource(library, url_str, source_str, RawScript::kLibrary, &result);
|
||||
CompileSource(isolate,
|
||||
library,
|
||||
url_str,
|
||||
source_str,
|
||||
RawScript::kLibrary,
|
||||
&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -531,14 +525,14 @@ DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, Dart_Handle source) {
|
|||
DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library_in,
|
||||
Dart_Handle url_in,
|
||||
Dart_Handle source_in) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const String& url = String::CheckedHandle(Api::UnwrapHandle(url_in));
|
||||
const String& source = String::CheckedHandle(Api::UnwrapHandle(source_in));
|
||||
const Library& library =
|
||||
Library::CheckedHandle(Api::UnwrapHandle(library_in));
|
||||
Dart_Handle result;
|
||||
CompileSource(library, url, source, RawScript::kSource, &result);
|
||||
CompileSource(isolate, library, url, source, RawScript::kSource, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -546,8 +540,7 @@ DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library_in,
|
|||
DART_EXPORT Dart_Handle Dart_SetNativeResolver(
|
||||
Dart_Handle library,
|
||||
Dart_NativeEntryResolver resolver) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Library& lib = Library::CheckedHandle(Api::UnwrapHandle(library));
|
||||
if (lib.IsNull()) {
|
||||
return Api::Error("Invalid parameter, Unknown library specified");
|
||||
|
@ -558,8 +551,7 @@ DART_EXPORT Dart_Handle Dart_SetNativeResolver(
|
|||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_ToString(Dart_Handle object) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
Object& result = Object::Handle();
|
||||
if (obj.IsString()) {
|
||||
|
@ -585,24 +577,21 @@ DART_EXPORT Dart_Handle Dart_Null() {
|
|||
|
||||
|
||||
DART_EXPORT bool Dart_IsNull(Dart_Handle object) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
return obj.IsNull();
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT bool Dart_IsClosure(Dart_Handle object) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
return obj.IsClosure();
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT int64_t Dart_ClosureSmrck(Dart_Handle object) {
|
||||
Zone zone;
|
||||
HandleScope scope;
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Closure& obj = Closure::CheckedHandle(Api::UnwrapHandle(object));
|
||||
const Integer& smrck = Integer::Handle(obj.smrck());
|
||||
return smrck.IsNull() ? 0 : smrck.AsInt64Value();
|
||||
|
@ -610,8 +599,7 @@ DART_EXPORT int64_t Dart_ClosureSmrck(Dart_Handle object) {
|
|||
|
||||
|
||||
DART_EXPORT void Dart_ClosureSetSmrck(Dart_Handle object, int64_t value) {
|
||||
Zone zone;
|
||||
HandleScope scope;
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Closure& obj = Closure::CheckedHandle(Api::UnwrapHandle(object));
|
||||
const Integer& smrck = Integer::Handle(Integer::New(value));
|
||||
obj.set_smrck(smrck);
|
||||
|
@ -620,8 +608,7 @@ DART_EXPORT void Dart_ClosureSetSmrck(Dart_Handle object, int64_t value) {
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_ObjectEquals(Dart_Handle obj1, Dart_Handle obj2,
|
||||
bool* value) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Instance& expected = Instance::CheckedHandle(Api::UnwrapHandle(obj1));
|
||||
const Instance& actual = Instance::CheckedHandle(Api::UnwrapHandle(obj2));
|
||||
const Instance& result =
|
||||
|
@ -641,8 +628,7 @@ DART_EXPORT Dart_Handle Dart_ObjectEquals(Dart_Handle obj1, Dart_Handle obj2,
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_IsSame(Dart_Handle obj1, Dart_Handle obj2,
|
||||
bool* value) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& expected = Object::Handle(Api::UnwrapHandle(obj1));
|
||||
const Object& actual = Object::Handle(Api::UnwrapHandle(obj2));
|
||||
*value = (expected.raw() == actual.raw());
|
||||
|
@ -651,8 +637,7 @@ DART_EXPORT Dart_Handle Dart_IsSame(Dart_Handle obj1, Dart_Handle obj2,
|
|||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle name) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& param = Object::Handle(Api::UnwrapHandle(name));
|
||||
if (param.IsNull() || !param.IsString()) {
|
||||
return Api::Error("Invalid class name specified");
|
||||
|
@ -679,8 +664,8 @@ DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle name) {
|
|||
DART_EXPORT Dart_Handle Dart_ObjectIsType(Dart_Handle object,
|
||||
Dart_Handle clazz,
|
||||
bool* value) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Class& cls = Class::CheckedHandle(Api::UnwrapHandle(clazz));
|
||||
if (cls.IsNull()) {
|
||||
return Api::Error("instanceof check against null class");
|
||||
|
@ -689,7 +674,7 @@ DART_EXPORT Dart_Handle Dart_ObjectIsType(Dart_Handle object,
|
|||
Instance& instance = Instance::Handle();
|
||||
instance ^= obj.raw();
|
||||
// Finalize all classes.
|
||||
const char* msg = CheckIsolateState();
|
||||
const char* msg = CheckIsolateState(isolate);
|
||||
if (msg != NULL) {
|
||||
return Api::Error(msg);
|
||||
}
|
||||
|
@ -701,32 +686,28 @@ DART_EXPORT Dart_Handle Dart_ObjectIsType(Dart_Handle object,
|
|||
|
||||
// TODO(iposva): The argument should be an instance.
|
||||
DART_EXPORT bool Dart_IsNumber(Dart_Handle object) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
return obj.IsNumber();
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT bool Dart_IsInteger(Dart_Handle object) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
return obj.IsInteger();
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Integer& obj = Integer::Handle(Integer::New(value));
|
||||
return Api::NewLocalHandle(obj);
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_NewIntegerFromHexCString(const char* str) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const String& str_obj = String::Handle(String::New(str));
|
||||
const Integer& obj = Integer::Handle(Integer::New(str_obj));
|
||||
return Api::NewLocalHandle(obj);
|
||||
|
@ -734,8 +715,7 @@ DART_EXPORT Dart_Handle Dart_NewIntegerFromHexCString(const char* str) {
|
|||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_IntegerValue(Dart_Handle integer, int64_t* value) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(integer));
|
||||
if (obj.IsSmi() || obj.IsMint()) {
|
||||
Integer& integer = Integer::Handle();
|
||||
|
@ -759,8 +739,7 @@ DART_EXPORT Dart_Handle Dart_IntegerValue(Dart_Handle integer, int64_t* value) {
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_IntegerValueHexCString(Dart_Handle integer,
|
||||
const char** value) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(integer));
|
||||
Bigint& bigint = Bigint::Handle();
|
||||
if (obj.IsSmi() || obj.IsMint()) {
|
||||
|
@ -781,8 +760,7 @@ DART_EXPORT Dart_Handle Dart_IntegerValueHexCString(Dart_Handle integer,
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer,
|
||||
bool* fits) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(integer));
|
||||
if (obj.IsSmi() || obj.IsMint()) {
|
||||
*fits = true;
|
||||
|
@ -811,8 +789,7 @@ DART_EXPORT Dart_Handle Dart_False() {
|
|||
|
||||
|
||||
DART_EXPORT bool Dart_IsBoolean(Dart_Handle object) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
return obj.IsBool();
|
||||
}
|
||||
|
@ -825,8 +802,7 @@ DART_EXPORT Dart_Handle Dart_NewBoolean(bool value) {
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle bool_object,
|
||||
bool* value) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(bool_object));
|
||||
if (obj.IsBool()) {
|
||||
Bool& bool_obj = Bool::Handle();
|
||||
|
@ -839,24 +815,21 @@ DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle bool_object,
|
|||
|
||||
|
||||
DART_EXPORT bool Dart_IsDouble(Dart_Handle object) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
return obj.IsDouble();
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_NewDouble(double value) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Double& obj = Double::Handle(Double::New(value));
|
||||
return Api::NewLocalHandle(obj);
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle integer, double* result) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(integer));
|
||||
if (obj.IsDouble()) {
|
||||
Double& double_obj = Double::Handle();
|
||||
|
@ -869,16 +842,14 @@ DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle integer, double* result) {
|
|||
|
||||
|
||||
DART_EXPORT bool Dart_IsString(Dart_Handle object) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
return obj.IsString();
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_StringLength(Dart_Handle str, intptr_t* len) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(str));
|
||||
if (obj.IsString()) {
|
||||
String& string_obj = String::Handle();
|
||||
|
@ -891,8 +862,7 @@ DART_EXPORT Dart_Handle Dart_StringLength(Dart_Handle str, intptr_t* len) {
|
|||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_NewString(const char* str) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const String& obj = String::Handle(String::New(str));
|
||||
return Api::NewLocalHandle(obj);
|
||||
}
|
||||
|
@ -900,8 +870,7 @@ DART_EXPORT Dart_Handle Dart_NewString(const char* str) {
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_NewString8(const uint8_t* codepoints,
|
||||
intptr_t length) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const String& obj = String::Handle(String::New(codepoints, length));
|
||||
return Api::NewLocalHandle(obj);
|
||||
}
|
||||
|
@ -909,8 +878,7 @@ DART_EXPORT Dart_Handle Dart_NewString8(const uint8_t* codepoints,
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_NewString16(const uint16_t* codepoints,
|
||||
intptr_t length) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const String& obj = String::Handle(String::New(codepoints, length));
|
||||
return Api::NewLocalHandle(obj);
|
||||
}
|
||||
|
@ -918,24 +886,21 @@ DART_EXPORT Dart_Handle Dart_NewString16(const uint16_t* codepoints,
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_NewString32(const uint32_t* codepoints,
|
||||
intptr_t length) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const String& obj = String::Handle(String::New(codepoints, length));
|
||||
return Api::NewLocalHandle(obj);
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT bool Dart_IsString8(Dart_Handle object) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
return obj.IsOneByteString();
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT bool Dart_IsString16(Dart_Handle object) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
return obj.IsOneByteString() || obj.IsTwoByteString();
|
||||
}
|
||||
|
@ -944,8 +909,7 @@ DART_EXPORT bool Dart_IsString16(Dart_Handle object) {
|
|||
DART_EXPORT Dart_Handle Dart_StringGet8(Dart_Handle str,
|
||||
uint8_t* codepoints,
|
||||
intptr_t* length) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(str));
|
||||
if (obj.IsOneByteString()) {
|
||||
OneByteString& string_obj = OneByteString::Handle();
|
||||
|
@ -967,8 +931,7 @@ DART_EXPORT Dart_Handle Dart_StringGet8(Dart_Handle str,
|
|||
DART_EXPORT Dart_Handle Dart_StringGet16(Dart_Handle str,
|
||||
uint16_t* codepoints,
|
||||
intptr_t* length) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(str));
|
||||
if (obj.IsOneByteString() || obj.IsTwoByteString()) {
|
||||
String& string_obj = String::Handle();
|
||||
|
@ -990,8 +953,7 @@ DART_EXPORT Dart_Handle Dart_StringGet16(Dart_Handle str,
|
|||
DART_EXPORT Dart_Handle Dart_StringGet32(Dart_Handle str,
|
||||
uint32_t* codepoints,
|
||||
intptr_t* length) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(str));
|
||||
if (obj.IsString()) {
|
||||
String& string_obj = String::Handle();
|
||||
|
@ -1010,8 +972,7 @@ DART_EXPORT Dart_Handle Dart_StringGet32(Dart_Handle str,
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle object,
|
||||
const char** result) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
if (obj.IsString()) {
|
||||
const char* string_value = obj.ToCString();
|
||||
|
@ -1041,26 +1002,25 @@ static RawInstance* GetListInstance(Isolate* isolate, const Object& obj) {
|
|||
|
||||
|
||||
DART_EXPORT bool Dart_IsList(Dart_Handle object) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
// TODO(5526318): Make access to GrowableObjectArray more efficient.
|
||||
return (obj.IsArray() ||
|
||||
(GetListInstance(Isolate::Current(), obj) != Instance::null()));
|
||||
(GetListInstance(isolate, obj) != Instance::null()));
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_NewList(intptr_t length) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Array& obj = Array::Handle(Array::New(length));
|
||||
return Api::NewLocalHandle(obj);
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t* len) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(list));
|
||||
if (obj.IsArray()) {
|
||||
Array& array_obj = Array::Handle();
|
||||
|
@ -1070,7 +1030,6 @@ DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t* len) {
|
|||
}
|
||||
// TODO(5526318): Make access to GrowableObjectArray more efficient.
|
||||
// Now check and handle a dart object that implements the List interface.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
const Instance& instance = Instance::Handle(GetListInstance(isolate, obj));
|
||||
if (!instance.IsNull()) {
|
||||
String& name = String::Handle(String::New("length"));
|
||||
|
@ -1157,8 +1116,8 @@ DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list,
|
|||
intptr_t offset,
|
||||
uint8_t* native_array,
|
||||
intptr_t length) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(list));
|
||||
if (obj.IsArray()) {
|
||||
Array& array_obj = Array::Handle();
|
||||
|
@ -1180,7 +1139,6 @@ DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list,
|
|||
}
|
||||
// TODO(5526318): Make access to GrowableObjectArray more efficient.
|
||||
// Now check and handle a dart object that implements the List interface.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
const Instance& instance = Instance::Handle(GetListInstance(isolate, obj));
|
||||
if (!instance.IsNull()) {
|
||||
String& name = String::Handle(String::New("[]"));
|
||||
|
@ -1210,8 +1168,8 @@ DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list,
|
|||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_ListGetAt(Dart_Handle list, intptr_t index) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(list));
|
||||
if (obj.IsArray()) {
|
||||
Array& array_obj = Array::Handle();
|
||||
|
@ -1224,7 +1182,6 @@ DART_EXPORT Dart_Handle Dart_ListGetAt(Dart_Handle list, intptr_t index) {
|
|||
}
|
||||
// TODO(5526318): Make access to GrowableObjectArray more efficient.
|
||||
// Now check and handle a dart object that implements the List interface.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
const Instance& instance = Instance::Handle(GetListInstance(isolate, obj));
|
||||
if (!instance.IsNull()) {
|
||||
String& name = String::Handle(String::New("[]"));
|
||||
|
@ -1283,8 +1240,8 @@ DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list,
|
|||
intptr_t offset,
|
||||
uint8_t* native_array,
|
||||
intptr_t length) {
|
||||
Zone zone;
|
||||
HandleScope scope;
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(list));
|
||||
if (obj.IsArray()) {
|
||||
Array& array_obj = Array::Handle();
|
||||
|
@ -1301,7 +1258,6 @@ DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list,
|
|||
}
|
||||
// TODO(5526318): Make access to GrowableObjectArray more efficient.
|
||||
// Now check and handle a dart object that implements the List interface.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
const Instance& instance = Instance::Handle(GetListInstance(isolate, obj));
|
||||
if (!instance.IsNull()) {
|
||||
String& name = String::Handle(String::New("[]="));
|
||||
|
@ -1329,8 +1285,8 @@ DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list,
|
|||
DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list,
|
||||
intptr_t index,
|
||||
Dart_Handle value) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(list));
|
||||
if (obj.IsArray()) {
|
||||
Array& array_obj = Array::Handle();
|
||||
|
@ -1344,7 +1300,6 @@ DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list,
|
|||
}
|
||||
// TODO(5526318): Make access to GrowableObjectArray more efficient.
|
||||
// Now check and handle a dart object that implements the List interface.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
const Instance& instance = Instance::Handle(GetListInstance(isolate, obj));
|
||||
if (!instance.IsNull()) {
|
||||
String& name = String::Handle(String::New("[]="));
|
||||
|
@ -1365,10 +1320,10 @@ DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list,
|
|||
// NOTE: Need to pass 'result' as a parameter here in order to avoid
|
||||
// warning: variable 'result' might be clobbered by 'longjmp' or 'vfork'
|
||||
// which shows up because of the use of setjmp.
|
||||
static void InvokeStatic(const Function& function,
|
||||
static void InvokeStatic(Isolate* isolate,
|
||||
const Function& function,
|
||||
GrowableArray<const Object*>& args,
|
||||
Dart_Handle* result) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
ASSERT(isolate != NULL);
|
||||
LongJump* base = isolate->long_jump_base();
|
||||
LongJump jump;
|
||||
|
@ -1392,11 +1347,11 @@ static void InvokeStatic(const Function& function,
|
|||
// NOTE: Need to pass 'result' as a parameter here in order to avoid
|
||||
// warning: variable 'result' might be clobbered by 'longjmp' or 'vfork'
|
||||
// which shows up because of the use of setjmp.
|
||||
static void InvokeDynamic(const Instance& receiver,
|
||||
static void InvokeDynamic(Isolate* isolate,
|
||||
const Instance& receiver,
|
||||
const Function& function,
|
||||
GrowableArray<const Object*>& args,
|
||||
Dart_Handle* result) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
ASSERT(isolate != NULL);
|
||||
LongJump* base = isolate->long_jump_base();
|
||||
LongJump jump;
|
||||
|
@ -1420,10 +1375,10 @@ static void InvokeDynamic(const Instance& receiver,
|
|||
// NOTE: Need to pass 'result' as a parameter here in order to avoid
|
||||
// warning: variable 'result' might be clobbered by 'longjmp' or 'vfork'
|
||||
// which shows up because of the use of setjmp.
|
||||
static void InvokeClosure(const Closure& closure,
|
||||
static void InvokeClosure(Isolate* isolate,
|
||||
const Closure& closure,
|
||||
GrowableArray<const Object*>& args,
|
||||
Dart_Handle* result) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
ASSERT(isolate != NULL);
|
||||
LongJump* base = isolate->long_jump_base();
|
||||
LongJump jump;
|
||||
|
@ -1449,10 +1404,10 @@ DART_EXPORT Dart_Handle Dart_InvokeStatic(Dart_Handle library_in,
|
|||
Dart_Handle function_name_in,
|
||||
int number_of_arguments,
|
||||
Dart_Handle* arguments) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
// Finalize all classes.
|
||||
const char* msg = CheckIsolateState();
|
||||
const char* msg = CheckIsolateState(isolate);
|
||||
if (msg != NULL) {
|
||||
return Api::Error(msg);
|
||||
}
|
||||
|
@ -1499,7 +1454,7 @@ DART_EXPORT Dart_Handle Dart_InvokeStatic(Dart_Handle library_in,
|
|||
const Object& arg = Object::Handle(Api::UnwrapHandle(arguments[i]));
|
||||
dart_arguments.Add(&arg);
|
||||
}
|
||||
InvokeStatic(function, dart_arguments, &retval);
|
||||
InvokeStatic(isolate, function, dart_arguments, &retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -1508,8 +1463,8 @@ DART_EXPORT Dart_Handle Dart_InvokeDynamic(Dart_Handle object,
|
|||
Dart_Handle function_name,
|
||||
int number_of_arguments,
|
||||
Dart_Handle* arguments) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(object));
|
||||
// Let the resolver figure out the correct target for null receiver.
|
||||
// E.g., (null).toString() should execute correctly.
|
||||
|
@ -1542,7 +1497,7 @@ DART_EXPORT Dart_Handle Dart_InvokeDynamic(Dart_Handle object,
|
|||
const Object& arg = Object::Handle(Api::UnwrapHandle(arguments[i]));
|
||||
dart_arguments.Add(&arg);
|
||||
}
|
||||
InvokeDynamic(receiver, function, dart_arguments, &retval);
|
||||
InvokeDynamic(isolate, receiver, function, dart_arguments, &retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -1550,8 +1505,8 @@ DART_EXPORT Dart_Handle Dart_InvokeDynamic(Dart_Handle object,
|
|||
DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure,
|
||||
int number_of_arguments,
|
||||
Dart_Handle* arguments) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& obj = Object::Handle(Api::UnwrapHandle(closure));
|
||||
if (obj.IsNull()) {
|
||||
return Api::Error("Null object passed in to invoke closure");
|
||||
|
@ -1570,15 +1525,14 @@ DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure,
|
|||
const Object& arg = Object::Handle(Api::UnwrapHandle(arguments[i]));
|
||||
dart_arguments.Add(&arg);
|
||||
}
|
||||
InvokeClosure(closure_obj, dart_arguments, &retval);
|
||||
InvokeClosure(isolate, closure_obj, dart_arguments, &retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args,
|
||||
int index) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
|
||||
const Object& obj = Object::Handle(arguments->At(index));
|
||||
return Api::NewLocalHandle(obj);
|
||||
|
@ -1593,8 +1547,7 @@ DART_EXPORT int Dart_GetNativeArgumentCount(Dart_NativeArguments args) {
|
|||
|
||||
DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args,
|
||||
Dart_Handle retval) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
|
||||
arguments->SetReturn(Object::Handle(Api::UnwrapHandle(retval)));
|
||||
}
|
||||
|
@ -1602,9 +1555,7 @@ DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args,
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
ASSERT(isolate != NULL);
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(isolate);
|
||||
if (isolate->top_exit_frame_info() == 0) {
|
||||
// There are no dart frames on the stack so it would be illegal to
|
||||
// throw an exception here.
|
||||
|
@ -1630,8 +1581,7 @@ DART_EXPORT Dart_Handle Dart_ReThrowException(Dart_Handle exception,
|
|||
// throw an exception here.
|
||||
return Api::Error("No Dart frames on stack, cannot throw exception");
|
||||
}
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(isolate);
|
||||
const Instance& excp = Instance::CheckedHandle(Api::UnwrapHandle(exception));
|
||||
const Instance& stk = Instance::CheckedHandle(Api::UnwrapHandle(stacktrace));
|
||||
// Unwind all the API scopes till the exit frame before throwing an
|
||||
|
@ -1669,10 +1619,8 @@ DART_EXPORT void Dart_ExitScope() {
|
|||
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_NewPersistentHandle(Dart_Handle object) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
ASSERT(isolate != NULL);
|
||||
DARTSCOPE(isolate);
|
||||
ApiState* state = isolate->api_state();
|
||||
ASSERT(state != NULL);
|
||||
const Object& old_ref = Object::Handle(Api::UnwrapHandle(object));
|
||||
|
@ -1793,8 +1741,8 @@ static Dart_Handle LookupInstanceField(const Object& object,
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_GetStaticField(Dart_Handle cls,
|
||||
Dart_Handle name) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
Dart_Handle result = LookupStaticField(cls, name, kGetter);
|
||||
if (::Dart_IsError(result)) {
|
||||
return result;
|
||||
|
@ -1810,7 +1758,7 @@ DART_EXPORT Dart_Handle Dart_GetStaticField(Dart_Handle cls,
|
|||
Function& func = Function::Handle();
|
||||
func ^= obj.raw();
|
||||
GrowableArray<const Object*> args;
|
||||
InvokeStatic(func, args, &result);
|
||||
InvokeStatic(isolate, func, args, &result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1821,8 +1769,7 @@ DART_EXPORT Dart_Handle Dart_GetStaticField(Dart_Handle cls,
|
|||
DART_EXPORT Dart_Handle Dart_SetStaticField(Dart_Handle cls,
|
||||
Dart_Handle name,
|
||||
Dart_Handle value) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
Dart_Handle result = LookupStaticField(cls, name, kSetter);
|
||||
if (::Dart_IsError(result)) {
|
||||
return result;
|
||||
|
@ -1842,8 +1789,8 @@ DART_EXPORT Dart_Handle Dart_SetStaticField(Dart_Handle cls,
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_GetInstanceField(Dart_Handle obj,
|
||||
Dart_Handle name) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& param = Object::Handle(Api::UnwrapHandle(obj));
|
||||
if (param.IsNull() || !param.IsInstance()) {
|
||||
return Api::Error("Invalid object passed in to access instance field");
|
||||
|
@ -1857,7 +1804,7 @@ DART_EXPORT Dart_Handle Dart_GetInstanceField(Dart_Handle obj,
|
|||
Function& func = Function::Handle();
|
||||
func ^= Api::UnwrapHandle(result);
|
||||
GrowableArray<const Object*> arguments;
|
||||
InvokeDynamic(object, func, arguments, &result);
|
||||
InvokeDynamic(isolate, object, func, arguments, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1865,8 +1812,8 @@ DART_EXPORT Dart_Handle Dart_GetInstanceField(Dart_Handle obj,
|
|||
DART_EXPORT Dart_Handle Dart_SetInstanceField(Dart_Handle obj,
|
||||
Dart_Handle name,
|
||||
Dart_Handle value) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& param = Object::Handle(Api::UnwrapHandle(obj));
|
||||
if (param.IsNull() || !param.IsInstance()) {
|
||||
return Api::Error("Invalid object passed in to access instance field");
|
||||
|
@ -1882,7 +1829,7 @@ DART_EXPORT Dart_Handle Dart_SetInstanceField(Dart_Handle obj,
|
|||
GrowableArray<const Object*> arguments(1);
|
||||
const Object& arg = Object::Handle(Api::UnwrapHandle(value));
|
||||
arguments.Add(&arg);
|
||||
InvokeDynamic(object, func, arguments, &result);
|
||||
InvokeDynamic(isolate, object, func, arguments, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1890,8 +1837,8 @@ DART_EXPORT Dart_Handle Dart_SetInstanceField(Dart_Handle obj,
|
|||
DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library,
|
||||
Dart_Handle name,
|
||||
int field_count) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
const Object& param = Object::Handle(Api::UnwrapHandle(name));
|
||||
if (param.IsNull() || !param.IsString() || field_count <= 0) {
|
||||
return Api::Error(
|
||||
|
@ -1920,8 +1867,7 @@ DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library,
|
|||
DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj,
|
||||
int index,
|
||||
intptr_t* value) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& param = Object::Handle(Api::UnwrapHandle(obj));
|
||||
if (param.IsNull() || !param.IsInstance()) {
|
||||
return Api::Error(
|
||||
|
@ -1941,8 +1887,7 @@ DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj,
|
|||
DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj,
|
||||
int index,
|
||||
intptr_t value) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& param = Object::Handle(Api::UnwrapHandle(obj));
|
||||
if (param.IsNull() || !param.IsInstance()) {
|
||||
return Api::Error("Invalid object passed in to set native instance field");
|
||||
|
@ -1969,17 +1914,16 @@ static uint8_t* ApiAllocator(uint8_t* ptr,
|
|||
|
||||
DART_EXPORT Dart_Handle Dart_CreateSnapshot(uint8_t** snapshot_buffer,
|
||||
intptr_t* snapshot_size) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
if (snapshot_buffer == NULL || snapshot_size == NULL) {
|
||||
return Api::Error("Invalid input parameters to Dart_CreateSnapshot");
|
||||
}
|
||||
const char* msg = CheckIsolateState();
|
||||
const char* msg = CheckIsolateState(isolate);
|
||||
if (msg != NULL) {
|
||||
return Api::Error(msg);
|
||||
}
|
||||
// Since this is only a snapshot the root library should not be set.
|
||||
Isolate* isolate = Isolate::Current();
|
||||
isolate->object_store()->set_root_library(Library::Handle());
|
||||
SnapshotWriter writer(true, snapshot_buffer, ApiAllocator);
|
||||
writer.WriteFullSnapshot();
|
||||
|
@ -2008,8 +1952,7 @@ DART_EXPORT bool Dart_PostIntArray(Dart_Port port,
|
|||
|
||||
|
||||
DART_EXPORT bool Dart_Post(Dart_Port port, Dart_Handle handle) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& object = Object::Handle(Api::UnwrapHandle(handle));
|
||||
uint8_t* data = NULL;
|
||||
SnapshotWriter writer(false, &data, &allocator);
|
||||
|
@ -2110,8 +2053,7 @@ Dart_Handle Api::Success() {
|
|||
|
||||
|
||||
Dart_Handle Api::Error(const char* format, ...) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
@ -2131,8 +2073,7 @@ Dart_Handle Api::Error(const char* format, ...) {
|
|||
|
||||
|
||||
Dart_Handle Api::ErrorFromException(const Object& obj) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
|
||||
ASSERT(obj.IsUnhandledException());
|
||||
if (obj.IsUnhandledException()) {
|
||||
|
|
|
@ -15,6 +15,12 @@ class Object;
|
|||
class PersistentHandle;
|
||||
class RawObject;
|
||||
|
||||
|
||||
#define DARTSCOPE(isolate) \
|
||||
ASSERT(isolate != NULL); \
|
||||
Zone zone(isolate); \
|
||||
HANDLESCOPE(isolate); \
|
||||
|
||||
class Api : AllStatic {
|
||||
public:
|
||||
// Creates a new local handle.
|
||||
|
|
|
@ -120,8 +120,7 @@ UNIT_TEST_CASE(IsSame) {
|
|||
|
||||
// Non-instance objects.
|
||||
{
|
||||
Zone zone;
|
||||
HandleScope hs;
|
||||
DARTSCOPE(Isolate::Current());
|
||||
const Object& cls1 = Object::Handle(Object::null_class());
|
||||
const Object& cls2 = Object::Handle(Object::class_class());
|
||||
Dart_Handle class1 = Api::NewLocalHandle(cls1);
|
||||
|
@ -542,8 +541,7 @@ UNIT_TEST_CASE(EnterExitScope) {
|
|||
Dart_EnterScope();
|
||||
{
|
||||
EXPECT(state->top_scope() != NULL);
|
||||
Zone zone;
|
||||
HandleScope hs;
|
||||
DARTSCOPE(isolate);
|
||||
const String& str1 = String::Handle(String::New("Test String"));
|
||||
Dart_Handle ref = Api::NewLocalHandle(str1);
|
||||
String& str2 = String::Handle();
|
||||
|
@ -569,8 +567,7 @@ UNIT_TEST_CASE(PersistentHandles) {
|
|||
Dart_Handle handles[2000];
|
||||
Dart_EnterScope();
|
||||
{
|
||||
Zone zone;
|
||||
HandleScope hs;
|
||||
DARTSCOPE(isolate);
|
||||
const String& str1 = String::Handle(String::New(kTestString1));
|
||||
Dart_Handle ref1 = Api::NewLocalHandle(str1);
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
|
@ -596,8 +593,7 @@ UNIT_TEST_CASE(PersistentHandles) {
|
|||
}
|
||||
Dart_ExitScope();
|
||||
{
|
||||
Zone zone;
|
||||
HandleScope hs;
|
||||
DARTSCOPE(isolate);
|
||||
for (int i = 0; i < 500; i++) {
|
||||
String& str = String::Handle();
|
||||
str ^= Api::UnwrapHandle(handles[i]);
|
||||
|
@ -666,8 +662,7 @@ UNIT_TEST_CASE(LocalHandles) {
|
|||
ApiLocalScope* scope = state->top_scope();
|
||||
Dart_Handle handles[300];
|
||||
{
|
||||
Zone zone;
|
||||
HandleScope hs;
|
||||
DARTSCOPE(isolate);
|
||||
Smi& val = Smi::Handle();
|
||||
|
||||
// Start a new scope and allocate some local handles.
|
||||
|
@ -1012,8 +1007,7 @@ UNIT_TEST_CASE(InjectNativeFields1) {
|
|||
|
||||
Dart_CreateIsolate(NULL, NULL);
|
||||
{
|
||||
Zone zone;
|
||||
HandleScope scope;
|
||||
DARTSCOPE(Isolate::Current());
|
||||
Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
|
||||
const int kNumNativeFields = 4;
|
||||
|
||||
|
@ -1232,8 +1226,7 @@ UNIT_TEST_CASE(NegativeNativeFieldAccess) {
|
|||
|
||||
Dart_CreateIsolate(NULL, NULL);
|
||||
{
|
||||
Zone zone;
|
||||
HandleScope scope;
|
||||
DARTSCOPE(Isolate::Current());
|
||||
Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
|
||||
|
||||
// Create a test library and Load up a test script in it.
|
||||
|
@ -1419,8 +1412,7 @@ UNIT_TEST_CASE(InvokeDynamic) {
|
|||
|
||||
Dart_CreateIsolate(NULL, NULL);
|
||||
{
|
||||
Zone zone;
|
||||
HandleScope scope;
|
||||
DARTSCOPE(Isolate::Current());
|
||||
Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
|
||||
|
||||
// Create a test library and Load up a test script in it.
|
||||
|
@ -1489,8 +1481,7 @@ UNIT_TEST_CASE(InvokeClosure) {
|
|||
|
||||
Dart_CreateIsolate(NULL, NULL);
|
||||
{
|
||||
Zone zone;
|
||||
HandleScope scope;
|
||||
DARTSCOPE(Isolate::Current());
|
||||
Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
|
||||
|
||||
// Create a test library and Load up a test script in it.
|
||||
|
@ -1784,8 +1775,7 @@ UNIT_TEST_CASE(NullReceiver) {
|
|||
Dart_CreateIsolate(NULL, NULL);
|
||||
Dart_EnterScope(); // Enter a Dart API scope for the unit test.
|
||||
{
|
||||
Zone zone;
|
||||
HandleScope hs;
|
||||
DARTSCOPE(Isolate::Current());
|
||||
|
||||
Dart_Handle function_name = Dart_NewString("toString");
|
||||
const int number_of_arguments = 0;
|
||||
|
|
|
@ -347,8 +347,7 @@ class ApiState {
|
|||
}
|
||||
PersistentHandle* Null() {
|
||||
if (null_ == NULL) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
|
||||
Object& null_object = Object::Handle();
|
||||
null_ = persistent_handles().AllocateHandle();
|
||||
|
@ -359,8 +358,7 @@ class ApiState {
|
|||
}
|
||||
PersistentHandle* True() {
|
||||
if (true_ == NULL) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
|
||||
const Object& true_object = Object::Handle(Bool::True());
|
||||
true_ = persistent_handles().AllocateHandle();
|
||||
|
@ -371,8 +369,7 @@ class ApiState {
|
|||
}
|
||||
PersistentHandle* False() {
|
||||
if (false_ == NULL) {
|
||||
Zone zone; // Setup a VM zone as we are creating some handles.
|
||||
HandleScope scope; // Setup a VM handle scope.
|
||||
DARTSCOPE(Isolate::Current());
|
||||
|
||||
const Object& false_object = Object::Handle(Bool::False());
|
||||
false_ = persistent_handles().AllocateHandle();
|
||||
|
|
|
@ -69,15 +69,15 @@ int VMHandles::ZoneHandleCount() {
|
|||
}
|
||||
|
||||
|
||||
HandleScope::HandleScope() : StackResource() {
|
||||
ASSERT(isolate()->no_handle_scope_depth() == 0);
|
||||
VMHandles* handles = isolate()->current_zone()->handles();
|
||||
HandleScope::HandleScope(Isolate* isolate) : StackResource(isolate) {
|
||||
ASSERT(isolate->no_handle_scope_depth() == 0);
|
||||
VMHandles* handles = isolate->current_zone()->handles();
|
||||
ASSERT(handles != NULL);
|
||||
saved_handle_block_ = handles->scoped_blocks_;
|
||||
saved_handle_slot_ = handles->scoped_blocks_->next_handle_slot();
|
||||
#if defined(DEBUG)
|
||||
link_ = isolate()->top_handle_scope();
|
||||
isolate()->set_top_handle_scope(this);
|
||||
link_ = isolate->top_handle_scope();
|
||||
isolate->set_top_handle_scope(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -98,8 +98,8 @@ HandleScope::~HandleScope() {
|
|||
|
||||
|
||||
#if defined(DEBUG)
|
||||
NoHandleScope::NoHandleScope() : StackResource() {
|
||||
isolate()->IncrementNoHandleScopeDepth();
|
||||
NoHandleScope::NoHandleScope(Isolate* isolate) : StackResource(isolate) {
|
||||
isolate->IncrementNoHandleScopeDepth();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace dart {
|
|||
// object is destroyed.
|
||||
// Code that uses scoped handles typically looks as follows:
|
||||
// {
|
||||
// HANDLESCOPE();
|
||||
// HANDLESCOPE(isolate);
|
||||
// const String& str = String::Handle(String::New("abc"));
|
||||
// .....
|
||||
// .....
|
||||
|
@ -48,7 +48,7 @@ namespace dart {
|
|||
// raw dart objects directly. We use NOHANDLESCOPE to assert that we do not
|
||||
// add code that will allocate new handles during this critical area.
|
||||
// {
|
||||
// NOHANDLESCOPE();
|
||||
// NOHANDLESCOPE(isolate);
|
||||
// ....
|
||||
// ....
|
||||
// }
|
||||
|
@ -243,7 +243,7 @@ class VMHandles : public Handles<kVMHandleSizeInWords,
|
|||
// The class HandleScope is used to start a new handles scope in the code.
|
||||
// It is used as follows:
|
||||
// {
|
||||
// HANDLESCOPE();
|
||||
// HANDLESCOPE(isolate);
|
||||
// ....
|
||||
// .....
|
||||
// code that creates some scoped handles.
|
||||
|
@ -251,7 +251,7 @@ class VMHandles : public Handles<kVMHandleSizeInWords,
|
|||
// }
|
||||
class HandleScope : public StackResource {
|
||||
public:
|
||||
HandleScope();
|
||||
explicit HandleScope(Isolate* isolate);
|
||||
~HandleScope();
|
||||
|
||||
private:
|
||||
|
@ -264,7 +264,8 @@ class HandleScope : public StackResource {
|
|||
};
|
||||
|
||||
// Macro to start a new Handle scope.
|
||||
#define HANDLESCOPE() dart::HandleScope vm_internal_handles_scope_;
|
||||
#define HANDLESCOPE(isolate) \
|
||||
dart::HandleScope vm_internal_handles_scope_(isolate);
|
||||
|
||||
|
||||
// The class NoHandleScope is used in critical regions of the virtual machine
|
||||
|
@ -273,7 +274,7 @@ class HandleScope : public StackResource {
|
|||
// during this critical area.
|
||||
// It is used as follows:
|
||||
// {
|
||||
// NOHANDLESCOPE();
|
||||
// NOHANDLESCOPE(isolate);
|
||||
// ....
|
||||
// .....
|
||||
// critical code that manipulates dart objects directly.
|
||||
|
@ -282,7 +283,7 @@ class HandleScope : public StackResource {
|
|||
#if defined(DEBUG)
|
||||
class NoHandleScope : public StackResource {
|
||||
public:
|
||||
NoHandleScope();
|
||||
explicit NoHandleScope(Isolate* isolate);
|
||||
~NoHandleScope();
|
||||
|
||||
private:
|
||||
|
@ -291,7 +292,7 @@ class NoHandleScope : public StackResource {
|
|||
#else // defined(DEBUG)
|
||||
class NoHandleScope : public ValueObject {
|
||||
public:
|
||||
NoHandleScope() { }
|
||||
explicit NoHandleScope(Isolate* isolate) { }
|
||||
~NoHandleScope() { }
|
||||
|
||||
private:
|
||||
|
@ -300,7 +301,8 @@ class NoHandleScope : public ValueObject {
|
|||
#endif // defined(DEBUG)
|
||||
|
||||
// Macro to start a no handles scope in the code.
|
||||
#define NOHANDLESCOPE() dart::NoHandleScope no_vm_internal_handles_scope_;
|
||||
#define NOHANDLESCOPE(isolate) \
|
||||
dart::NoHandleScope no_vm_internal_handles_scope_(isolate);
|
||||
|
||||
} // namespace dart
|
||||
|
||||
|
|
|
@ -49,7 +49,8 @@ TEST_CASE(AllocateScopeHandle) {
|
|||
static const int kNumHandles = 65;
|
||||
// Create some scoped handles.
|
||||
{
|
||||
HANDLESCOPE();
|
||||
Isolate* isolate = Isolate::Current();
|
||||
HANDLESCOPE(isolate);
|
||||
for (int i = 0; i < kNumHandles; i++) {
|
||||
const Smi& handle = Smi::Handle(Smi::New(i));
|
||||
EXPECT(handle.IsSmi());
|
||||
|
@ -58,7 +59,7 @@ TEST_CASE(AllocateScopeHandle) {
|
|||
EXPECT_EQ((handle_count + kNumHandles), VMHandles::ScopedHandleCount());
|
||||
// Create lots of scoped handles in a loop with a nested scope.
|
||||
for (int loop = 0; loop < 1000; loop++) {
|
||||
HANDLESCOPE();
|
||||
HANDLESCOPE(isolate);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
const Smi& handle = Smi::Handle(Smi::New(i + loop));
|
||||
EXPECT(handle.IsSmi());
|
||||
|
|
|
@ -137,13 +137,13 @@ uword Heap::EndAddress() {
|
|||
|
||||
|
||||
#if defined(DEBUG)
|
||||
NoGCScope::NoGCScope() : StackResource(), isolate_(Isolate::Current()) {
|
||||
isolate_->IncrementNoGCScopeDepth();
|
||||
NoGCScope::NoGCScope() : StackResource(Isolate::Current()) {
|
||||
isolate()->IncrementNoGCScopeDepth();
|
||||
}
|
||||
|
||||
|
||||
NoGCScope::~NoGCScope() {
|
||||
isolate_->DecrementNoGCScopeDepth();
|
||||
isolate()->DecrementNoGCScopeDepth();
|
||||
}
|
||||
#endif // defined(DEBUG)
|
||||
|
||||
|
|
|
@ -88,8 +88,6 @@ class NoGCScope : public StackResource {
|
|||
NoGCScope();
|
||||
~NoGCScope();
|
||||
private:
|
||||
Isolate* isolate_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NoGCScope);
|
||||
};
|
||||
#else // defined(DEBUG)
|
||||
|
|
|
@ -162,8 +162,9 @@ static int MostCalledFunctionFirst(const Function* const* a,
|
|||
|
||||
|
||||
void Isolate::PrintInvokedFunctions() {
|
||||
Zone zone;
|
||||
HandleScope handle_scope;
|
||||
ASSERT(this == Isolate::Current());
|
||||
Zone zone(this);
|
||||
HandleScope handle_scope(this);
|
||||
Library& library = Library::Handle();
|
||||
library = object_store()->registered_libraries();
|
||||
GrowableArray<const Function*> invoked_functions;
|
||||
|
@ -241,8 +242,9 @@ void Isolate::StandardRunLoop() {
|
|||
ASSERT(close_port_callback() == &StandardClosePortCallback);
|
||||
|
||||
while (active_ports() > 0) {
|
||||
Zone zone;
|
||||
HandleScope handle_scope;
|
||||
ASSERT(this == Isolate::Current());
|
||||
Zone zone(this);
|
||||
HandleScope handle_scope(this);
|
||||
|
||||
PortMessage* message = message_queue()->Dequeue(0);
|
||||
if (message != NULL) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
namespace dart {
|
||||
|
||||
// Forward declarations.
|
||||
class Isolate;
|
||||
class Object;
|
||||
class RawObject;
|
||||
|
||||
|
@ -31,6 +32,7 @@ class RawObject;
|
|||
// subclass of ValueObject.
|
||||
class NativeArguments {
|
||||
public:
|
||||
Isolate* isolate() const { return isolate_; }
|
||||
int Count() const { return argc_; }
|
||||
|
||||
RawObject* At(int index) const {
|
||||
|
@ -40,6 +42,9 @@ class NativeArguments {
|
|||
|
||||
void SetReturn(const Object& value) const;
|
||||
|
||||
static intptr_t isolate_offset() {
|
||||
return OFFSET_OF(NativeArguments, isolate_);
|
||||
}
|
||||
static intptr_t argc_offset() { return OFFSET_OF(NativeArguments, argc_); }
|
||||
static intptr_t argv_offset() { return OFFSET_OF(NativeArguments, argv_); }
|
||||
static intptr_t retval_offset() {
|
||||
|
@ -47,6 +52,7 @@ class NativeArguments {
|
|||
}
|
||||
|
||||
private:
|
||||
Isolate* isolate_; // Current isolate pointer.
|
||||
int argc_; // Number of arguments passed to the runtime call.
|
||||
RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call.
|
||||
RawObject** retval_; // Pointer to the return value area.
|
||||
|
|
|
@ -32,7 +32,7 @@ typedef void (*NativeFunction)(NativeArguments* arguments);
|
|||
|
||||
|
||||
#define DEFINE_NATIVE_ENTRY(name, argument_count) \
|
||||
static void DN_Helper##name(NativeArguments* arguments); \
|
||||
static void DN_Helper##name(Isolate* isolate, NativeArguments* arguments); \
|
||||
void NATIVE_ENTRY_FUNCTION(name)(Dart_NativeArguments args) { \
|
||||
CHECK_STACK_ALIGNMENT; \
|
||||
VERIFY_ON_TRANSITION; \
|
||||
|
@ -40,13 +40,13 @@ typedef void (*NativeFunction)(NativeArguments* arguments);
|
|||
ASSERT(arguments->Count() == argument_count); \
|
||||
if (FLAG_trace_natives) OS::Print("Calling native: %s\n", ""#name); \
|
||||
{ \
|
||||
Zone zone; \
|
||||
HANDLESCOPE(); \
|
||||
DN_Helper##name(arguments); \
|
||||
Zone zone(arguments->isolate()); \
|
||||
HANDLESCOPE(arguments->isolate()); \
|
||||
DN_Helper##name(arguments->isolate(), arguments); \
|
||||
} \
|
||||
VERIFY_ON_TRANSITION; \
|
||||
} \
|
||||
static void DN_Helper##name(NativeArguments* arguments)
|
||||
static void DN_Helper##name(Isolate* isolate, NativeArguments* arguments)
|
||||
|
||||
|
||||
#define DECLARE_NATIVE_ENTRY(name, argument_count) \
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "vm/raw_object.h"
|
||||
|
||||
#include "vm/isolate.h"
|
||||
#include "vm/object.h"
|
||||
#include "vm/visitor.h"
|
||||
|
||||
|
@ -25,7 +26,7 @@ void RawObject::Validate() const {
|
|||
|
||||
|
||||
intptr_t RawObject::Size() const {
|
||||
NoHandleScope no_handles;
|
||||
NoHandleScope no_handles(Isolate::Current());
|
||||
|
||||
// Only reasonable to be called on heap objects.
|
||||
ASSERT(IsHeapObject());
|
||||
|
@ -143,7 +144,7 @@ intptr_t RawObject::Size() const {
|
|||
|
||||
intptr_t RawObject::VisitPointers(ObjectPointerVisitor* visitor) {
|
||||
intptr_t size = 0;
|
||||
NoHandleScope no_handles;
|
||||
NoHandleScope no_handles(Isolate::Current());
|
||||
|
||||
// Only reasonable to be called on heap objects.
|
||||
ASSERT(IsHeapObject());
|
||||
|
|
|
@ -52,19 +52,19 @@ class RuntimeEntry : public ValueObject {
|
|||
extern void DRT_##name(NativeArguments arguments); \
|
||||
extern const RuntimeEntry k##name##RuntimeEntry( \
|
||||
"DRT_"#name, &DRT_##name, argument_count); \
|
||||
static void DRT_Helper##name(NativeArguments arguments); \
|
||||
static void DRT_Helper##name(Isolate* isolate, NativeArguments arguments); \
|
||||
void DRT_##name(NativeArguments arguments) { \
|
||||
CHECK_STACK_ALIGNMENT; \
|
||||
VERIFY_ON_TRANSITION; \
|
||||
if (FLAG_trace_runtime_calls) OS::Print("Runtime call: %s\n", ""#name); \
|
||||
{ \
|
||||
Zone zone; \
|
||||
HANDLESCOPE(); \
|
||||
DRT_Helper##name(arguments); \
|
||||
Zone zone(arguments.isolate()); \
|
||||
HANDLESCOPE(arguments.isolate()); \
|
||||
DRT_Helper##name(arguments.isolate(), arguments); \
|
||||
} \
|
||||
VERIFY_ON_TRANSITION; \
|
||||
} \
|
||||
static void DRT_Helper##name(NativeArguments arguments)
|
||||
static void DRT_Helper##name(Isolate* isolate, NativeArguments arguments)
|
||||
|
||||
#define DECLARE_RUNTIME_ENTRY(name) \
|
||||
extern const RuntimeEntry k##name##RuntimeEntry
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "vm/scavenger.h"
|
||||
|
||||
#include "vm/dart.h"
|
||||
#include "vm/isolate.h"
|
||||
#include "vm/object.h"
|
||||
#include "vm/stack_frame.h"
|
||||
#include "vm/verifier.h"
|
||||
|
@ -165,9 +166,9 @@ void Scavenger::Epilogue() {
|
|||
}
|
||||
|
||||
|
||||
void Scavenger::IterateRoots(ObjectPointerVisitor* visitor) {
|
||||
Isolate::Current()->VisitObjectPointers(
|
||||
visitor, StackFrameIterator::kDontValidateFrames);
|
||||
void Scavenger::IterateRoots(Isolate* isolate, ObjectPointerVisitor* visitor) {
|
||||
isolate->VisitObjectPointers(visitor,
|
||||
StackFrameIterator::kDontValidateFrames);
|
||||
heap_->IterateOldPointers(visitor);
|
||||
}
|
||||
|
||||
|
@ -195,14 +196,15 @@ void Scavenger::Scavenge() {
|
|||
// Scavenging is not reentrant. Make sure that is the case.
|
||||
ASSERT(!scavenging_);
|
||||
scavenging_ = true;
|
||||
NoHandleScope no_handles;
|
||||
Isolate* isolate = Isolate::Current();
|
||||
NoHandleScope no_handles(isolate);
|
||||
|
||||
Timer timer(FLAG_verbose_gc, "Scavenge");
|
||||
timer.Start();
|
||||
// Setup the visitor and run a scavenge.
|
||||
ScavengerVisitor visitor(this);
|
||||
Prologue();
|
||||
IterateRoots(&visitor);
|
||||
IterateRoots(isolate, &visitor);
|
||||
ProcessToSpace(&visitor);
|
||||
Epilogue();
|
||||
timer.Stop();
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace dart {
|
|||
|
||||
// Forward declarations.
|
||||
class Heap;
|
||||
class Isolate;
|
||||
|
||||
class Scavenger {
|
||||
public:
|
||||
|
@ -68,7 +69,7 @@ class Scavenger {
|
|||
private:
|
||||
uword FirstObjectStart() const { return to_->start() | object_alignment_; }
|
||||
void Prologue();
|
||||
void IterateRoots(ObjectPointerVisitor* visitor);
|
||||
void IterateRoots(Isolate* isolate, ObjectPointerVisitor* visitor);
|
||||
void ProcessToSpace(ObjectPointerVisitor* visitor);
|
||||
void Epilogue();
|
||||
|
||||
|
|
|
@ -342,8 +342,9 @@ UNIT_TEST_CASE(FullSnapshot) {
|
|||
OS::PrintErr("Without Snapshot: %dus\n", timer1.TotalElapsedTime());
|
||||
|
||||
// Write snapshot with object content.
|
||||
Zone zone;
|
||||
HandleScope hs;
|
||||
Isolate* isolate = Isolate::Current();
|
||||
Zone zone(isolate);
|
||||
HandleScope scope(isolate);
|
||||
SnapshotWriter writer(true, &buffer, &allocator);
|
||||
writer.WriteFullSnapshot();
|
||||
|
||||
|
@ -394,8 +395,9 @@ UNIT_TEST_CASE(FullSnapshot1) {
|
|||
Dart_CreateIsolate(NULL, NULL);
|
||||
{
|
||||
Dart_EnterScope(); // Start a Dart API scope for invoking API functions.
|
||||
Zone zone;
|
||||
HandleScope hs;
|
||||
Isolate* isolate = Isolate::Current();
|
||||
Zone zone(isolate);
|
||||
HandleScope scope(isolate);
|
||||
|
||||
// Create a test library and Load up a test script in it.
|
||||
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
|
||||
|
|
|
@ -30,6 +30,7 @@ DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects.");
|
|||
// EDX : number of arguments to the call.
|
||||
// Must preserve callee saved registers EDI and EBX.
|
||||
static void GenerateCallRuntimeStub(Assembler* assembler) {
|
||||
const intptr_t isolate_offset = NativeArguments::isolate_offset();
|
||||
const intptr_t argc_offset = NativeArguments::argc_offset();
|
||||
const intptr_t argv_offset = NativeArguments::argv_offset();
|
||||
const intptr_t retval_offset = NativeArguments::retval_offset();
|
||||
|
@ -56,6 +57,7 @@ static void GenerateCallRuntimeStub(Assembler* assembler) {
|
|||
}
|
||||
|
||||
// Pass NativeArguments structure by value and call runtime.
|
||||
__ movl(Address(ESP, isolate_offset), CTX); // Set isolate in NativeArgs.
|
||||
__ movl(Address(ESP, argc_offset), EDX); // Set argc in NativeArguments.
|
||||
__ leal(EAX, Address(EBP, EDX, TIMES_4, 1 * kWordSize)); // Compute argv.
|
||||
__ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments.
|
||||
|
@ -118,6 +120,8 @@ void StubCode::GenerateStubCallToRuntimeStub(Assembler* assembler) {
|
|||
// Uses EDI.
|
||||
void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) {
|
||||
const intptr_t native_args_struct_offset = kWordSize;
|
||||
const intptr_t isolate_offset =
|
||||
NativeArguments::isolate_offset() + native_args_struct_offset;
|
||||
const intptr_t argc_offset =
|
||||
NativeArguments::argc_offset() + native_args_struct_offset;
|
||||
const intptr_t argv_offset =
|
||||
|
@ -149,6 +153,7 @@ void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) {
|
|||
}
|
||||
|
||||
// Pass NativeArguments structure by value and call runtime.
|
||||
__ movl(Address(ESP, isolate_offset), CTX); // Set isolate in NativeArgs.
|
||||
__ movl(Address(ESP, argc_offset), EDX); // Set argc in NativeArguments.
|
||||
__ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments.
|
||||
__ leal(EAX, Address(EBP, 2 * kWordSize)); // Compute return value addr.
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "vm/assert.h"
|
||||
#include "vm/allocation.h"
|
||||
#include "vm/globals.h"
|
||||
#include "vm/isolate.h"
|
||||
|
||||
// Declare the OS-specific types ahead of defining the generic classes.
|
||||
#if defined(TARGET_OS_LINUX)
|
||||
|
@ -85,7 +86,9 @@ class Monitor {
|
|||
|
||||
class MutexLocker : public StackResource {
|
||||
public:
|
||||
explicit MutexLocker(Mutex* mutex) : StackResource(), mutex_(mutex) {
|
||||
explicit MutexLocker(Mutex* mutex) :
|
||||
StackResource(Isolate::Current()),
|
||||
mutex_(mutex) {
|
||||
ASSERT(mutex != NULL);
|
||||
// TODO(iposva): Consider adding a no GC scope here.
|
||||
mutex_->Lock();
|
||||
|
@ -106,7 +109,7 @@ class MutexLocker : public StackResource {
|
|||
class MonitorLocker : public StackResource {
|
||||
public:
|
||||
explicit MonitorLocker(Monitor* monitor)
|
||||
: StackResource(),
|
||||
: StackResource(Isolate::Current()),
|
||||
monitor_(monitor) {
|
||||
ASSERT(monitor != NULL);
|
||||
// TODO(iposva): Consider adding a no GC scope here.
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
UNIT_TEST_CASE(name) \
|
||||
{ \
|
||||
TestIsolateScope __test_isolate__; \
|
||||
Zone __zone__; \
|
||||
HandleScope __hs__; \
|
||||
Zone __zone__(__test_isolate__.isolate()); \
|
||||
HandleScope __hs__(__test_isolate__.isolate()); \
|
||||
Dart_TestHelper##name(); \
|
||||
} \
|
||||
static void Dart_TestHelper##name()
|
||||
|
@ -183,6 +183,7 @@ class TestIsolateScope {
|
|||
Dart_ShutdownIsolate();
|
||||
isolate_ = NULL;
|
||||
}
|
||||
Isolate* isolate() const { return isolate_; }
|
||||
|
||||
private:
|
||||
Isolate* isolate_;
|
||||
|
|
|
@ -216,15 +216,16 @@ void BaseZone::DumpZoneSizes() {
|
|||
#endif
|
||||
|
||||
|
||||
Zone::Zone()
|
||||
: zone_(),
|
||||
Zone::Zone(Isolate* isolate)
|
||||
: StackResource(isolate),
|
||||
zone_(),
|
||||
handles_(),
|
||||
previous_(NULL) {
|
||||
// Assert that there is no current zone as we only want to scope
|
||||
// zones when transitioning from generated dart code to dart VM
|
||||
// runtime code.
|
||||
previous_ = isolate()->current_zone();
|
||||
isolate()->set_current_zone(this);
|
||||
previous_ = isolate->current_zone();
|
||||
isolate->set_current_zone(this);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@ namespace dart {
|
|||
// support deallocating all chunks in one fast operation.
|
||||
|
||||
class BaseZone {
|
||||
public:
|
||||
|
||||
private:
|
||||
BaseZone();
|
||||
~BaseZone(); // Delete all memory associated with the zone.
|
||||
|
@ -100,7 +98,7 @@ class BaseZone {
|
|||
class Zone : public StackResource {
|
||||
public:
|
||||
// Create an empty zone and set is at the current zone for the Isolate.
|
||||
Zone();
|
||||
explicit Zone(Isolate* isolate);
|
||||
|
||||
// Delete all memory associated with the zone.
|
||||
~Zone();
|
||||
|
|
|
@ -20,7 +20,7 @@ UNIT_TEST_CASE(AllocateZone) {
|
|||
EXPECT(Isolate::Current() == isolate);
|
||||
EXPECT(isolate->current_zone() == NULL);
|
||||
{
|
||||
Zone zone;
|
||||
Zone zone(isolate);
|
||||
EXPECT(isolate->current_zone() != NULL);
|
||||
intptr_t allocated_size = 0;
|
||||
|
||||
|
@ -94,7 +94,7 @@ UNIT_TEST_CASE(ZoneAllocated) {
|
|||
|
||||
// Create a few zone allocated objects.
|
||||
{
|
||||
Zone zone;
|
||||
Zone zone(isolate);
|
||||
EXPECT_EQ(0, zone.SizeInBytes());
|
||||
SimpleZoneObject* first = new SimpleZoneObject();
|
||||
EXPECT(first != NULL);
|
||||
|
|
Loading…
Reference in a new issue