Fix ARMu debug mode failure by handling runtime calls
authorkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 6 Oct 2008 06:41:10 +0000 (06:41 +0000)
committerkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 6 Oct 2008 06:41:10 +0000 (06:41 +0000)
with the wrong number of arguments on ARM in the same
way it's done on IA32. Make sure to remove arguments
on both platforms and return the illegal result in
register eax or r0.
Review URL: http://codereview.chromium.org/6263

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

src/macro-assembler-arm.cc
src/macro-assembler-arm.h
src/macro-assembler-ia32.cc
src/macro-assembler-ia32.h

index 5e5b9c9fe1eba05c81cc5c88318e060cc0c074c8..a6c336fe646da282846e2e36ce05c3108762f465 100644 (file)
@@ -690,12 +690,24 @@ void MacroAssembler::StubReturn(int argc) {
 }
 
 
+void MacroAssembler::IllegalOperation(int num_arguments) {
+  if (num_arguments > 0) {
+    add(sp, sp, Operand(num_arguments * kPointerSize));
+  }
+  mov(r0, Operand(Factory::undefined_value()));
+}
+
+
 void MacroAssembler::CallRuntime(Runtime::Function* f, int num_arguments) {
   // All parameters are on the stack.  r0 has the return value after call.
 
-  // Either the expected number of arguments is unknown, or the actual
-  // number of arguments match the expectation.
-  ASSERT(f->nargs < 0 || f->nargs == num_arguments);
+  // If the expected number of arguments of the runtime function is
+  // constant, we check that the actual number of arguments match the
+  // expectation.
+  if (f->nargs >= 0 && f->nargs != num_arguments) {
+    IllegalOperation(num_arguments);
+    return;
+  }
 
   Runtime::FunctionId function_id =
       static_cast<Runtime::FunctionId>(f->stub_id);
index 00d2f194a1db15a6e04020745b94cc4b7995c208..7930e4cfc8e7e097dd48efc733b1db261cc79dce 100644 (file)
@@ -176,6 +176,14 @@ class MacroAssembler: public Assembler {
   void CheckAccessGlobal(Register holder_reg, Register scratch, Label* miss);
 
 
+  // ---------------------------------------------------------------------------
+  // Support functions.
+
+  // Generates code for reporting that an illegal operation has
+  // occurred.
+  void IllegalOperation(int num_arguments);
+
+
   // ---------------------------------------------------------------------------
   // Runtime calls
 
index dab6778e5d4c287886a6d0421f4c9db7ce676dd4..11ffa0138c6e6dd78a31a1d6b6772868d7d8d10c 100644 (file)
@@ -601,8 +601,11 @@ void MacroAssembler::StubReturn(int argc) {
 }
 
 
-void MacroAssembler::IllegalOperation() {
-  push(Immediate(Factory::undefined_value()));
+void MacroAssembler::IllegalOperation(int num_arguments) {
+  if (num_arguments > 0) {
+    add(Operand(esp), Immediate(num_arguments * kPointerSize));
+  }
+  mov(Operand(eax), Immediate(Factory::undefined_value()));
 }
 
 
@@ -616,7 +619,7 @@ void MacroAssembler::CallRuntime(Runtime::Function* f, int num_arguments) {
   // constant, we check that the actual number of arguments match the
   // expectation.
   if (f->nargs >= 0 && f->nargs != num_arguments) {
-    IllegalOperation();
+    IllegalOperation(num_arguments);
     return;
   }
 
index 9a923e4c894cdf02be1ec7cadf2ca0d328c32d73..d644c0f9b5a9df9ed9511e55caa5e82ddffe4b02 100644 (file)
@@ -180,8 +180,8 @@ class MacroAssembler: public Assembler {
                         Register scratch, Label* then_label);
 
   // Generates code for reporting that an illegal operation has
-  // occurred
-  void IllegalOperation();
+  // occurred.
+  void IllegalOperation(int num_arguments);
 
   // ---------------------------------------------------------------------------
   // Runtime calls