Fix bugs 145 and 323, preemption and apply on ARM.
authorerik.corry@gmail.com <erik.corry@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 27 Apr 2009 07:03:10 +0000 (07:03 +0000)
committererik.corry@gmail.com <erik.corry@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 27 Apr 2009 07:03:10 +0000 (07:03 +0000)
Review URL: http://codereview.chromium.org/93121

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1794 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/arm/assembler-arm.h
src/arm/builtins-arm.cc
src/arm/codegen-arm.cc
test/cctest/cctest.status
test/cctest/test-api.cc
test/cctest/test-hashmap.cc
test/cctest/test-list.cc

index f965ebd8a641f5b24a0f2ce9636062e8dfa60b0d..5edccbc18542840bd3433e37d5aa4583df5d2e19 100644 (file)
@@ -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.
 };
 
 
index 58eeca8c44b70e5b0eff5351b303c2f1bf5c589b..519c04a2cf0a8e5256f29d09f3055b09b0235abf 100644 (file)
@@ -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);
index 9337454bb8a4a3959cb64da79fadd2622c79578e..57e98c157905d8c9b8e0a9aadb779ae36f50542b 100644 (file)
@@ -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);
index e56452f3e03513fd1d23fba220a1a9e3fb71c7c5..7b43c8de90f19bdce2287e2595f69aee4e97430d 100644 (file)
@@ -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
 
index d9d42364cc2b6e555bca85fa48d91f7facc8d1b4..9a3aead7ad309d23b8c18059e54575cf3d097546 100644 (file)
@@ -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;
index 0a337cb2c236084d0b00f8183ce13a2c4b3dafd4..954dbe103f8d2283303840b2df3ef404c011623f 100644 (file)
@@ -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);
index 3d8718857593b4e6d2ebd43db1967b53fd0b0dab..838a45d0dea1c15028f0a59bef43549bc38e62cd 100644 (file)
@@ -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]);
 }