mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 16:04:53 +00:00
Hide Isolate pointer from embedder
BUG= R=iposva@google.com Review URL: https://codereview.chromium.org//1130753006
This commit is contained in:
parent
97c4f89e69
commit
014e694ba7
|
@ -20,7 +20,7 @@ Builtin::builtin_lib_props Builtin::builtin_libraries_[] = {
|
|||
DartUtils::kIOLibPatchURL, io_patch_paths_, true },
|
||||
};
|
||||
|
||||
Dart_Port Builtin::load_port_ = ILLEGAL_PORT;
|
||||
Dart_Port Builtin::load_port_ = DART_ILLEGAL_PORT;
|
||||
|
||||
// Patch all the specified patch files in the array 'patch_files' into the
|
||||
// library specified in 'library'.
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace bin {
|
|||
|
||||
void Builtin::SetLoadPort(Dart_Port port) {
|
||||
load_port_ = port;
|
||||
ASSERT(load_port_ != ILLEGAL_PORT);
|
||||
ASSERT(load_port_ != DART_ILLEGAL_PORT);
|
||||
Dart_Handle field_name = DartUtils::NewString("_loadPort");
|
||||
ASSERT(!Dart_IsError(field_name));
|
||||
Dart_Handle builtin_lib =
|
||||
|
|
|
@ -20,7 +20,7 @@ Builtin::builtin_lib_props Builtin::builtin_libraries_[] = {
|
|||
{ DartUtils::kIOLibURL, NULL, NULL, NULL, true },
|
||||
};
|
||||
|
||||
Dart_Port Builtin::load_port_ = ILLEGAL_PORT;
|
||||
Dart_Port Builtin::load_port_ = DART_ILLEGAL_PORT;
|
||||
|
||||
Dart_Handle Builtin::Source(BuiltinLibraryId id) {
|
||||
return DartUtils::NewError("Unreachable code in Builtin::Source (%d).", id);
|
||||
|
|
|
@ -482,7 +482,7 @@ Dart_Handle DartUtils::LoadScript(const char* script_uri,
|
|||
Dart_Handle uri = Dart_NewStringFromCString(script_uri);
|
||||
|
||||
Dart_Port load_port = Dart_ServiceWaitForLoadPort();
|
||||
if (load_port == ILLEGAL_PORT) {
|
||||
if (load_port == DART_ILLEGAL_PORT) {
|
||||
return NewDartUnsupportedError("Service did not return load port.");
|
||||
}
|
||||
Builtin::SetLoadPort(load_port);
|
||||
|
|
|
@ -455,7 +455,8 @@ void DebuggerConnectionHandler::HandleInterruptCmd(DbgMessage* in_msg) {
|
|||
MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len());
|
||||
int msg_id = msg_parser.MessageId();
|
||||
Dart_IsolateId isolate_id = msg_parser.GetInt64Param("isolateId");
|
||||
if (isolate_id == ILLEGAL_ISOLATE_ID || Dart_GetIsolate(isolate_id) == NULL) {
|
||||
if (isolate_id == DART_ILLEGAL_ISOLATE_ID ||
|
||||
Dart_GetIsolate(isolate_id) == DART_ILLEGAL_ISOLATE) {
|
||||
in_msg->SendErrorReply(msg_id, "Invalid isolate specified");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ class DbgMsgQueue {
|
|||
msg = msglist_head_;
|
||||
}
|
||||
msglist_tail_ = NULL;
|
||||
isolate_id_ = ILLEGAL_ISOLATE_ID;
|
||||
isolate_id_ = DART_ILLEGAL_ISOLATE_ID;
|
||||
next_ = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ static void WriteSnapshotFile(const char* filename,
|
|||
class UriResolverIsolateScope {
|
||||
public:
|
||||
UriResolverIsolateScope() {
|
||||
ASSERT(isolate != NULL);
|
||||
ASSERT(isolate != DART_ILLEGAL_ISOLATE);
|
||||
snapshotted_isolate_ = Dart_CurrentIsolate();
|
||||
Dart_ExitIsolate();
|
||||
Dart_EnterIsolate(isolate);
|
||||
|
@ -179,7 +179,7 @@ class UriResolverIsolateScope {
|
|||
}
|
||||
|
||||
~UriResolverIsolateScope() {
|
||||
ASSERT(snapshotted_isolate_ != NULL);
|
||||
ASSERT(snapshotted_isolate_ != DART_ILLEGAL_ISOLATE);
|
||||
Dart_ExitScope();
|
||||
Dart_ExitIsolate();
|
||||
Dart_EnterIsolate(snapshotted_isolate_);
|
||||
|
@ -193,7 +193,7 @@ class UriResolverIsolateScope {
|
|||
DISALLOW_COPY_AND_ASSIGN(UriResolverIsolateScope);
|
||||
};
|
||||
|
||||
Dart_Isolate UriResolverIsolateScope::isolate = NULL;
|
||||
Dart_Isolate UriResolverIsolateScope::isolate = DART_ILLEGAL_ISOLATE;
|
||||
|
||||
|
||||
static Dart_Handle ResolveUriInWorkingDirectory(const char* script_uri) {
|
||||
|
@ -552,7 +552,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
char* error;
|
||||
Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, NULL, NULL, &error);
|
||||
if (isolate == NULL) {
|
||||
if (isolate == DART_ILLEGAL_ISOLATE) {
|
||||
Log::PrintErr("Error: %s", error);
|
||||
free(error);
|
||||
exit(255);
|
||||
|
@ -597,7 +597,8 @@ int main(int argc, char** argv) {
|
|||
|
||||
// Now we create an isolate into which we load all the code that needs to
|
||||
// be in the snapshot.
|
||||
if (Dart_CreateIsolate(NULL, NULL, NULL, NULL, &error) == NULL) {
|
||||
if (Dart_CreateIsolate(
|
||||
NULL, NULL, NULL, NULL, &error) == DART_ILLEGAL_ISOLATE) {
|
||||
fprintf(stderr, "%s", error);
|
||||
free(error);
|
||||
exit(255);
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace bin {
|
|||
|
||||
void IOServiceCallback(Dart_Port dest_port_id,
|
||||
Dart_CObject* message) {
|
||||
Dart_Port reply_port_id = ILLEGAL_PORT;
|
||||
Dart_Port reply_port_id = DART_ILLEGAL_PORT;
|
||||
CObject* response = CObject::IllegalArgumentError();
|
||||
CObjectArray request(message);
|
||||
if (message->type == Dart_CObject_kArray &&
|
||||
|
@ -51,7 +51,7 @@ void IOServiceCallback(Dart_Port dest_port_id,
|
|||
CObjectArray result(CObject::NewArray(2));
|
||||
result.SetAt(0, request[0]);
|
||||
result.SetAt(1, response);
|
||||
ASSERT(reply_port_id != ILLEGAL_PORT);
|
||||
ASSERT(reply_port_id != DART_ILLEGAL_PORT);
|
||||
Dart_PostCObject(reply_port_id, result.AsApiCObject());
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ Dart_Port IOService::GetServicePort() {
|
|||
void FUNCTION_NAME(IOService_NewServicePort)(Dart_NativeArguments args) {
|
||||
Dart_SetReturnValue(args, Dart_Null());
|
||||
Dart_Port service_port = IOService::GetServicePort();
|
||||
if (service_port != ILLEGAL_PORT) {
|
||||
if (service_port != DART_ILLEGAL_PORT) {
|
||||
// Return a send port for the service port.
|
||||
Dart_Handle send_port = Dart_NewSendPort(service_port);
|
||||
Dart_SetReturnValue(args, send_port);
|
||||
|
|
|
@ -591,8 +591,8 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
|||
isolate_data,
|
||||
error);
|
||||
|
||||
if (isolate == NULL) {
|
||||
return NULL;
|
||||
if (isolate == DART_ILLEGAL_ISOLATE) {
|
||||
return DART_ILLEGAL_ISOLATE;
|
||||
}
|
||||
|
||||
Dart_EnterScope();
|
||||
|
@ -964,7 +964,7 @@ void main(int argc, char** argv) {
|
|||
commandline_package_root,
|
||||
&error,
|
||||
&exit_code);
|
||||
if (isolate == NULL) {
|
||||
if (isolate == DART_ILLEGAL_ISOLATE) {
|
||||
Log::PrintErr("%s\n", error);
|
||||
free(error);
|
||||
delete [] isolate_name;
|
||||
|
@ -974,7 +974,7 @@ void main(int argc, char** argv) {
|
|||
|
||||
Dart_EnterIsolate(isolate);
|
||||
ASSERT(isolate == Dart_CurrentIsolate());
|
||||
ASSERT(isolate != NULL);
|
||||
ASSERT(isolate != DART_ILLEGAL_ISOLATE);
|
||||
Dart_Handle result;
|
||||
|
||||
Dart_EnterScope();
|
||||
|
|
|
@ -161,7 +161,7 @@ intptr_t VmService::server_port_ = 0;
|
|||
|
||||
bool VmService::Setup(const char* server_ip, intptr_t server_port) {
|
||||
Dart_Isolate isolate = Dart_CurrentIsolate();
|
||||
ASSERT(isolate != NULL);
|
||||
ASSERT(isolate != DART_ILLEGAL_ISOLATE);
|
||||
SetServerIPAndPort("", 0);
|
||||
|
||||
Dart_Handle result;
|
||||
|
|
|
@ -65,12 +65,20 @@ typedef unsigned __int64 uint64_t;
|
|||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
/*
|
||||
* =======
|
||||
* Handles
|
||||
* =======
|
||||
* ========
|
||||
* Isolates
|
||||
* ========
|
||||
*/
|
||||
|
||||
/**
|
||||
* A port is used to send or receive inter-isolate messages. It is also used
|
||||
* to identify an isolate (see Dart_Isolate).
|
||||
*/
|
||||
typedef int64_t Dart_Port;
|
||||
|
||||
|
||||
/**
|
||||
* An isolate is the unit of concurrency in Dart. Each isolate has
|
||||
* its own memory and thread of control. No state is shared between
|
||||
|
@ -78,12 +86,24 @@ typedef unsigned __int64 uint64_t;
|
|||
*
|
||||
* Each thread keeps track of its current isolate, which is the
|
||||
* isolate which is ready to execute on the current thread. The
|
||||
* current isolate may be NULL, in which case no isolate is ready to
|
||||
* execute. Most of the Dart apis require there to be a current
|
||||
* current isolate may be DART_ILLEGAL_ISOLATE, in which case no isolate is
|
||||
* ready to execute. Most of the Dart apis require there to be a current
|
||||
* isolate in order to function without error. The current isolate is
|
||||
* set by any call to Dart_CreateIsolate or Dart_EnterIsolate.
|
||||
*/
|
||||
typedef struct _Dart_Isolate* Dart_Isolate;
|
||||
typedef Dart_Port Dart_Isolate;
|
||||
|
||||
/**
|
||||
* DART_ILLEGAL_ISOLATE is an isolate id that is guaranteed never to be associated
|
||||
* with a valid isolate.
|
||||
*/
|
||||
#define DART_ILLEGAL_ISOLATE ((Dart_Isolate) 0)
|
||||
|
||||
/*
|
||||
* =======
|
||||
* Handles
|
||||
* =======
|
||||
*/
|
||||
|
||||
/**
|
||||
* An object reference managed by the Dart VM garbage collector.
|
||||
|
@ -937,6 +957,8 @@ DART_EXPORT void* Dart_CurrentIsolateData();
|
|||
* was passed to the isolate when it was created.
|
||||
* The embedder is responsible for ensuring the consistency of this data
|
||||
* with respect to the lifecycle of an Isolate.
|
||||
*
|
||||
* \return pointer to data or NULL if the isolate could not be found.
|
||||
*/
|
||||
DART_EXPORT void* Dart_IsolateData(Dart_Isolate isolate);
|
||||
|
||||
|
@ -954,8 +976,10 @@ DART_EXPORT Dart_Handle Dart_DebugName();
|
|||
*
|
||||
* Requires there to be no current isolate. Multiple threads may not be in
|
||||
* the same isolate at once.
|
||||
*
|
||||
* \return true if isolate was entered, false otherwise.
|
||||
*/
|
||||
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate);
|
||||
DART_EXPORT bool Dart_EnterIsolate(Dart_Isolate isolate);
|
||||
|
||||
/**
|
||||
* Notifies the VM that the current isolate is about to make a blocking call.
|
||||
|
@ -1040,8 +1064,10 @@ DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer,
|
|||
* Dart_IsolateInterruptCallback).
|
||||
*
|
||||
* \param isolate The isolate to be interrupted.
|
||||
*
|
||||
* \return true if isolate is scheduled to be be interrupted, false otherwise.
|
||||
*/
|
||||
DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate);
|
||||
DART_EXPORT bool Dart_InterruptIsolate(Dart_Isolate isolate);
|
||||
|
||||
/**
|
||||
* Make isolate runnable.
|
||||
|
@ -1052,6 +1078,8 @@ DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate);
|
|||
* This function does not expect there to be a current isolate.
|
||||
*
|
||||
* \param isolate The isolate to be made runnable.
|
||||
*
|
||||
* \return true if isolate was made runnable, false otherwise.
|
||||
*/
|
||||
DART_EXPORT bool Dart_IsolateMakeRunnable(Dart_Isolate isolate);
|
||||
|
||||
|
@ -1063,15 +1091,10 @@ DART_EXPORT bool Dart_IsolateMakeRunnable(Dart_Isolate isolate);
|
|||
*/
|
||||
|
||||
/**
|
||||
* A port is used to send or receive inter-isolate messages
|
||||
* DART_ILLEGAL_PORT is a port number guaranteed never to be associated with a
|
||||
* valid port.
|
||||
*/
|
||||
typedef int64_t Dart_Port;
|
||||
|
||||
/**
|
||||
* ILLEGAL_PORT is a port number guaranteed never to be associated with a valid
|
||||
* port.
|
||||
*/
|
||||
#define ILLEGAL_PORT ((Dart_Port) 0)
|
||||
#define DART_ILLEGAL_PORT ((Dart_Port) 0)
|
||||
|
||||
/**
|
||||
* A message notification callback.
|
||||
|
@ -2786,8 +2809,8 @@ DART_EXPORT bool Dart_IsServiceIsolate(Dart_Isolate isolate);
|
|||
/**
|
||||
* Returns the port that script load requests should be sent on.
|
||||
*
|
||||
* \return Returns the port for load requests or ILLEGAL_PORT if the service
|
||||
* isolate failed to startup or does not support load requests.
|
||||
* \return Returns the port for load requests or DART_ILLEGAL_PORT if the
|
||||
* service isolate failed to startup or does not support load requests.
|
||||
*/
|
||||
DART_EXPORT Dart_Port Dart_ServiceWaitForLoadPort();
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ typedef struct _Dart_ActivationFrame* Dart_ActivationFrame;
|
|||
typedef Dart_Port Dart_IsolateId;
|
||||
|
||||
/**
|
||||
* ILLEGAL_ISOLATE_ID is a number guaranteed never to be associated with a
|
||||
* DART_ILLEGAL_ISOLATE_ID is a number guaranteed never to be associated with a
|
||||
* valid isolate.
|
||||
*/
|
||||
#define ILLEGAL_ISOLATE_ID ILLEGAL_PORT
|
||||
#define DART_ILLEGAL_ISOLATE_ID DART_ILLEGAL_PORT
|
||||
|
||||
|
||||
/**
|
||||
|
@ -477,7 +477,7 @@ DART_EXPORT Dart_Handle Dart_GetLocalVariables(
|
|||
* Returns origin class of a function.
|
||||
*
|
||||
* Requires there to be a current isolate.
|
||||
*
|
||||
*
|
||||
* \return Returns the class id (a handle to an integer) of the class in
|
||||
* which \function is defined. Returns a null handle if \function is defined
|
||||
* at the top level. Returns an error object otherwise.
|
||||
|
@ -520,7 +520,7 @@ DART_EXPORT Dart_Handle Dart_ActivationFrameEvaluate(
|
|||
* were a static method of that class.
|
||||
* If \target is a Library, the expression is evaluated as if it
|
||||
* were a top-level function in that library.
|
||||
*
|
||||
*
|
||||
* \return A handle to the computed value, or an error object if
|
||||
* the compilation of the expression fails, or if the evaluation throws
|
||||
* an error.
|
||||
|
|
|
@ -123,7 +123,7 @@ typedef void (*Dart_NativeMessageHandler)(Dart_Port dest_port_id,
|
|||
* native port concurrently?
|
||||
*
|
||||
* \return If successful, returns the port id for the native port. In
|
||||
* case of error, returns ILLEGAL_PORT.
|
||||
* case of error, returns DART_ILLEGAL_PORT.
|
||||
*/
|
||||
DART_EXPORT Dart_Port Dart_NewNativePort(const char* name,
|
||||
Dart_NativeMessageHandler handler,
|
||||
|
|
|
@ -172,12 +172,11 @@ static bool CreateIsolate(Isolate* parent_isolate,
|
|||
}
|
||||
|
||||
void* init_data = parent_isolate->init_callback_data();
|
||||
Isolate* child_isolate = reinterpret_cast<Isolate*>(
|
||||
(callback)(state->script_url(),
|
||||
state->function_name(),
|
||||
state->package_root(),
|
||||
init_data,
|
||||
error));
|
||||
Isolate* child_isolate = Api::CastIsolate((callback)(state->script_url(),
|
||||
state->function_name(),
|
||||
state->package_root(),
|
||||
init_data,
|
||||
error));
|
||||
if (child_isolate == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -272,7 +272,6 @@ typedef simd128_value_t fpu_register_t;
|
|||
#define Pu64 PRIu64
|
||||
#define Px64 PRIx64
|
||||
|
||||
|
||||
// Suffixes for 64-bit integer literals.
|
||||
#ifdef _MSC_VER
|
||||
#define DART_INT64_C(x) x##I64
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "include/dart_api.h"
|
||||
|
||||
#include "vm/dart.h"
|
||||
#include "vm/dart_api_impl.h"
|
||||
#include "vm/globals.h"
|
||||
#include "vm/heap.h"
|
||||
#include "vm/isolate.h"
|
||||
|
@ -77,12 +78,12 @@ class Benchmark {
|
|||
const char* score_kind() const { return score_kind_; }
|
||||
void set_score(int64_t value) { score_ = value; }
|
||||
int64_t score() const { return score_; }
|
||||
Isolate* isolate() const { return reinterpret_cast<Isolate*>(isolate_); }
|
||||
Isolate* isolate() const { return Api::CastIsolate(isolate_); }
|
||||
|
||||
Dart_Isolate CreateIsolate(const uint8_t* buffer) {
|
||||
char* err = NULL;
|
||||
isolate_ = Dart_CreateIsolate(NULL, NULL, buffer, NULL, &err);
|
||||
EXPECT(isolate_ != NULL);
|
||||
EXPECT(isolate_ != DART_ILLEGAL_ISOLATE);
|
||||
free(err);
|
||||
return isolate_;
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ class StartEvent : public Event {
|
|||
|
||||
|
||||
void StartEvent::Process() {
|
||||
OS::Print(">> StartEvent with isolate(%p)--\n", isolate());
|
||||
OS::Print(">> StartEvent with isolate(%" PRId64 ")--\n", isolate());
|
||||
Dart_EnterIsolate(isolate());
|
||||
Dart_EnterScope();
|
||||
Dart_Handle result;
|
||||
|
@ -197,7 +197,7 @@ class MessageEvent : public Event {
|
|||
|
||||
|
||||
void MessageEvent::Process() {
|
||||
OS::Print("$$ MessageEvent with isolate(%p)\n", isolate());
|
||||
OS::Print("$$ MessageEvent with isolate(%" PRId64 ")\n", isolate());
|
||||
Dart_EnterIsolate(isolate());
|
||||
Dart_EnterScope();
|
||||
|
||||
|
@ -205,19 +205,20 @@ void MessageEvent::Process() {
|
|||
EXPECT_VALID(result);
|
||||
|
||||
if (!Dart_HasLivePorts()) {
|
||||
OS::Print("<< Shutting down isolate(%p)\n", isolate());
|
||||
OS::Print("<< Shutting down isolate(%" PRId64 ")\n", isolate());
|
||||
event_queue->RemoveEventsForIsolate(isolate());
|
||||
Dart_ShutdownIsolate();
|
||||
} else {
|
||||
Dart_ExitScope();
|
||||
Dart_ExitIsolate();
|
||||
}
|
||||
ASSERT(Dart_CurrentIsolate() == NULL);
|
||||
ASSERT(Dart_CurrentIsolate() == DART_ILLEGAL_ISOLATE);
|
||||
}
|
||||
|
||||
|
||||
static void NotifyMessage(Dart_Isolate dest_isolate) {
|
||||
OS::Print("-- Notify isolate(%p) of pending message --\n", dest_isolate);
|
||||
OS::Print("-- Notify isolate(%" PRId64 ") of pending message --\n",
|
||||
dest_isolate);
|
||||
OS::Print("-- Adding MessageEvent to queue --\n");
|
||||
event_queue->Add(new MessageEvent(dest_isolate));
|
||||
}
|
||||
|
@ -252,7 +253,7 @@ static void native_echo(Dart_NativeArguments args) {
|
|||
free(const_cast<char*>(saved_echo));
|
||||
}
|
||||
saved_echo = strdup(c_str);
|
||||
OS::Print("-- (isolate=%p) %s\n", Dart_CurrentIsolate(), c_str);
|
||||
OS::Print("-- (isolate=%" PRId64 ") %s\n", Dart_CurrentIsolate(), c_str);
|
||||
Dart_ExitScope();
|
||||
}
|
||||
|
||||
|
@ -277,7 +278,7 @@ static void CustomIsolateImpl_start(Dart_NativeArguments args) {
|
|||
|
||||
// Create a new Dart_Isolate.
|
||||
Dart_Isolate new_isolate = TestCase::CreateTestIsolate();
|
||||
EXPECT(new_isolate != NULL);
|
||||
EXPECT(new_isolate != DART_ILLEGAL_ISOLATE);
|
||||
Dart_SetMessageNotifyCallback(&NotifyMessage);
|
||||
Dart_EnterScope();
|
||||
// Reload all the test classes here.
|
||||
|
@ -315,7 +316,7 @@ UNIT_TEST_CASE(CustomIsolates) {
|
|||
event_queue = new EventQueue();
|
||||
|
||||
Dart_Isolate dart_isolate = TestCase::CreateTestIsolate();
|
||||
EXPECT(dart_isolate != NULL);
|
||||
EXPECT(dart_isolate != DART_ILLEGAL_ISOLATE);
|
||||
Dart_SetMessageNotifyCallback(&NotifyMessage);
|
||||
Dart_EnterScope();
|
||||
Dart_Handle result;
|
||||
|
|
|
@ -392,7 +392,15 @@ Dart_Handle Api::CheckAndFinalizePendingClasses(Isolate* isolate) {
|
|||
|
||||
|
||||
Dart_Isolate Api::CastIsolate(Isolate* isolate) {
|
||||
return reinterpret_cast<Dart_Isolate>(isolate);
|
||||
if (isolate == NULL) {
|
||||
return DART_ILLEGAL_ISOLATE;
|
||||
}
|
||||
return static_cast<Dart_Isolate>(isolate->main_port());
|
||||
}
|
||||
|
||||
|
||||
Isolate* Api::CastIsolate(Dart_Isolate isolate) {
|
||||
return PortMap::GetIsolate(static_cast<Dart_Port>(isolate));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1306,12 +1314,12 @@ DART_EXPORT Dart_Isolate Dart_CreateIsolate(const char* script_uri,
|
|||
}
|
||||
#endif // defined(DART_NO_SNAPSHOT).
|
||||
START_TIMER(isolate, time_total_runtime);
|
||||
return reinterpret_cast<Dart_Isolate>(isolate);
|
||||
return Api::CastIsolate(isolate);
|
||||
}
|
||||
*error = strdup(error_obj.ToErrorCString());
|
||||
}
|
||||
Dart::ShutdownIsolate();
|
||||
return reinterpret_cast<Dart_Isolate>(NULL);
|
||||
return DART_ILLEGAL_ISOLATE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1342,11 +1350,10 @@ DART_EXPORT void* Dart_CurrentIsolateData() {
|
|||
|
||||
DART_EXPORT void* Dart_IsolateData(Dart_Isolate isolate) {
|
||||
TRACE_API_CALL(CURRENT_FUNC);
|
||||
if (isolate == NULL) {
|
||||
FATAL1("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC);
|
||||
Isolate* iso = Api::CastIsolate(isolate);
|
||||
if (iso == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
// TODO(16615): Validate isolate parameter.
|
||||
Isolate* iso = reinterpret_cast<Isolate*>(isolate);
|
||||
return iso->init_callback_data();
|
||||
}
|
||||
|
||||
|
@ -1359,15 +1366,19 @@ DART_EXPORT Dart_Handle Dart_DebugName() {
|
|||
|
||||
|
||||
|
||||
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate) {
|
||||
DART_EXPORT bool Dart_EnterIsolate(Dart_Isolate isolate) {
|
||||
CHECK_NO_ISOLATE(Isolate::Current());
|
||||
// TODO(16615): Validate isolate parameter.
|
||||
Isolate* iso = reinterpret_cast<Isolate*>(isolate);
|
||||
Isolate* iso = Api::CastIsolate(isolate);
|
||||
if (iso == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (iso->mutator_thread() != NULL) {
|
||||
FATAL("Multiple mutators within one isolate is not supported.");
|
||||
return false;
|
||||
}
|
||||
Thread::EnsureInit();
|
||||
Thread::EnterIsolate(iso);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1484,27 +1495,25 @@ DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer,
|
|||
}
|
||||
|
||||
|
||||
DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate) {
|
||||
DART_EXPORT bool Dart_InterruptIsolate(Dart_Isolate isolate) {
|
||||
TRACE_API_CALL(CURRENT_FUNC);
|
||||
if (isolate == NULL) {
|
||||
FATAL1("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC);
|
||||
Isolate* iso = Api::CastIsolate(isolate);
|
||||
if (iso == NULL) {
|
||||
return false;
|
||||
}
|
||||
// TODO(16615): Validate isolate parameter.
|
||||
Isolate* iso = reinterpret_cast<Isolate*>(isolate);
|
||||
iso->ScheduleInterrupts(Isolate::kApiInterrupt);
|
||||
// Can't use Dart_Post() since there isn't a current isolate.
|
||||
Dart_CObject api_null = { Dart_CObject_kNull , { 0 } };
|
||||
Dart_PostCObject(iso->main_port(), &api_null);
|
||||
return Dart_PostCObject(iso->main_port(), &api_null);
|
||||
}
|
||||
|
||||
|
||||
DART_EXPORT bool Dart_IsolateMakeRunnable(Dart_Isolate isolate) {
|
||||
CHECK_NO_ISOLATE(Isolate::Current());
|
||||
if (isolate == NULL) {
|
||||
FATAL1("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC);
|
||||
Isolate* iso = Api::CastIsolate(isolate);
|
||||
if (iso == NULL) {
|
||||
return false;
|
||||
}
|
||||
// TODO(16615): Validate isolate parameter.
|
||||
Isolate* iso = reinterpret_cast<Isolate*>(isolate);
|
||||
if (iso->object_store()->root_library() == Library::null()) {
|
||||
// The embedder should have called Dart_LoadScript by now.
|
||||
return false;
|
||||
|
@ -1619,7 +1628,7 @@ static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
|
|||
DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
if (port_id == ILLEGAL_PORT) {
|
||||
if (port_id == DART_ILLEGAL_PORT) {
|
||||
return false;
|
||||
}
|
||||
const Object& object = Object::Handle(isolate, Api::UnwrapHandle(handle));
|
||||
|
@ -1636,7 +1645,7 @@ DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) {
|
|||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
CHECK_CALLBACK_STATE(isolate);
|
||||
if (port_id == ILLEGAL_PORT) {
|
||||
if (port_id == DART_ILLEGAL_PORT) {
|
||||
return Api::NewError("%s: illegal port_id %" Pd64 ".",
|
||||
CURRENT_FUNC,
|
||||
port_id);
|
||||
|
@ -5551,7 +5560,10 @@ DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer) {
|
|||
// --- Service support ---
|
||||
|
||||
DART_EXPORT bool Dart_IsServiceIsolate(Dart_Isolate isolate) {
|
||||
Isolate* iso = reinterpret_cast<Isolate*>(isolate);
|
||||
Isolate* iso = Api::CastIsolate(isolate);
|
||||
if (iso == NULL) {
|
||||
return false;
|
||||
}
|
||||
return ServiceIsolate::IsServiceIsolate(iso);
|
||||
}
|
||||
|
||||
|
|
|
@ -149,6 +149,8 @@ class Api : AllStatic {
|
|||
|
||||
// Casts the internal Isolate* type to the external Dart_Isolate type.
|
||||
static Dart_Isolate CastIsolate(Isolate* isolate);
|
||||
// Casts the external Dart_Isolate type to the internal Isolate* type.
|
||||
static Isolate* CastIsolate(Dart_Isolate);
|
||||
|
||||
// Gets the handle used to designate successful return.
|
||||
static Dart_Handle Success() { return Api::True(); }
|
||||
|
|
|
@ -3674,40 +3674,43 @@ UNIT_TEST_CASE(LocalZoneMemory) {
|
|||
|
||||
|
||||
UNIT_TEST_CASE(Isolates) {
|
||||
// This test currently assumes that the Dart_Isolate type is an opaque
|
||||
// representation of Isolate*.
|
||||
Dart_Isolate iso_1 = TestCase::CreateTestIsolate();
|
||||
EXPECT_EQ(iso_1, Api::CastIsolate(Isolate::Current()));
|
||||
Dart_Isolate isolate = Dart_CurrentIsolate();
|
||||
EXPECT_EQ(iso_1, isolate);
|
||||
Dart_ExitIsolate();
|
||||
EXPECT(NULL == Dart_CurrentIsolate());
|
||||
EXPECT(DART_ILLEGAL_ISOLATE == Dart_CurrentIsolate());
|
||||
// Test that Dart_EnterIsolate returns an error when passed a bad isolate id.
|
||||
EXPECT(!Dart_EnterIsolate(DART_ILLEGAL_ISOLATE));
|
||||
Dart_Isolate iso_2 = TestCase::CreateTestIsolate();
|
||||
EXPECT_EQ(iso_2, Dart_CurrentIsolate());
|
||||
Dart_ExitIsolate();
|
||||
EXPECT(NULL == Dart_CurrentIsolate());
|
||||
EXPECT(DART_ILLEGAL_ISOLATE == Dart_CurrentIsolate());
|
||||
Dart_EnterIsolate(iso_2);
|
||||
EXPECT_EQ(iso_2, Dart_CurrentIsolate());
|
||||
Dart_ShutdownIsolate();
|
||||
EXPECT(NULL == Dart_CurrentIsolate());
|
||||
EXPECT(DART_ILLEGAL_ISOLATE == Dart_CurrentIsolate());
|
||||
Dart_EnterIsolate(iso_1);
|
||||
EXPECT_EQ(iso_1, Dart_CurrentIsolate());
|
||||
Dart_ShutdownIsolate();
|
||||
EXPECT(NULL == Dart_CurrentIsolate());
|
||||
EXPECT(DART_ILLEGAL_ISOLATE == Dart_CurrentIsolate());
|
||||
}
|
||||
|
||||
|
||||
UNIT_TEST_CASE(CurrentIsolateData) {
|
||||
intptr_t mydata = 12345;
|
||||
char* err;
|
||||
// We expect that Dart_Port and Dart_Isolate are the same size.
|
||||
EXPECT_EQ(sizeof(Dart_Port), sizeof(Dart_Isolate));
|
||||
Dart_Isolate isolate =
|
||||
Dart_CreateIsolate(NULL, NULL, bin::isolate_snapshot_buffer,
|
||||
reinterpret_cast<void*>(mydata),
|
||||
&err);
|
||||
EXPECT(isolate != NULL);
|
||||
EXPECT(isolate != DART_ILLEGAL_ISOLATE);
|
||||
EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData()));
|
||||
EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate)));
|
||||
Dart_ShutdownIsolate();
|
||||
EXPECT(Dart_IsolateData(DART_ILLEGAL_ISOLATE) == NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3756,7 +3759,7 @@ static void MyMessageNotifyCallback(Dart_Isolate dest_isolate) {
|
|||
UNIT_TEST_CASE(SetMessageCallbacks) {
|
||||
Dart_Isolate dart_isolate = TestCase::CreateTestIsolate();
|
||||
Dart_SetMessageNotifyCallback(&MyMessageNotifyCallback);
|
||||
Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate);
|
||||
Isolate* isolate = Api::CastIsolate(dart_isolate);
|
||||
EXPECT_EQ(&MyMessageNotifyCallback, isolate->message_notify_callback());
|
||||
Dart_ShutdownIsolate();
|
||||
}
|
||||
|
@ -7224,7 +7227,7 @@ void NewNativePort_send321(Dart_Port dest_port_id,
|
|||
|
||||
|
||||
TEST_CASE(IllegalNewSendPort) {
|
||||
Dart_Handle error = Dart_NewSendPort(ILLEGAL_PORT);
|
||||
Dart_Handle error = Dart_NewSendPort(DART_ILLEGAL_PORT);
|
||||
EXPECT(Dart_IsError(error));
|
||||
EXPECT(Dart_IsApiError(error));
|
||||
}
|
||||
|
@ -7232,7 +7235,7 @@ TEST_CASE(IllegalNewSendPort) {
|
|||
|
||||
TEST_CASE(IllegalPost) {
|
||||
Dart_Handle message = Dart_True();
|
||||
bool success = Dart_Post(ILLEGAL_PORT, message);
|
||||
bool success = Dart_Post(DART_ILLEGAL_PORT, message);
|
||||
EXPECT(!success);
|
||||
}
|
||||
|
||||
|
@ -7240,7 +7243,7 @@ TEST_CASE(IllegalPost) {
|
|||
UNIT_TEST_CASE(NewNativePort) {
|
||||
// Create a port with a bogus handler.
|
||||
Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true);
|
||||
EXPECT_EQ(ILLEGAL_PORT, error_port);
|
||||
EXPECT_EQ(DART_ILLEGAL_PORT, error_port);
|
||||
|
||||
// Create the port w/o a current isolate, just to make sure that works.
|
||||
Dart_Port port_id1 =
|
||||
|
@ -7326,11 +7329,11 @@ static Dart_Isolate RunLoopTestCallback(const char* script_name,
|
|||
" };\n"
|
||||
"}\n";
|
||||
|
||||
if (Dart_CurrentIsolate() != NULL) {
|
||||
if (Dart_CurrentIsolate() != DART_ILLEGAL_ISOLATE) {
|
||||
Dart_ExitIsolate();
|
||||
}
|
||||
Dart_Isolate isolate = TestCase::CreateTestIsolate(script_name);
|
||||
ASSERT(isolate != NULL);
|
||||
ASSERT(isolate != DART_ILLEGAL_ISOLATE);
|
||||
if (Dart_IsServiceIsolate(isolate)) {
|
||||
return isolate;
|
||||
}
|
||||
|
@ -7476,7 +7479,7 @@ void BusyLoop_start(uword unused) {
|
|||
shared_isolate = Dart_CreateIsolate(NULL, NULL,
|
||||
bin::isolate_snapshot_buffer,
|
||||
NULL, &error);
|
||||
EXPECT(shared_isolate != NULL);
|
||||
EXPECT(shared_isolate != DART_ILLEGAL_ISOLATE);
|
||||
Dart_EnterScope();
|
||||
Dart_Handle url = NewString(TestCase::url());
|
||||
Dart_Handle source = NewString(kScriptChars);
|
||||
|
@ -7555,6 +7558,10 @@ TEST_CASE(IsolateInterrupt) {
|
|||
}
|
||||
}
|
||||
|
||||
// Test that Dart_InterruptIsolate returns false when passed an illegal
|
||||
// isolate.
|
||||
EXPECT(!Dart_InterruptIsolate(DART_ILLEGAL_ISOLATE));
|
||||
|
||||
// Send a number of interrupts to the other isolate. All but the
|
||||
// last allow execution to continue. The last causes an exception in
|
||||
// the isolate.
|
||||
|
@ -7575,7 +7582,7 @@ TEST_CASE(IsolateInterrupt) {
|
|||
{
|
||||
MonitorLocker ml(sync);
|
||||
// Wait for our isolate to finish.
|
||||
while (shared_isolate != NULL) {
|
||||
while (shared_isolate != DART_ILLEGAL_ISOLATE) {
|
||||
ml.Wait();
|
||||
}
|
||||
}
|
||||
|
@ -7604,11 +7611,11 @@ UNIT_TEST_CASE(IsolateShutdown) {
|
|||
Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL,
|
||||
bin::isolate_snapshot_buffer,
|
||||
my_data, &err);
|
||||
if (isolate == NULL) {
|
||||
if (isolate == DART_ILLEGAL_ISOLATE) {
|
||||
OS::Print("Creation of isolate failed '%s'\n", err);
|
||||
free(err);
|
||||
}
|
||||
EXPECT(isolate != NULL);
|
||||
EXPECT(isolate != DART_ILLEGAL_ISOLATE);
|
||||
|
||||
// The shutdown callback has not been called.
|
||||
EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data));
|
||||
|
@ -7654,11 +7661,11 @@ UNIT_TEST_CASE(IsolateShutdownRunDartCode) {
|
|||
Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL,
|
||||
bin::isolate_snapshot_buffer,
|
||||
NULL, &err);
|
||||
if (isolate == NULL) {
|
||||
if (isolate == DART_ILLEGAL_ISOLATE) {
|
||||
OS::Print("Creation of isolate failed '%s'\n", err);
|
||||
free(err);
|
||||
}
|
||||
EXPECT(isolate != NULL);
|
||||
EXPECT(isolate != DART_ILLEGAL_ISOLATE);
|
||||
|
||||
Isolate::SetShutdownCallback(IsolateShutdownRunDartCodeTestCallback);
|
||||
|
||||
|
@ -7681,7 +7688,7 @@ UNIT_TEST_CASE(IsolateShutdownRunDartCode) {
|
|||
// The shutdown callback has not been called.
|
||||
EXPECT_EQ(0, add_result);
|
||||
|
||||
EXPECT(isolate != NULL);
|
||||
EXPECT(isolate != DART_ILLEGAL_ISOLATE);
|
||||
|
||||
// Shutdown the isolate.
|
||||
Dart_ShutdownIsolate();
|
||||
|
|
|
@ -263,7 +263,7 @@ void Debugger::InvokeEventHandler(DebuggerEvent* event) {
|
|||
void Debugger::SignalIsolateEvent(DebuggerEvent::EventType type) {
|
||||
if (HasEventHandler()) {
|
||||
DebuggerEvent event(isolate_, type);
|
||||
ASSERT(event.isolate_id() != ILLEGAL_ISOLATE_ID);
|
||||
ASSERT(event.isolate_id() != DART_ILLEGAL_ISOLATE_ID);
|
||||
if (type == DebuggerEvent::kIsolateInterrupted) {
|
||||
DebuggerStackTrace* trace = CollectStackTrace();
|
||||
ASSERT(trace->Length() > 0);
|
||||
|
@ -1039,7 +1039,7 @@ RawObject* RemoteObjectCache::GetObj(intptr_t obj_id) const {
|
|||
|
||||
Debugger::Debugger()
|
||||
: isolate_(NULL),
|
||||
isolate_id_(ILLEGAL_ISOLATE_ID),
|
||||
isolate_id_(DART_ILLEGAL_ISOLATE_ID),
|
||||
initialized_(false),
|
||||
next_id_(1),
|
||||
latent_breakpoints_(NULL),
|
||||
|
@ -1056,7 +1056,7 @@ Debugger::Debugger()
|
|||
|
||||
|
||||
Debugger::~Debugger() {
|
||||
isolate_id_ = ILLEGAL_ISOLATE_ID;
|
||||
isolate_id_ = DART_ILLEGAL_ISOLATE_ID;
|
||||
ASSERT(!IsPaused());
|
||||
ASSERT(latent_breakpoints_ == NULL);
|
||||
ASSERT(src_breakpoints_ == NULL);
|
||||
|
|
|
@ -982,7 +982,7 @@ DART_EXPORT Dart_Isolate Dart_GetIsolate(Dart_IsolateId isolate_id) {
|
|||
|
||||
|
||||
DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) {
|
||||
Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate);
|
||||
Isolate* isolate = Api::CastIsolate(dart_isolate);
|
||||
return isolate->debugger()->GetIsolateId();
|
||||
}
|
||||
|
||||
|
|
|
@ -1354,11 +1354,11 @@ TEST_CASE(Debug_InspectObject) {
|
|||
}
|
||||
|
||||
|
||||
static Dart_IsolateId test_isolate_id = ILLEGAL_ISOLATE_ID;
|
||||
static Dart_IsolateId test_isolate_id = DART_ILLEGAL_ISOLATE_ID;
|
||||
static int verify_callback = 0;
|
||||
static void TestIsolateID(Dart_IsolateId isolate_id, Dart_IsolateEvent kind) {
|
||||
if (kind == kCreated) {
|
||||
EXPECT(test_isolate_id == ILLEGAL_ISOLATE_ID);
|
||||
EXPECT(test_isolate_id == DART_ILLEGAL_ISOLATE_ID);
|
||||
test_isolate_id = isolate_id;
|
||||
Dart_Isolate isolate = Dart_GetIsolate(isolate_id);
|
||||
EXPECT(isolate == Dart_CurrentIsolate());
|
||||
|
@ -1391,12 +1391,12 @@ UNIT_TEST_CASE(Debug_IsolateID) {
|
|||
|
||||
Dart_SetIsolateEventHandler(&TestIsolateID);
|
||||
Dart_Isolate isolate = TestCase::CreateTestIsolate();
|
||||
ASSERT(isolate != NULL);
|
||||
ASSERT(isolate != DART_ILLEGAL_ISOLATE);
|
||||
Dart_EnterScope();
|
||||
LoadScript(kScriptChars);
|
||||
Dart_Handle retval = Invoke("main");
|
||||
EXPECT_VALID(retval);
|
||||
EXPECT(test_isolate_id != ILLEGAL_ISOLATE_ID);
|
||||
EXPECT(test_isolate_id != DART_ILLEGAL_ISOLATE_ID);
|
||||
EXPECT(Dart_GetIsolate(test_isolate_id) == isolate);
|
||||
EXPECT(Dart_GetIsolateId(isolate) == test_isolate_id);
|
||||
Dart_ExitScope();
|
||||
|
@ -1408,7 +1408,7 @@ UNIT_TEST_CASE(Debug_IsolateID) {
|
|||
static Monitor* sync = NULL;
|
||||
static bool isolate_interrupted = false;
|
||||
static bool pause_event_handled = false;
|
||||
static Dart_IsolateId interrupt_isolate_id = ILLEGAL_ISOLATE_ID;
|
||||
static Dart_IsolateId interrupt_isolate_id = DART_ILLEGAL_ISOLATE_ID;
|
||||
static volatile bool continue_isolate_loop = true;
|
||||
|
||||
|
||||
|
@ -1423,7 +1423,7 @@ static void InterruptIsolateHandler(Dart_IsolateId isolateId,
|
|||
static void TestInterruptIsolate(Dart_IsolateId isolate_id,
|
||||
Dart_IsolateEvent kind) {
|
||||
if (kind == kCreated) {
|
||||
EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID);
|
||||
EXPECT(interrupt_isolate_id == DART_ILLEGAL_ISOLATE_ID);
|
||||
// Indicate that the isolate has been created.
|
||||
{
|
||||
MonitorLocker ml(sync);
|
||||
|
@ -1441,7 +1441,7 @@ static void TestInterruptIsolate(Dart_IsolateId isolate_id,
|
|||
} else if (kind == kShutdown) {
|
||||
if (interrupt_isolate_id == isolate_id) {
|
||||
MonitorLocker ml(sync);
|
||||
interrupt_isolate_id = ILLEGAL_ISOLATE_ID;
|
||||
interrupt_isolate_id = DART_ILLEGAL_ISOLATE_ID;
|
||||
ml.Notify();
|
||||
}
|
||||
}
|
||||
|
@ -1483,7 +1483,7 @@ static void InterruptIsolateRun(uword unused) {
|
|||
"} \n";
|
||||
|
||||
Dart_Isolate isolate = TestCase::CreateTestIsolate();
|
||||
ASSERT(isolate != NULL);
|
||||
ASSERT(isolate != DART_ILLEGAL_ISOLATE);
|
||||
Dart_EnterScope();
|
||||
LoadScript(kScriptChars);
|
||||
|
||||
|
@ -1502,7 +1502,7 @@ static void InterruptIsolateRun(uword unused) {
|
|||
TEST_CASE(Debug_InterruptIsolate) {
|
||||
Dart_SetIsolateEventHandler(&TestInterruptIsolate);
|
||||
sync = new Monitor();
|
||||
EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID);
|
||||
EXPECT(interrupt_isolate_id == DART_ILLEGAL_ISOLATE_ID);
|
||||
Dart_SetPausedEventHandler(InterruptIsolateHandler);
|
||||
int result = OSThread::Start(InterruptIsolateRun, 0);
|
||||
EXPECT_EQ(0, result);
|
||||
|
@ -1510,14 +1510,14 @@ TEST_CASE(Debug_InterruptIsolate) {
|
|||
// Wait for the test isolate to be created.
|
||||
{
|
||||
MonitorLocker ml(sync);
|
||||
while (interrupt_isolate_id == ILLEGAL_ISOLATE_ID) {
|
||||
while (interrupt_isolate_id == DART_ILLEGAL_ISOLATE_ID) {
|
||||
ml.Wait();
|
||||
}
|
||||
}
|
||||
EXPECT(interrupt_isolate_id != ILLEGAL_ISOLATE_ID);
|
||||
EXPECT(interrupt_isolate_id != DART_ILLEGAL_ISOLATE_ID);
|
||||
|
||||
Dart_Isolate isolate = Dart_GetIsolate(interrupt_isolate_id);
|
||||
EXPECT(isolate != NULL);
|
||||
EXPECT(isolate != DART_ILLEGAL_ISOLATE);
|
||||
Dart_InterruptIsolate(isolate);
|
||||
|
||||
// Wait for the test isolate to be interrupted.
|
||||
|
@ -1533,11 +1533,11 @@ TEST_CASE(Debug_InterruptIsolate) {
|
|||
// Wait for the test isolate to shutdown.
|
||||
{
|
||||
MonitorLocker ml(sync);
|
||||
while (interrupt_isolate_id != ILLEGAL_ISOLATE_ID) {
|
||||
while (interrupt_isolate_id != DART_ILLEGAL_ISOLATE_ID) {
|
||||
ml.Wait();
|
||||
}
|
||||
}
|
||||
EXPECT(interrupt_isolate_id == ILLEGAL_ISOLATE_ID);
|
||||
EXPECT(interrupt_isolate_id == DART_ILLEGAL_ISOLATE_ID);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ JSONStream::JSONStream(intptr_t buf_size)
|
|||
default_id_zone_(Isolate::Current()->object_id_ring(),
|
||||
ObjectIdRing::kAllocateId),
|
||||
id_zone_(&default_id_zone_),
|
||||
reply_port_(ILLEGAL_PORT),
|
||||
reply_port_(DART_ILLEGAL_PORT),
|
||||
seq_(""),
|
||||
method_(""),
|
||||
param_keys_(NULL),
|
||||
|
@ -159,8 +159,8 @@ static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
|
|||
|
||||
void JSONStream::PostReply() {
|
||||
Dart_Port port = reply_port();
|
||||
ASSERT(port != ILLEGAL_PORT);
|
||||
set_reply_port(ILLEGAL_PORT); // Prevent double replies.
|
||||
ASSERT(port != DART_ILLEGAL_PORT);
|
||||
set_reply_port(DART_ILLEGAL_PORT); // Prevent double replies.
|
||||
int64_t process_delta_micros = 0;
|
||||
if (FLAG_trace_service) {
|
||||
process_delta_micros = OS::GetCurrentTimeMicros() - setup_time_micros_;
|
||||
|
|
|
@ -44,7 +44,7 @@ DART_EXPORT Dart_Port Dart_NewNativePort(const char* name,
|
|||
if (handler == NULL) {
|
||||
OS::PrintErr("%s expects argument 'handler' to be non-null.\n",
|
||||
CURRENT_FUNC);
|
||||
return ILLEGAL_PORT;
|
||||
return DART_ILLEGAL_PORT;
|
||||
}
|
||||
// Start the native port without a current isolate.
|
||||
IsolateSaver saver(Isolate::Current());
|
||||
|
|
|
@ -20102,7 +20102,7 @@ void Capability::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
RawReceivePort* ReceivePort::New(Dart_Port id,
|
||||
bool is_control_port,
|
||||
Heap::Space space) {
|
||||
ASSERT(id != ILLEGAL_PORT);
|
||||
ASSERT(id != DART_ILLEGAL_PORT);
|
||||
Isolate* isolate = Isolate::Current();
|
||||
const SendPort& send_port =
|
||||
SendPort::Handle(isolate, SendPort::New(id, isolate->origin_id()));
|
||||
|
@ -20143,7 +20143,7 @@ RawSendPort* SendPort::New(Dart_Port id, Heap::Space space) {
|
|||
RawSendPort* SendPort::New(Dart_Port id,
|
||||
Dart_Port origin_id,
|
||||
Heap::Space space) {
|
||||
ASSERT(id != ILLEGAL_PORT);
|
||||
ASSERT(id != DART_ILLEGAL_PORT);
|
||||
SendPort& result = SendPort::Handle();
|
||||
{
|
||||
RawObject* raw = Object::Allocate(SendPort::kClassId,
|
||||
|
|
|
@ -25,14 +25,14 @@ Random* PortMap::prng_ = NULL;
|
|||
|
||||
|
||||
intptr_t PortMap::FindPort(Dart_Port port) {
|
||||
// ILLEGAL_PORT (0) is used as a sentinel value in Entry.port. The loop below
|
||||
// could return the index to a deleted port when we are searching for
|
||||
// port id ILLEGAL_PORT. Return -1 immediately to indicate the port
|
||||
// DART_ILLEGAL_PORT (0) is used as a sentinel value in Entry.port. The loop
|
||||
// below could return the index to a deleted port when we are searching for
|
||||
// port id DART_ILLEGAL_PORT. Return -1 immediately to indicate the port
|
||||
// does not exist.
|
||||
if (port == ILLEGAL_PORT) {
|
||||
if (port == DART_ILLEGAL_PORT) {
|
||||
return -1;
|
||||
}
|
||||
ASSERT(port != ILLEGAL_PORT);
|
||||
ASSERT(port != DART_ILLEGAL_PORT);
|
||||
intptr_t index = port % capacity_;
|
||||
intptr_t start_index = index;
|
||||
Entry entry = map_[index];
|
||||
|
|
|
@ -18,7 +18,7 @@ class MessageHandler;
|
|||
class Mutex;
|
||||
class PortMapTestPeer;
|
||||
|
||||
class PortMap: public AllStatic {
|
||||
class PortMap : public AllStatic {
|
||||
public:
|
||||
enum PortState {
|
||||
kNewPort = 0, // a newly allocated port
|
||||
|
|
|
@ -109,7 +109,7 @@ static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
|
|||
static Dart_Port ExtractPort(Isolate* isolate, Dart_Handle receivePort) {
|
||||
const ReceivePort& rp = Api::UnwrapReceivePortHandle(isolate, receivePort);
|
||||
if (rp.IsNull()) {
|
||||
return ILLEGAL_PORT;
|
||||
return DART_ILLEGAL_PORT;
|
||||
}
|
||||
return rp.Id();
|
||||
}
|
||||
|
@ -147,9 +147,9 @@ static RawArray* MakeServiceExitMessage() {
|
|||
|
||||
const char* ServiceIsolate::kName = "vm-service";
|
||||
Isolate* ServiceIsolate::isolate_ = NULL;
|
||||
Dart_Port ServiceIsolate::port_ = ILLEGAL_PORT;
|
||||
Dart_Port ServiceIsolate::load_port_ = ILLEGAL_PORT;
|
||||
Dart_Port ServiceIsolate::origin_ = ILLEGAL_PORT;
|
||||
Dart_Port ServiceIsolate::port_ = DART_ILLEGAL_PORT;
|
||||
Dart_Port ServiceIsolate::load_port_ = DART_ILLEGAL_PORT;
|
||||
Dart_Port ServiceIsolate::origin_ = DART_ILLEGAL_PORT;
|
||||
Dart_IsolateCreateCallback ServiceIsolate::create_callback_ = NULL;
|
||||
uint8_t* ServiceIsolate::exit_message_ = NULL;
|
||||
intptr_t ServiceIsolate::exit_message_length_ = 0;
|
||||
|
@ -270,7 +270,7 @@ class ServiceIsolateNatives : public AllStatic {
|
|||
Dart_Invoke(library, Dart_NewStringFromCString("boot"), 0, NULL);
|
||||
ASSERT(!Dart_IsError(result));
|
||||
Dart_Port port = ExtractPort(isolate, result);
|
||||
ASSERT(port != ILLEGAL_PORT);
|
||||
ASSERT(port != DART_ILLEGAL_PORT);
|
||||
ServiceIsolate::SetServicePort(port);
|
||||
Dart_ExitScope();
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ bool ServiceIsolate::Exists() {
|
|||
|
||||
bool ServiceIsolate::IsRunning() {
|
||||
MonitorLocker ml(monitor_);
|
||||
return (port_ != ILLEGAL_PORT) && (isolate_ != NULL);
|
||||
return (port_ != DART_ILLEGAL_PORT) && (isolate_ != NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -381,7 +381,7 @@ Dart_Port ServiceIsolate::Port() {
|
|||
Dart_Port ServiceIsolate::WaitForLoadPort() {
|
||||
MonitorLocker ml(monitor_);
|
||||
|
||||
while (initializing_ && (load_port_ == ILLEGAL_PORT)) {
|
||||
while (initializing_ && (load_port_ == DART_ILLEGAL_PORT)) {
|
||||
ml.Wait();
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ void ServiceIsolate::SetServiceIsolate(Isolate* isolate) {
|
|||
isolate_->is_service_isolate_ = true;
|
||||
origin_ = isolate_->origin_id();
|
||||
} else {
|
||||
origin_ = ILLEGAL_PORT;
|
||||
origin_ = DART_ILLEGAL_PORT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -601,12 +601,11 @@ class RunServiceTask : public ThreadPool::Task {
|
|||
return;
|
||||
}
|
||||
|
||||
isolate =
|
||||
reinterpret_cast<Isolate*>(create_callback(ServiceIsolate::kName,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&error));
|
||||
isolate = Api::CastIsolate(create_callback(ServiceIsolate::kName,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&error));
|
||||
if (isolate == NULL) {
|
||||
OS::PrintErr("vm-service: Isolate creation error: %s\n", error);
|
||||
ServiceIsolate::FinishedInitializing();
|
||||
|
@ -650,7 +649,7 @@ class RunServiceTask : public ThreadPool::Task {
|
|||
Dart::ShutdownIsolate();
|
||||
}
|
||||
ServiceIsolate::SetServiceIsolate(NULL);
|
||||
ServiceIsolate::SetServicePort(ILLEGAL_PORT);
|
||||
ServiceIsolate::SetServicePort(DART_ILLEGAL_PORT);
|
||||
if (FLAG_trace_service) {
|
||||
OS::Print("vm-service: Shutdown.\n");
|
||||
}
|
||||
|
@ -728,7 +727,7 @@ void ServiceIsolate::Shutdown() {
|
|||
SendServiceExitMessage();
|
||||
{
|
||||
MonitorLocker ml(monitor_);
|
||||
while (shutting_down_ && (port_ != ILLEGAL_PORT)) {
|
||||
while (shutting_down_ && (port_ != DART_ILLEGAL_PORT)) {
|
||||
ml.Wait();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "vm/ast.h"
|
||||
#include "vm/dart.h"
|
||||
#include "vm/dart_api_impl.h"
|
||||
#include "vm/globals.h"
|
||||
#include "vm/heap.h"
|
||||
#include "vm/isolate.h"
|
||||
|
@ -287,11 +288,11 @@ class TestCase : TestCaseBase {
|
|||
const char* name) {
|
||||
char* err;
|
||||
Dart_Isolate isolate = Dart_CreateIsolate(name, NULL, buffer, NULL, &err);
|
||||
if (isolate == NULL) {
|
||||
if (isolate == DART_ILLEGAL_ISOLATE) {
|
||||
OS::Print("Creation of isolate failed '%s'\n", err);
|
||||
free(err);
|
||||
}
|
||||
EXPECT(isolate != NULL);
|
||||
EXPECT(isolate != DART_ILLEGAL_ISOLATE);
|
||||
return isolate;
|
||||
}
|
||||
|
||||
|
@ -302,19 +303,19 @@ class TestCase : TestCaseBase {
|
|||
class TestIsolateScope {
|
||||
public:
|
||||
TestIsolateScope() {
|
||||
isolate_ = reinterpret_cast<Isolate*>(TestCase::CreateTestIsolate());
|
||||
isolate_ = TestCase::CreateTestIsolate();
|
||||
Dart_EnterScope(); // Create a Dart API scope for unit tests.
|
||||
}
|
||||
~TestIsolateScope() {
|
||||
Dart_ExitScope(); // Exit the Dart API scope created for unit tests.
|
||||
ASSERT(isolate_ == Isolate::Current());
|
||||
ASSERT(isolate_ == Api::CastIsolate(Isolate::Current()));
|
||||
Dart_ShutdownIsolate();
|
||||
isolate_ = NULL;
|
||||
isolate_ = DART_ILLEGAL_ISOLATE;
|
||||
}
|
||||
Isolate* isolate() const { return isolate_; }
|
||||
Isolate* isolate() const { return Api::CastIsolate(isolate_); }
|
||||
|
||||
private:
|
||||
Isolate* isolate_;
|
||||
Dart_Isolate isolate_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TestIsolateScope);
|
||||
};
|
||||
|
|
|
@ -81,7 +81,7 @@ uint8_t* randomArray(int seed, int length) {
|
|||
|
||||
void wrappedRandomArray(Dart_Port dest_port_id,
|
||||
Dart_CObject* message) {
|
||||
Dart_Port reply_port_id = ILLEGAL_PORT;
|
||||
Dart_Port reply_port_id = DART_ILLEGAL_PORT;
|
||||
if (message->type == Dart_CObject_kArray &&
|
||||
3 == message->value.as_array.length) {
|
||||
// Use .as_array and .as_int32 to access the data in the Dart_CObject.
|
||||
|
@ -121,7 +121,7 @@ void randomArrayServicePort(Dart_NativeArguments arguments) {
|
|||
Dart_SetReturnValue(arguments, Dart_Null());
|
||||
Dart_Port service_port =
|
||||
Dart_NewNativePort("RandomArrayService", wrappedRandomArray, true);
|
||||
if (service_port != ILLEGAL_PORT) {
|
||||
if (service_port != DART_ILLEGAL_PORT) {
|
||||
Dart_Handle send_port = HandleError(Dart_NewSendPort(service_port));
|
||||
Dart_SetReturnValue(arguments, send_port);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue