05e2ba9540
Maintain a separate top_exit_frame_info for simulated frames and use it to verify that longjumps are safe. Make sure unwinding of scopes works in the presence of a simulator. Support inline allocation of objects. Support checking of inline cache and instance calls. Support subtype test cache. Support (some) equality checks. Support for (some) conditional branches. Support for pool pointer setup in stubs. Review URL: https://codereview.chromium.org//13502002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20890 260f80e4-7a28-3924-810f-c04153c831b5
59 lines
1.7 KiB
C++
59 lines
1.7 KiB
C++
// Copyright (c) 2011, 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/longjump.h"
|
|
|
|
#include "include/dart_api.h"
|
|
|
|
#include "vm/dart_api_impl.h"
|
|
#include "vm/isolate.h"
|
|
#include "vm/object.h"
|
|
#include "vm/object_store.h"
|
|
#include "vm/os.h"
|
|
#include "vm/simulator.h"
|
|
|
|
namespace dart {
|
|
|
|
jmp_buf* LongJump::Set() {
|
|
top_ = Isolate::Current()->top_resource();
|
|
return &environment_;
|
|
}
|
|
|
|
|
|
bool LongJump::IsSafeToJump() {
|
|
// We do not want to jump past Dart frames. Note that this code
|
|
// assumes the stack grows from high to low.
|
|
Isolate* isolate = Isolate::Current();
|
|
uword jumpbuf_addr = reinterpret_cast<uword>(this);
|
|
#if defined(USING_SIMULATOR)
|
|
uword top_exit_frame_info = isolate->simulator()->top_exit_frame_info();
|
|
#else
|
|
uword top_exit_frame_info = isolate->top_exit_frame_info();
|
|
#endif
|
|
return ((top_exit_frame_info == 0) || (jumpbuf_addr < top_exit_frame_info));
|
|
}
|
|
|
|
|
|
void LongJump::Jump(int value, const Error& error) {
|
|
// A zero is the default return value from setting up a LongJump using Set.
|
|
ASSERT(value != 0);
|
|
ASSERT(IsSafeToJump());
|
|
|
|
Isolate* isolate = Isolate::Current();
|
|
|
|
// Remember the error in the sticky error of this isolate.
|
|
isolate->object_store()->set_sticky_error(error);
|
|
|
|
// Destruct all the active StackResource objects.
|
|
StackResource* current_resource = isolate->top_resource();
|
|
while (current_resource != top_) {
|
|
current_resource->~StackResource();
|
|
current_resource = isolate->top_resource();
|
|
}
|
|
longjmp(environment_, value);
|
|
UNREACHABLE();
|
|
}
|
|
|
|
} // namespace dart
|