Commit f08b2a88 authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Fix bugs 145 and 323, preemption and apply on ARM.

Review URL: http://codereview.chromium.org/93121

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1794 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d8daf5f8
......@@ -164,23 +164,23 @@ enum Coprocessor {
// Condition field in instructions
enum Condition {
eq = 0 << 28,
ne = 1 << 28,
cs = 2 << 28,
hs = 2 << 28,
cc = 3 << 28,
lo = 3 << 28,
mi = 4 << 28,
pl = 5 << 28,
vs = 6 << 28,
vc = 7 << 28,
hi = 8 << 28,
ls = 9 << 28,
ge = 10 << 28,
lt = 11 << 28,
gt = 12 << 28,
le = 13 << 28,
al = 14 << 28
eq = 0 << 28, // Z set equal.
ne = 1 << 28, // Z clear not equal.
cs = 2 << 28, // C set unsigned higher or same.
hs = 2 << 28, // C set unsigned higher or same.
cc = 3 << 28, // C clear unsigned lower.
lo = 3 << 28, // C clear unsigned lower.
mi = 4 << 28, // N set negative.
pl = 5 << 28, // N clear positive or zero.
vs = 6 << 28, // V set overflow.
vc = 7 << 28, // V clear no overflow.
hi = 8 << 28, // C set, Z clear unsigned higher.
ls = 9 << 28, // C clear or Z set unsigned lower or same.
ge = 10 << 28, // N == V greater or equal.
lt = 11 << 28, // N != V less than.
gt = 12 << 28, // Z clear, N == V greater than.
le = 13 << 28, // Z set or N != V less then or equal
al = 14 << 28 // always.
};
......
......@@ -417,15 +417,35 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
__ push(r0);
__ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_JS);
// Eagerly check for stack-overflow before starting to push the arguments.
// r0: number of arguments
Label okay;
Label no_preemption, retry_preemption;
__ bind(&retry_preemption);
ExternalReference stack_guard_limit_address =
ExternalReference::address_of_stack_guard_limit();
__ mov(r2, Operand(stack_guard_limit_address));
__ ldr(r2, MemOperand(r2));
__ cmp(sp, r2);
__ b(hi, &no_preemption);
// We have encountered a preemption or stack overflow already before we push
// the array contents. Save r0 which is the Smi-tagged length of the array.
__ push(r0);
// Runtime routines expect at least one argument, so give it a Smi.
__ mov(r0, Operand(Smi::FromInt(0)));
__ push(r0);
__ CallRuntime(Runtime::kStackGuard, 1);
// Since we returned, it wasn't a stack overflow. Restore r0 and try again.
__ pop(r0);
__ b(&retry_preemption);
__ bind(&no_preemption);
// Eagerly check for stack-overflow before starting to push the arguments.
// r0: number of arguments.
// r2: stack limit.
Label okay;
__ sub(r2, sp, r2);
__ sub(r2, r2, Operand(3 * kPointerSize)); // limit, index, receiver
__ cmp(r2, Operand(r0, LSL, kPointerSizeLog2 - kSmiTagSize));
__ b(hi, &okay);
......
......@@ -4596,7 +4596,9 @@ void StackCheckStub::Generate(MacroAssembler* masm) {
__ ldr(ip, MemOperand(ip));
__ cmp(sp, Operand(ip));
__ b(hs, &within_limit);
// Do tail-call to runtime routine.
// Do tail-call to runtime routine. Runtime routines expect at least one
// argument, so give it a Smi.
__ mov(r0, Operand(Smi::FromInt(0)));
__ push(r0);
__ TailCallRuntime(ExternalReference(Runtime::kStackGuard), 1);
__ bind(&within_limit);
......
......@@ -34,9 +34,6 @@ test-debug/DebuggerAgent: PASS, (PASS || FAIL) if $system == linux
test-debug: SKIP
# Bug http://code.google.com/p/v8/issues/detail?id=323
test-api/ApplyInterruption: SKIP
# BUG(113): Test seems flaky on ARM.
test-spaces/LargeObjectSpace: PASS || FAIL
......
......@@ -6081,6 +6081,8 @@ class ApplyInterruptTest {
Local<String> source = String::New(c_source);
Local<Script> script = Script::Compile(source);
Local<Value> result = script->Run();
// Check that no exception was thrown.
CHECK(!result.IsEmpty());
}
int gc_after = gc_count_;
gc_during_apply_ += gc_after - gc_before;
......
......@@ -43,7 +43,7 @@ class IntSet {
IntSet() : map_(DefaultMatchFun) {}
void Insert(int x) {
CHECK(x != 0); // 0 corresponds to (void*)NULL - illegal key value
CHECK_NE(0, x); // 0 corresponds to (void*)NULL - illegal key value
HashMap::Entry* p = map_.Lookup(reinterpret_cast<void*>(x), Hash(x), true);
CHECK(p != NULL); // insert is set!
CHECK_EQ(reinterpret_cast<void*>(x), p->key);
......
......@@ -63,5 +63,5 @@ TEST(ListAdd) {
// Add an existing element, the backing store should have to grow.
list.Add(list[0]);
CHECK(list[4] == 1);
CHECK_EQ(1, list[4]);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment