Reviewers: Mads Ager,

Message:
Mads,

a tiny CL for you, please.

Description:
Unification: introduce ExternalReference::pending_exception_address().

Please review this at http://codereview.chromium.org/6335016/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/arm/code-stubs-arm.cc
  M src/assembler.h
  M src/assembler.cc
  M src/ia32/code-stubs-ia32.cc
  M src/mips/codegen-mips.cc
  M src/x64/code-stubs-x64.cc


Index: src/arm/code-stubs-arm.cc
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc
index a44600727579043f89852f211f7d61ef3838c3e2..575b8b128c668182ca43d42c18caf8052faadda9 100644
--- a/src/arm/code-stubs-arm.cc
+++ b/src/arm/code-stubs-arm.cc
@@ -2522,7 +2522,7 @@ void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm,
     // Set pending exception and r0 to out of memory exception.
     Failure* out_of_memory = Failure::OutOfMemoryException();
     __ mov(r0, Operand(reinterpret_cast<int32_t>(out_of_memory)));
- __ mov(r2, Operand(ExternalReference(Top::k_pending_exception_address)));
+    __ mov(r2, Operand(ExternalReference::pending_exception_address()));
     __ str(r0, MemOperand(r2));
   }

@@ -2669,7 +2669,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
   // Retrieve the pending exception and clear the variable.
   __ mov(ip, Operand(ExternalReference::the_hole_value_location()));
   __ ldr(r3, MemOperand(ip));
-  __ mov(ip, Operand(ExternalReference(Top::k_pending_exception_address)));
+  __ mov(ip, Operand(ExternalReference::pending_exception_address()));
   __ ldr(r0, MemOperand(ip));
   __ str(r3, MemOperand(ip));

@@ -2805,7 +2805,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
   // exception field in the JSEnv and return a failure sentinel.
   // Coming in here the fp will be invalid because the PushTryHandler below
   // sets it to 0 to signal the existence of the JSEntry frame.
-  __ mov(ip, Operand(ExternalReference(Top::k_pending_exception_address)));
+  __ mov(ip, Operand(ExternalReference::pending_exception_address()));
   __ str(r0, MemOperand(ip));
   __ mov(r0, Operand(reinterpret_cast<int32_t>(Failure::Exception())));
   __ b(&exit);
@@ -2822,7 +2822,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
   // Clear any pending exceptions.
   __ mov(ip, Operand(ExternalReference::the_hole_value_location()));
   __ ldr(r5, MemOperand(ip));
-  __ mov(ip, Operand(ExternalReference(Top::k_pending_exception_address)));
+  __ mov(ip, Operand(ExternalReference::pending_exception_address()));
   __ str(r5, MemOperand(ip));

   // Invoke the function by calling through JS entry trampoline builtin.
@@ -3489,7 +3489,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
   // TODO(592): Rerunning the RegExp to get the stack overflow exception.
   __ mov(r0, Operand(ExternalReference::the_hole_value_location()));
   __ ldr(r0, MemOperand(r0, 0));
-  __ mov(r1, Operand(ExternalReference(Top::k_pending_exception_address)));
+  __ mov(r1, Operand(ExternalReference::pending_exception_address()));
   __ ldr(r1, MemOperand(r1, 0));
   __ cmp(r0, r1);
   __ b(eq, &runtime);
Index: src/assembler.cc
diff --git a/src/assembler.cc b/src/assembler.cc
index fb9a4af14e851b15c3e71d9793f4906411d3f22e..4b7b95c205c9689447354752d3b737c762f50f25 100644
--- a/src/assembler.cc
+++ b/src/assembler.cc
@@ -713,6 +713,11 @@ ExternalReference ExternalReference::handle_scope_limit_address() {
 }


+ExternalReference ExternalReference::pending_exception_address() {
+  return ExternalReference(Top::k_pending_exception_address);
+}
+
+
 ExternalReference ExternalReference::scheduled_exception_address() {
   return ExternalReference(Top::scheduled_exception_address());
 }
