Files
sdk/runtime/vm/allocation.cc
T
turnidge@google.com 1f5364cd3b Add support for native ports in the vm.
Dart_NewNativePort creates a port associated with a C handler
function.  When messages come in on this port, they are forwarded to
the C function for processing.

To support this, refactored PortMap so that it operates on a new
MessageHandler type instead of directly on Isolates.

For now, native ports have a dedicated single thread.  Eventually we
will back native ports (and possibly Isolates as well) by a shared
thread pool.
Review URL: https://chromiumcodereview.appspot.com//9169063

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3804 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-01 18:53:40 +00:00

46 lines
1.2 KiB
C++

// 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.
#include "vm/allocation.h"
#include "platform/assert.h"
#include "vm/isolate.h"
#include "vm/zone.h"
namespace dart {
StackResource::StackResource(Isolate* isolate)
: isolate_(isolate), previous_(NULL) {
// We can only have longjumps and exceptions when there is a current
// isolate. If there is no current isolate, we don't need to
// protect this case.
if (isolate) {
previous_ = isolate->top_resource();
isolate->set_top_resource(this);
}
}
StackResource::~StackResource() {
if (isolate()) {
StackResource* top = isolate()->top_resource();
ASSERT(top == this);
isolate()->set_top_resource(previous_);
}
ASSERT(Isolate::Current() == isolate());
}
ZoneAllocated::~ZoneAllocated() {
UNREACHABLE();
}
void* ZoneAllocated::operator new(uword size) {
Isolate* isolate = Isolate::Current();
ASSERT(isolate != NULL);
ASSERT(isolate->current_zone() != NULL);
return reinterpret_cast<void*>(isolate->current_zone()->Allocate(size));
}
} // namespace dart