Bug 732845 - Call relookupOrAdd instead of add in generateVMWrapper. r=dvander
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 15 May 2012 20:25:47 +0200
changeset 95390 06338317eaba9190894a1b60b9ea3d1a8137eb18
parent 95389 c83c77b4ed05534bfae3ea4ab386365d93fb602c
child 95391 da2151ef57f04c5d377a22d532ba3f34d5956c38
push id893
push userjandemooij@gmail.com
push dateTue, 15 May 2012 18:26:58 +0000
reviewersdvander
bugs732845
milestone15.0a1
Bug 732845 - Call relookupOrAdd instead of add in generateVMWrapper. r=dvander
js/src/ion/arm/Trampoline-arm.cpp
js/src/ion/x64/Trampoline-x64.cpp
js/src/ion/x86/Trampoline-x86.cpp
--- a/js/src/ion/arm/Trampoline-arm.cpp
+++ b/js/src/ion/arm/Trampoline-arm.cpp
@@ -674,17 +674,22 @@ IonCompartment::generateVMWrapper(JSCont
     masm.leaveExitFrame();
     masm.retn(Imm32(sizeof(IonExitFrameLayout) + f.explicitStackSlots() * sizeof(void *)));
 
     masm.bind(&exception);
     masm.handleException();
 
     Linker linker(masm);
     IonCode *wrapper = linker.newCode(cx);
-    if (!wrapper || !functionWrappers_->add(p, &f, wrapper))
+    if (!wrapper)
+        return NULL;
+
+    // linker.newCode may trigger a GC and sweep functionWrappers_ so we have to
+    // use relookupOrAdd instead of add.
+    if (!functionWrappers_->relookupOrAdd(p, &f, wrapper))
         return NULL;
 
     return wrapper;
 }
 
 IonCode *
 IonCompartment::generatePreBarrier(JSContext *cx)
 {
--- a/js/src/ion/x64/Trampoline-x64.cpp
+++ b/js/src/ion/x64/Trampoline-x64.cpp
@@ -576,17 +576,22 @@ IonCompartment::generateVMWrapper(JSCont
     masm.leaveExitFrame();
     masm.retn(Imm32(sizeof(IonExitFrameLayout) + f.explicitStackSlots() * sizeof(void *)));
 
     masm.bind(&exception);
     masm.handleException();
 
     Linker linker(masm);
     IonCode *wrapper = linker.newCode(cx);
-    if (!wrapper || !functionWrappers_->add(p, &f, wrapper))
+    if (!wrapper)
+        return NULL;
+
+    // linker.newCode may trigger a GC and sweep functionWrappers_ so we have to
+    // use relookupOrAdd instead of add.
+    if (!functionWrappers_->relookupOrAdd(p, &f, wrapper))
         return NULL;
 
     return wrapper;
 }
 
 IonCode *
 IonCompartment::generatePreBarrier(JSContext *cx)
 {
--- a/js/src/ion/x86/Trampoline-x86.cpp
+++ b/js/src/ion/x86/Trampoline-x86.cpp
@@ -607,17 +607,22 @@ IonCompartment::generateVMWrapper(JSCont
     masm.leaveExitFrame();
     masm.retn(Imm32(sizeof(IonExitFrameLayout) + f.explicitStackSlots() * sizeof(void *)));
 
     masm.bind(&exception);
     masm.handleException();
 
     Linker linker(masm);
     IonCode *wrapper = linker.newCode(cx);
-    if (!wrapper || !functionWrappers_->add(p, &f, wrapper))
+    if (!wrapper)
+        return NULL;
+
+    // linker.newCode may trigger a GC and sweep functionWrappers_ so we have to
+    // use relookupOrAdd instead of add.
+    if (!functionWrappers_->relookupOrAdd(p, &f, wrapper))
         return NULL;
 
     return wrapper;
 }
 
 IonCode *
 IonCompartment::generatePreBarrier(JSContext *cx)
 {