Index: src/assembler.h
diff --git a/src/assembler.h b/src/assembler.h
index 4ef61e4b1402a7bc2c0e5ec0c8922a575b144236..e89eb15bfa424ae50c2b1625da38d55cc78bd4f9 100644
--- a/src/assembler.h
+++ b/src/assembler.h
@@ -552,6 +552,7 @@ class ExternalReference BASE_EMBEDDED {
   static ExternalReference handle_scope_limit_address();
   static ExternalReference handle_scope_level_address();

+  static ExternalReference pending_exception_address();
   static ExternalReference scheduled_exception_address();

   // Static variables containing common double constants.
Index: src/ia32/code-stubs-ia32.cc
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
index 2c83662efd3853cafeac85d23da62fd5cf8d441e..e8d84bf9c6b22c92ffbe345ddeb492001477a21c 100644
--- a/src/ia32/code-stubs-ia32.cc
+++ b/src/ia32/code-stubs-ia32.cc
@@ -3944,10 +3944,11 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // stack overflow (on the backtrack stack) was detected in RegExp code but
   // haven't created the exception yet. Handle that in the runtime system.
   // TODO(592): Rerunning the RegExp to get the stack overflow exception.
-  ExternalReference pending_exception(Top::k_pending_exception_address);
+  ExternalReference pending_exception_address =
+      ExternalReference::pending_exception_address();
   __ mov(eax,
Operand::StaticVariable(ExternalReference::the_hole_value_location()));
-  __ cmp(eax, Operand::StaticVariable(pending_exception));
+  __ cmp(eax, Operand::StaticVariable(pending_exception_address));
   __ j(equal, &runtime);
   __ bind(&failure);
   // For failure and exception return null.
@@ -4738,7 +4739,8 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
   __ j(equal, throw_out_of_memory_exception);

   // Retrieve the pending exception and clear the variable.
- ExternalReference pending_exception_address(Top::k_pending_exception_address);
+  ExternalReference pending_exception_address =
+      ExternalReference::pending_exception_address();
   __ mov(eax, Operand::StaticVariable(pending_exception_address));
   __ mov(edx,
Operand::StaticVariable(ExternalReference::the_hole_value_location())); @@ -4790,9 +4792,10 @@ void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm,
     __ mov(Operand::StaticVariable(external_caught), eax);

     // Set pending exception and eax to out of memory exception.
-    ExternalReference pending_exception(Top::k_pending_exception_address);
+    ExternalReference pending_exception_address =
+        ExternalReference::pending_exception_address();
__ mov(eax, reinterpret_cast<int32_t>(Failure::OutOfMemoryException()));
-    __ mov(Operand::StaticVariable(pending_exception), eax);
+    __ mov(Operand::StaticVariable(pending_exception_address), eax);
   }

   // Clear the context pointer.
@@ -4908,8 +4911,9 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {

   // Caught exception: Store result (exception) in the pending
   // exception field in the JSEnv and return a failure sentinel.
-  ExternalReference pending_exception(Top::k_pending_exception_address);
-  __ mov(Operand::StaticVariable(pending_exception), eax);
+  ExternalReference pending_exception_address =
+      ExternalReference::pending_exception_address();
+  __ mov(Operand::StaticVariable(pending_exception_address), eax);
   __ mov(eax, reinterpret_cast<int32_t>(Failure::Exception()));
   __ jmp(&exit);

@@ -4920,7 +4924,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
   // Clear any pending exceptions.
   __ mov(edx,
Operand::StaticVariable(ExternalReference::the_hole_value_location()));
-  __ mov(Operand::StaticVariable(pending_exception), edx);
+  __ mov(Operand::StaticVariable(pending_exception_address), edx);

   // Fake a receiver (NULL).
   __ push(Immediate(0));  // receiver
Index: src/mips/codegen-mips.cc
diff --git a/src/mips/codegen-mips.cc b/src/mips/codegen-mips.cc
index 79801f07becbd30506897511854a47f95285458d..3bda275ca1cd7d9accb266eb6094574ff2081af8 100644
--- a/src/mips/codegen-mips.cc
+++ b/src/mips/codegen-mips.cc
@@ -1178,7 +1178,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
__ LoadExternalReference(t0, ExternalReference::the_hole_value_location());
   __ lw(a3, MemOperand(t0));
   __ LoadExternalReference(t0,
-      ExternalReference(Top::k_pending_exception_address));
+      ExternalReference::pending_exception_address());
   __ lw(v0, MemOperand(t0));
   __ sw(a3, MemOperand(t0));

