summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/jit/JITInlineCacheGenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/jit/JITInlineCacheGenerator.cpp')
-rw-r--r--Source/JavaScriptCore/jit/JITInlineCacheGenerator.cpp126
1 files changed, 50 insertions, 76 deletions
diff --git a/Source/JavaScriptCore/jit/JITInlineCacheGenerator.cpp b/Source/JavaScriptCore/jit/JITInlineCacheGenerator.cpp
index 74b086a7c..04179394a 100644
--- a/Source/JavaScriptCore/jit/JITInlineCacheGenerator.cpp
+++ b/Source/JavaScriptCore/jit/JITInlineCacheGenerator.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,70 +29,60 @@
#if ENABLE(JIT)
#include "CodeBlock.h"
+#include "InlineAccess.h"
+#include "JSCInlines.h"
#include "LinkBuffer.h"
-#include "Operations.h"
+#include "StructureStubInfo.h"
namespace JSC {
static StructureStubInfo* garbageStubInfo()
{
- static StructureStubInfo* stubInfo = new StructureStubInfo();
+ static StructureStubInfo* stubInfo = new StructureStubInfo(AccessType::Get);
return stubInfo;
}
-JITInlineCacheGenerator::JITInlineCacheGenerator(CodeBlock* codeBlock, CodeOrigin codeOrigin)
+JITInlineCacheGenerator::JITInlineCacheGenerator(
+ CodeBlock* codeBlock, CodeOrigin codeOrigin, CallSiteIndex callSite, AccessType accessType)
: m_codeBlock(codeBlock)
{
- m_stubInfo = m_codeBlock ? m_codeBlock->addStubInfo() : garbageStubInfo();
+ m_stubInfo = m_codeBlock ? m_codeBlock->addStubInfo(accessType) : garbageStubInfo();
m_stubInfo->codeOrigin = codeOrigin;
+ m_stubInfo->callSiteIndex = callSite;
}
JITByIdGenerator::JITByIdGenerator(
- CodeBlock* codeBlock, CodeOrigin codeOrigin, const RegisterSet& usedRegisters,
- GPRReg callFrameRegister, JSValueRegs base, JSValueRegs value, bool registersFlushed)
- : JITInlineCacheGenerator(codeBlock, codeOrigin)
+ CodeBlock* codeBlock, CodeOrigin codeOrigin, CallSiteIndex callSite, AccessType accessType,
+ const RegisterSet& usedRegisters, JSValueRegs base, JSValueRegs value)
+ : JITInlineCacheGenerator(codeBlock, codeOrigin, callSite, accessType)
, m_base(base)
, m_value(value)
{
- m_stubInfo->patch.registersFlushed = registersFlushed;
m_stubInfo->patch.usedRegisters = usedRegisters;
- // This is a convenience - in cases where the only registers you're using are base/value,
- // it allows you to pass RegisterSet() as the usedRegisters argument.
- m_stubInfo->patch.usedRegisters.set(base);
- m_stubInfo->patch.usedRegisters.set(value);
-
- m_stubInfo->patch.callFrameRegister = static_cast<int8_t>(callFrameRegister);
m_stubInfo->patch.baseGPR = static_cast<int8_t>(base.payloadGPR());
m_stubInfo->patch.valueGPR = static_cast<int8_t>(value.payloadGPR());
#if USE(JSVALUE32_64)
+ m_stubInfo->patch.baseTagGPR = static_cast<int8_t>(base.tagGPR());
m_stubInfo->patch.valueTagGPR = static_cast<int8_t>(value.tagGPR());
#endif
}
void JITByIdGenerator::finalize(LinkBuffer& fastPath, LinkBuffer& slowPath)
{
- CodeLocationCall callReturnLocation = slowPath.locationOf(m_call);
- m_stubInfo->callReturnLocation = callReturnLocation;
- m_stubInfo->patch.deltaCheckImmToCall = MacroAssembler::differenceBetweenCodePtr(
- fastPath.locationOf(m_structureImm), callReturnLocation);
- m_stubInfo->patch.deltaCallToJump = MacroAssembler::differenceBetweenCodePtr(
- callReturnLocation, fastPath.locationOf(m_structureCheck));
-#if USE(JSVALUE64)
- m_stubInfo->patch.deltaCallToLoadOrStore = MacroAssembler::differenceBetweenCodePtr(
- callReturnLocation, fastPath.locationOf(m_loadOrStore));
-#else
- m_stubInfo->patch.deltaCallToTagLoadOrStore = MacroAssembler::differenceBetweenCodePtr(
- callReturnLocation, fastPath.locationOf(m_tagLoadOrStore));
- m_stubInfo->patch.deltaCallToPayloadLoadOrStore = MacroAssembler::differenceBetweenCodePtr(
- callReturnLocation, fastPath.locationOf(m_loadOrStore));
-#endif
- m_stubInfo->patch.deltaCallToSlowCase = MacroAssembler::differenceBetweenCodePtr(
- callReturnLocation, slowPath.locationOf(m_slowPathBegin));
- m_stubInfo->patch.deltaCallToDone = MacroAssembler::differenceBetweenCodePtr(
- callReturnLocation, fastPath.locationOf(m_done));
- m_stubInfo->patch.deltaCallToStorageLoad = MacroAssembler::differenceBetweenCodePtr(
- callReturnLocation, fastPath.locationOf(m_propertyStorageLoad));
+ ASSERT(m_start.isSet());
+ CodeLocationLabel start = fastPath.locationOf(m_start);
+ m_stubInfo->patch.start = start;
+
+ int32_t inlineSize = MacroAssembler::differenceBetweenCodePtr(
+ start, fastPath.locationOf(m_done));
+ ASSERT(inlineSize > 0);
+ m_stubInfo->patch.inlineSize = inlineSize;
+
+ m_stubInfo->patch.deltaFromStartToSlowPathCallLocation = MacroAssembler::differenceBetweenCodePtr(
+ start, slowPath.locationOf(m_slowPathCall));
+ m_stubInfo->patch.deltaFromStartToSlowPathStart = MacroAssembler::differenceBetweenCodePtr(
+ start, slowPath.locationOf(m_slowPathBegin));
}
void JITByIdGenerator::finalize(LinkBuffer& linkBuffer)
@@ -100,42 +90,38 @@ void JITByIdGenerator::finalize(LinkBuffer& linkBuffer)
finalize(linkBuffer, linkBuffer);
}
-void JITByIdGenerator::generateFastPathChecks(MacroAssembler& jit, GPRReg butterfly)
+void JITByIdGenerator::generateFastCommon(MacroAssembler& jit, size_t inlineICSize)
{
- m_structureCheck = jit.patchableBranchPtrWithPatch(
- MacroAssembler::NotEqual,
- MacroAssembler::Address(m_base.payloadGPR(), JSCell::structureOffset()),
- m_structureImm, MacroAssembler::TrustedImmPtr(reinterpret_cast<void*>(unusedPointer)));
-
- m_propertyStorageLoad = jit.convertibleLoadPtr(
- MacroAssembler::Address(m_base.payloadGPR(), JSObject::butterflyOffset()), butterfly);
+ m_start = jit.label();
+ size_t startSize = jit.m_assembler.buffer().codeSize();
+ m_slowPathJump = jit.jump();
+ size_t jumpSize = jit.m_assembler.buffer().codeSize() - startSize;
+ size_t nopsToEmitInBytes = inlineICSize - jumpSize;
+ jit.emitNops(nopsToEmitInBytes);
+ ASSERT(jit.m_assembler.buffer().codeSize() - startSize == inlineICSize);
+ m_done = jit.label();
+}
+
+JITGetByIdGenerator::JITGetByIdGenerator(
+ CodeBlock* codeBlock, CodeOrigin codeOrigin, CallSiteIndex callSite, const RegisterSet& usedRegisters,
+ UniquedStringImpl* propertyName, JSValueRegs base, JSValueRegs value, AccessType accessType)
+ : JITByIdGenerator(codeBlock, codeOrigin, callSite, accessType, usedRegisters, base, value)
+ , m_isLengthAccess(propertyName == codeBlock->vm()->propertyNames->length.impl())
+{
+ RELEASE_ASSERT(base.payloadGPR() != value.tagGPR());
}
void JITGetByIdGenerator::generateFastPath(MacroAssembler& jit)
{
- generateFastPathChecks(jit, m_value.payloadGPR());
-
-#if USE(JSVALUE64)
- m_loadOrStore = jit.load64WithCompactAddressOffsetPatch(
- MacroAssembler::Address(m_value.payloadGPR(), 0), m_value.payloadGPR()).label();
-#else
- m_tagLoadOrStore = jit.load32WithCompactAddressOffsetPatch(
- MacroAssembler::Address(m_value.payloadGPR(), 0), m_value.tagGPR()).label();
- m_loadOrStore = jit.load32WithCompactAddressOffsetPatch(
- MacroAssembler::Address(m_value.payloadGPR(), 0), m_value.payloadGPR()).label();
-#endif
-
- m_done = jit.label();
+ generateFastCommon(jit, m_isLengthAccess ? InlineAccess::sizeForLengthAccess() : InlineAccess::sizeForPropertyAccess());
}
JITPutByIdGenerator::JITPutByIdGenerator(
- CodeBlock* codeBlock, CodeOrigin codeOrigin, const RegisterSet& usedRegisters,
- GPRReg callFrameRegister, JSValueRegs base, JSValueRegs value, GPRReg scratch,
- bool registersFlushed, ECMAMode ecmaMode, PutKind putKind)
+ CodeBlock* codeBlock, CodeOrigin codeOrigin, CallSiteIndex callSite, const RegisterSet& usedRegisters,
+ JSValueRegs base, JSValueRegs value, GPRReg scratch,
+ ECMAMode ecmaMode, PutKind putKind)
: JITByIdGenerator(
- codeBlock, codeOrigin, usedRegisters, callFrameRegister, base, value,
- registersFlushed)
- , m_scratch(scratch)
+ codeBlock, codeOrigin, callSite, AccessType::Put, usedRegisters, base, value)
, m_ecmaMode(ecmaMode)
, m_putKind(putKind)
{
@@ -144,19 +130,7 @@ JITPutByIdGenerator::JITPutByIdGenerator(
void JITPutByIdGenerator::generateFastPath(MacroAssembler& jit)
{
- generateFastPathChecks(jit, m_scratch);
-
-#if USE(JSVALUE64)
- m_loadOrStore = jit.store64WithAddressOffsetPatch(
- m_value.payloadGPR(), MacroAssembler::Address(m_scratch, 0)).label();
-#else
- m_tagLoadOrStore = jit.store32WithAddressOffsetPatch(
- m_value.tagGPR(), MacroAssembler::Address(m_scratch, 0)).label();
- m_loadOrStore = jit.store32WithAddressOffsetPatch(
- m_value.payloadGPR(), MacroAssembler::Address(m_scratch, 0)).label();
-#endif
-
- m_done = jit.label();
+ generateFastCommon(jit, InlineAccess::sizeForPropertyReplace());
}
V_JITOperation_ESsiJJI JITPutByIdGenerator::slowPathFunction()