2012-04-06 18:00:51 +00:00
|
|
|
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
2016-10-26 07:26:03 +00:00
|
|
|
#ifndef RUNTIME_VM_BASE_ISOLATE_H_
|
|
|
|
#define RUNTIME_VM_BASE_ISOLATE_H_
|
2012-04-06 18:00:51 +00:00
|
|
|
|
2015-03-25 22:41:33 +00:00
|
|
|
#include "platform/assert.h"
|
2015-02-20 20:46:31 +00:00
|
|
|
#include "vm/globals.h"
|
|
|
|
|
2012-04-06 18:00:51 +00:00
|
|
|
namespace dart {
|
|
|
|
|
|
|
|
class HandleScope;
|
|
|
|
class StackResource;
|
2015-07-09 18:22:26 +00:00
|
|
|
class Thread;
|
2012-10-16 22:05:40 +00:00
|
|
|
class Zone;
|
2012-04-06 18:00:51 +00:00
|
|
|
|
|
|
|
// A BaseIsolate contains just enough functionality to allocate
|
|
|
|
// StackResources. This allows us to inline the StackResource
|
|
|
|
// constructor/destructor for performance.
|
|
|
|
class BaseIsolate {
|
|
|
|
public:
|
2015-06-17 15:25:26 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
void AssertCurrentThreadIsMutator() const;
|
|
|
|
#else
|
|
|
|
void AssertCurrentThreadIsMutator() const {}
|
|
|
|
#endif // DEBUG
|
2012-04-06 18:00:51 +00:00
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
static void AssertCurrent(BaseIsolate* isolate);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2019-07-11 13:36:02 +00:00
|
|
|
BaseIsolate() {}
|
2012-04-06 18:00:51 +00:00
|
|
|
|
|
|
|
~BaseIsolate() {
|
|
|
|
// Do not delete stack resources: top_resource_ and current_zone_.
|
|
|
|
}
|
|
|
|
|
2019-07-11 13:36:02 +00:00
|
|
|
Thread* scheduled_mutator_thread_ = nullptr;
|
|
|
|
|
|
|
|
// TODO(asiva): Currently we treat a mutator thread as a special thread
|
|
|
|
// and always schedule execution of Dart code on the same mutator thread
|
|
|
|
// object. The ApiLocalScope has been made thread specific but we still
|
|
|
|
// have scenarios where we do a temporary exit of an Isolate with live
|
|
|
|
// zones/handles in the API scope :
|
|
|
|
// - Dart_RunLoop()
|
|
|
|
// - IsolateSaver in Dart_NewNativePort
|
|
|
|
// We probably need a mechanism to return to the specific thread only
|
|
|
|
// for these specific cases. We should also determine if the embedder
|
|
|
|
// should allow exiting an isolate with live state in zones/handles in
|
|
|
|
// which case a new API for returning to the specific thread needs to be
|
|
|
|
// added.
|
|
|
|
Thread* mutator_thread_ = nullptr;
|
2012-04-06 18:00:51 +00:00
|
|
|
|
2013-06-24 22:41:01 +00:00
|
|
|
private:
|
2012-04-06 18:00:51 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(BaseIsolate);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dart
|
|
|
|
|
2016-10-26 07:26:03 +00:00
|
|
|
#endif // RUNTIME_VM_BASE_ISOLATE_H_
|