@@ -1311,7 +1311,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
   // Coming in here the fp will be invalid because the PushTryHandler below
   // sets it to 0 to signal the existence of the JSEntry frame.
   __ LoadExternalReference(t0,
-      ExternalReference(Top::k_pending_exception_address));
+      ExternalReference::pending_exception_address());
__ sw(v0, MemOperand(t0)); // We come back from 'invoke'. result is in v0.
   __ li(v0, Operand(reinterpret_cast<int32_t>(Failure::Exception())));
   __ b(&exit);
@@ -1329,7 +1329,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { __ LoadExternalReference(t0, ExternalReference::the_hole_value_location());
   __ lw(t1, MemOperand(t0));
   __ LoadExternalReference(t0,
-      ExternalReference(Top::k_pending_exception_address));
+      ExternalReference::pending_exception_address());
   __ sw(t1, MemOperand(t0));

   // Invoke the function by calling through JS entry trampoline builtin.
Index: src/x64/code-stubs-x64.cc
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
index a261b9d086d24219ef62ec92a4522a4ecd3ef8bd..c9d86d9ebd28a3bf9c00c0716bb09d34379d71bb 100644
--- a/src/x64/code-stubs-x64.cc
+++ b/src/x64/code-stubs-x64.cc
@@ -2125,8 +2125,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
// stack overflow (on the backtrack stack) was detected in RegExp code but
   // haven't created the exception yet. Handle that in the runtime system.
   // TODO(592): Rerunning the RegExp to get the stack overflow exception.
- ExternalReference pending_exception_address(Top::k_pending_exception_address);
-  __ movq(kScratchRegister, pending_exception_address);
+ __ movq(kScratchRegister, ExternalReference::pending_exception_address());
   __ Cmp(kScratchRegister, Factory::the_hole_value());
   __ j(equal, &runtime);
   __ bind(&failure);
@@ -2885,8 +2884,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
   __ j(equal, throw_out_of_memory_exception);

   // Retrieve the pending exception and clear the variable.
- ExternalReference pending_exception_address(Top::k_pending_exception_address);
-  __ movq(kScratchRegister, pending_exception_address);
+ __ movq(kScratchRegister, ExternalReference::pending_exception_address());
   __ movq(rax, Operand(kScratchRegister, 0));
   __ movq(rdx, ExternalReference::the_hole_value_location());
   __ movq(rdx, Operand(rdx, 0));
@@ -2936,9 +2934,8 @@ void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm,
     __ store_rax(external_caught);

     // Set pending exception and rax to out of memory exception.
-    ExternalReference pending_exception(Top::k_pending_exception_address);
     __ movq(rax, Failure::OutOfMemoryException(), RelocInfo::NONE);
-    __ store_rax(pending_exception);
+    __ store_rax(ExternalReference::pending_exception_address());
   }

   // Clear the context pointer.
@@ -3091,8 +3088,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {

   // Caught exception: Store result (exception) in the pending
   // exception field in the JSEnv and return a failure sentinel.
-  ExternalReference pending_exception(Top::k_pending_exception_address);
-  __ store_rax(pending_exception);
+  __ store_rax(ExternalReference::pending_exception_address());
   __ movq(rax, Failure::Exception(), RelocInfo::NONE);
   __ jmp(&exit);

@@ -3102,7 +3098,7 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {

   // Clear any pending exceptions.
   __ load_rax(ExternalReference::the_hole_value_location());
-  __ store_rax(pending_exception);
+  __ store_rax(ExternalReference::pending_exception_address());

   // Fake a receiver (NULL).
   __ push(Immediate(0));  // receiver


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to