// Special handling for simulators which have a separate JS stack.
js_stack_comparable_address_ =
reinterpret_cast<void*>(v8::internal::SimulatorStack::RegisterCTryCatch(
- GetCurrentStackPosition()));
+ v8::internal::GetCurrentStackPosition()));
isolate_->RegisterTryCatchHandler(this);
}
return RoundDown<T>(static_cast<T>(x + m - 1), m);
}
-
-template <typename T, typename U>
-inline bool IsAligned(T value, U alignment) {
- return (value & (alignment - 1)) == 0;
-}
-
-
-// Returns current value of top of the stack. Works correctly with ASAN.
-DISABLE_ASAN
-inline uintptr_t GetCurrentStackPosition() {
- // Takes the address of the limit variable in order to find out where
- // the top of stack is right now.
- uintptr_t limit = reinterpret_cast<uintptr_t>(&limit);
- return limit;
-}
-
#endif // V8_BASE_MACROS_H_
VirtualMemory::VirtualMemory(size_t size, size_t alignment)
: address_(NULL), size_(0) {
- DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment())));
+ DCHECK((alignment % OS::AllocateAlignment()) == 0);
size_t request_size = RoundUp(size + alignment,
static_cast<intptr_t>(OS::AllocateAlignment()));
void* address = ReserveRegion(request_size);
VirtualMemory::VirtualMemory(size_t size, size_t alignment)
: address_(NULL), size_(0) {
- DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment())));
+ DCHECK((alignment % OS::AllocateAlignment()) == 0);
size_t request_size = RoundUp(size + alignment,
static_cast<intptr_t>(OS::AllocateAlignment()));
void* reservation = mmap(OS::GetRandomMmapAddr(),
VirtualMemory::VirtualMemory(size_t size, size_t alignment)
: address_(NULL), size_(0) {
- DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment())));
+ DCHECK((alignment % OS::AllocateAlignment()) == 0);
size_t request_size = RoundUp(size + alignment,
static_cast<intptr_t>(OS::AllocateAlignment()));
void* reservation = mmap(OS::GetRandomMmapAddr(),
VirtualMemory::VirtualMemory(size_t size, size_t alignment)
: address_(NULL), size_(0) {
- DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment())));
+ DCHECK((alignment % OS::AllocateAlignment()) == 0);
size_t request_size = RoundUp(size + alignment,
static_cast<intptr_t>(OS::AllocateAlignment()));
void* reservation = mmap(OS::GetRandomMmapAddr(),
VirtualMemory::VirtualMemory(size_t size, size_t alignment)
: address_(NULL), size_(0) {
- DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment())));
+ DCHECK((alignment % OS::AllocateAlignment()) == 0);
size_t request_size = RoundUp(size + alignment,
static_cast<intptr_t>(OS::AllocateAlignment()));
void* reservation = mmap(OS::GetRandomMmapAddr(),
VirtualMemory::VirtualMemory(size_t size, size_t alignment)
: address_(NULL), size_(0) {
- DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment())));
+ DCHECK((alignment % OS::AllocateAlignment()) == 0);
size_t request_size = RoundUp(size + alignment,
static_cast<intptr_t>(OS::AllocateAlignment()));
void* reservation = mmap(OS::GetRandomMmapAddr(),
VirtualMemory::VirtualMemory(size_t size, size_t alignment)
: address_(NULL), size_(0) {
- DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment())));
+ DCHECK((alignment % OS::AllocateAlignment()) == 0);
size_t request_size = RoundUp(size + alignment,
static_cast<intptr_t>(OS::AllocateAlignment()));
void* reservation = mmap(OS::GetRandomMmapAddr(),
if (mbase == NULL) return NULL;
- DCHECK(IsAligned(reinterpret_cast<size_t>(mbase), OS::AllocateAlignment()));
+ DCHECK((static_cast<uintptr_t>(mbase) % OS::AllocateAlignment()) == 0);
*allocated = msize;
return mbase;
VirtualMemory::VirtualMemory(size_t size, size_t alignment)
: address_(NULL), size_(0) {
- DCHECK(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment())));
+ DCHECK((alignment % OS::AllocateAlignment()) == 0);
size_t request_size = RoundUp(size + alignment,
static_cast<intptr_t>(OS::AllocateAlignment()));
void* address = ReserveRegion(request_size);
}
+template <typename T, typename U>
+inline bool IsAligned(T value, U alignment) {
+ return (value & (alignment - 1)) == 0;
+}
+
+
// Returns true if (addr + offset) is aligned.
inline bool IsAddressAligned(Address addr,
intptr_t alignment,
}
-} } // namespace v8::internal
+// Returns current value of top of the stack. Works correctly with ASAN.
+DISABLE_ASAN
+inline uintptr_t GetCurrentStackPosition() {
+ // Takes the address of the limit variable in order to find out where
+ // the top of stack is right now.
+ uintptr_t limit = reinterpret_cast<uintptr_t>(&limit);
+ return limit;
+}
+
+} // namespace internal
+} // namespace v8
#endif // V8_UTILS_H_
};
// Parser/Scanner needs a stack limit.
- CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() -
- 128 * 1024);
+ CcTest::i_isolate()->stack_guard()->SetStackLimit(
+ i::GetCurrentStackPosition() - 128 * 1024);
uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
for (int i = 0; tests[i]; i++) {
const i::byte* source =
v8::HandleScope handles(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
- CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() -
- 128 * 1024);
+ CcTest::i_isolate()->stack_guard()->SetStackLimit(
+ i::GetCurrentStackPosition() - 128 * 1024);
// Source containing functions that might be lazily compiled and all types
// of symbols (string, propertyName, regexp).
v8::HandleScope handles(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
- CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() -
- 128 * 1024);
+ CcTest::i_isolate()->stack_guard()->SetStackLimit(
+ i::GetCurrentStackPosition() - 128 * 1024);
const char* good_code[] = {
"function this_is_lazy() { var a; } function foo() { return 25; } foo();",
TEST(StandAlonePreParser) {
v8::V8::Initialize();
- CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() -
- 128 * 1024);
+ CcTest::i_isolate()->stack_guard()->SetStackLimit(
+ i::GetCurrentStackPosition() - 128 * 1024);
const char* programs[] = {
"{label: 42}",
TEST(StandAlonePreParserNoNatives) {
v8::V8::Initialize();
- CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() -
- 128 * 1024);
+ CcTest::i_isolate()->stack_guard()->SetStackLimit(
+ i::GetCurrentStackPosition() - 128 * 1024);
const char* programs[] = {
"%ArgleBargle(glop);",
v8::HandleScope handles(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
- CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() -
- 128 * 1024);
+ CcTest::i_isolate()->stack_guard()->SetStackLimit(
+ i::GetCurrentStackPosition() - 128 * 1024);
{
const char* source = "var myo = {if: \"foo\"}; myo.if;";
v8::V8::Initialize();
i::Isolate* isolate = CcTest::i_isolate();
- isolate->stack_guard()->SetStackLimit(GetCurrentStackPosition() - 128 * 1024);
+ isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
+ 128 * 1024);
const char* program = "var x = 'something';\n"
"escape: function() {}";
// as with-content, which made it assume that a function inside
// the block could be lazily compiled, and an extra, unexpected,
// entry was added to the data.
- isolate->stack_guard()->SetStackLimit(GetCurrentStackPosition() - 128 * 1024);
+ isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
+ 128 * 1024);
const char* program =
"try { } catch (e) { var foo = function () { /* first */ } }"
TEST(PreParseOverflow) {
v8::V8::Initialize();
- CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() -
- 128 * 1024);
+ CcTest::i_isolate()->stack_guard()->SetStackLimit(
+ i::GetCurrentStackPosition() - 128 * 1024);
size_t kProgramSize = 1024 * 1024;
i::SmartArrayPointer<char> program(i::NewArray<char>(kProgramSize + 1));
v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
- isolate->stack_guard()->SetStackLimit(GetCurrentStackPosition() - 128 * 1024);
+ isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
+ 128 * 1024);
for (int i = 0; source_data[i].outer_prefix; i++) {
int kPrefixLen = Utf8LengthHelper(source_data[i].outer_prefix);
v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
- CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() -
- 128 * 1024);
+ CcTest::i_isolate()->stack_guard()->SetStackLimit(
+ i::GetCurrentStackPosition() - 128 * 1024);
static const ParserFlag flags1[] = {kAllowLazy, kAllowHarmonyScoping,
kAllowModules, kAllowGenerators,
v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
v8::Context::Scope context_scope(context);
- CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() -
- 128 * 1024);
+ CcTest::i_isolate()->stack_guard()->SetStackLimit(
+ i::GetCurrentStackPosition() - 128 * 1024);
static const ParserFlag default_flags[] = {
kAllowLazy, kAllowHarmonyScoping, kAllowModules,
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handles(isolate);
- CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() -
- 128 * 1024);
+ CcTest::i_isolate()->stack_guard()->SetStackLimit(
+ i::GetCurrentStackPosition() - 128 * 1024);
struct TestCase {
const char* program;