Add MacroAssembler::patchableBranch64 and fix ARM64's patchableBranchPtr
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Aug 2015 17:31:27 +0000 (17:31 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Aug 2015 17:31:27 +0000 (17:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147761

Reviewed by Mark Lam.

This patch implements MacroAssembler::patchableBranch64 in 64bit environments.
And fix the existing MacroAssemblerARM64::patchableBranchPtr, before this patch,
it truncates the immediate pointer into the 32bit immediate.
And use patchableBranch64 in the baseline JIT under the JSVALUE64 configuration.

* assembler/MacroAssemblerARM64.h:
(JSC::MacroAssemblerARM64::patchableBranchPtr):
(JSC::MacroAssemblerARM64::patchableBranch64):
* assembler/MacroAssemblerX86_64.h:
(JSC::MacroAssemblerX86_64::patchableBranch64):
* jit/JIT.h:
* jit/JITInlines.h:
(JSC::JIT::emitPatchableJumpIfNotImmediateInteger):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_by_val):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188135 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/assembler/MacroAssemblerARM64.h
Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h
Source/JavaScriptCore/jit/JIT.h
Source/JavaScriptCore/jit/JITInlines.h
Source/JavaScriptCore/jit/JITPropertyAccess.cpp

index f023574..7110915 100644 (file)
@@ -1,3 +1,26 @@
+2015-08-07  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Add MacroAssembler::patchableBranch64 and fix ARM64's patchableBranchPtr
+        https://bugs.webkit.org/show_bug.cgi?id=147761
+
+        Reviewed by Mark Lam.
+
+        This patch implements MacroAssembler::patchableBranch64 in 64bit environments.
+        And fix the existing MacroAssemblerARM64::patchableBranchPtr, before this patch,
+        it truncates the immediate pointer into the 32bit immediate.
+        And use patchableBranch64 in the baseline JIT under the JSVALUE64 configuration.
+
+        * assembler/MacroAssemblerARM64.h:
+        (JSC::MacroAssemblerARM64::patchableBranchPtr):
+        (JSC::MacroAssemblerARM64::patchableBranch64):
+        * assembler/MacroAssemblerX86_64.h:
+        (JSC::MacroAssemblerX86_64::patchableBranch64):
+        * jit/JIT.h:
+        * jit/JITInlines.h:
+        (JSC::JIT::emitPatchableJumpIfNotImmediateInteger):
+        * jit/JITPropertyAccess.cpp:
+        (JSC::JIT::emit_op_get_by_val):
+
 2015-08-06  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Introduce get_by_id like IC into get_by_val when the given name is String or Symbol
index 661fc0a..c825859 100644 (file)
@@ -2341,10 +2341,10 @@ public:
         return branch32(cond, left, dataTempRegister);
     }
 
-    PatchableJump patchableBranchPtr(RelationalCondition cond, Address left, TrustedImmPtr right = TrustedImmPtr(0))
+    PatchableJump patchableBranchPtr(RelationalCondition cond, Address left, TrustedImmPtr right)
     {
         m_makeJumpPatchable = true;
-        Jump result = branch32(cond, left, TrustedImm32(right));
+        Jump result = branch64(cond, left, TrustedImm64(right));
         m_makeJumpPatchable = false;
         return PatchableJump(result);
     }
@@ -2365,6 +2365,22 @@ public:
         return PatchableJump(result);
     }
 
+    PatchableJump patchableBranch64(RelationalCondition cond, RegisterID reg, TrustedImm64 imm)
+    {
+        m_makeJumpPatchable = true;
+        Jump result = branch64(cond, reg, imm);
+        m_makeJumpPatchable = false;
+        return PatchableJump(result);
+    }
+
+    PatchableJump patchableBranch64(RelationalCondition cond, RegisterID left, RegisterID right)
+    {
+        m_makeJumpPatchable = true;
+        Jump result = branch64(cond, left, right);
+        m_makeJumpPatchable = false;
+        return PatchableJump(result);
+    }
+
     PatchableJump patchableBranchPtrWithPatch(RelationalCondition cond, Address left, DataLabelPtr& dataLabel, TrustedImmPtr initialRightValue = TrustedImmPtr(0))
     {
         m_makeJumpPatchable = true;
index 920de74..cee55f9 100644 (file)
@@ -756,6 +756,16 @@ public:
         store64(scratchRegister, address);
         return label;
     }
+
+    PatchableJump patchableBranch64(RelationalCondition cond, RegisterID reg, TrustedImm64 imm)
+    {
+        return PatchableJump(branch64(cond, reg, imm));
+    }
+
+    PatchableJump patchableBranch64(RelationalCondition cond, RegisterID left, RegisterID right)
+    {
+        return PatchableJump(branch64(cond, left, right));
+    }
     
     using MacroAssemblerX86Common::branch8;
     Jump branch8(RelationalCondition cond, AbsoluteAddress left, TrustedImm32 right)
index 8ca0857..90108af 100644 (file)
@@ -450,6 +450,7 @@ namespace JSC {
         Jump emitJumpIfImmediateInteger(RegisterID);
         Jump emitJumpIfNotImmediateInteger(RegisterID);
         Jump emitJumpIfNotImmediateIntegers(RegisterID, RegisterID, RegisterID);
+        PatchableJump emitPatchableJumpIfNotImmediateInteger(RegisterID);
         void emitJumpSlowCaseIfNotImmediateInteger(RegisterID);
         void emitJumpSlowCaseIfNotImmediateNumber(RegisterID);
         void emitJumpSlowCaseIfNotImmediateIntegers(RegisterID, RegisterID, RegisterID);
index acd8c89..5d68690 100644 (file)
@@ -1208,6 +1208,11 @@ ALWAYS_INLINE JIT::Jump JIT::emitJumpIfNotImmediateInteger(RegisterID reg)
     return branch64(Below, reg, tagTypeNumberRegister);
 }
 
+ALWAYS_INLINE JIT::PatchableJump JIT::emitPatchableJumpIfNotImmediateInteger(RegisterID reg)
+{
+    return patchableBranch64(Below, reg, tagTypeNumberRegister);
+}
+
 ALWAYS_INLINE JIT::Jump JIT::emitJumpIfNotImmediateIntegers(RegisterID reg1, RegisterID reg2, RegisterID scratch)
 {
     move(reg1, scratch);
index 73deb96..a00ccb2 100644 (file)
@@ -104,18 +104,9 @@ void JIT::emit_op_get_by_val(Instruction* currentInstruction)
 
     emitJumpSlowCaseIfNotJSCell(regT0, base);
 
-    // FIXME: patchableBranch64 could reduce the following 2 jumps into 1. Like,
-    //
-    // PatchableJump notIndex = emitJumpIfNotImmediateInteger(regT1);
-    //
-    // To use patchableBranch64, we need to fix the existing patchableBranchPtr in ARM64
-    // and introduce patchableBranch64 helper function for 64bit environments.
-    // https://bugs.webkit.org/show_bug.cgi?id=147761
-    Jump isIndex = emitJumpIfImmediateInteger(regT1);
-    PatchableJump notIndex = patchableJump();
+    PatchableJump notIndex = emitPatchableJumpIfNotImmediateInteger(regT1);
     addSlowCase(notIndex);
 
-    isIndex.link(this);
     // This is technically incorrect - we're zero-extending an int32.  On the hot path this doesn't matter.
     // We check the value as if it was a uint32 against the m_vectorLength - which will always fail if
     // number was signed since m_vectorLength is always less than intmax (since the total allocation