Commit 45f1eb1e authored by oliver@apple.com's avatar oliver@apple.com

Improve performance of string indexing

Reviewed by Geoff Garen

Add a cti_get_by_val_string function to specialise indexing into a string object.
This gives us a slight performance win on a number of string tests.


git-svn-id: svn://svn.chromium.org/blink/trunk@42976 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent f6669c1e
...@@ -4,6 +4,20 @@ ...@@ -4,6 +4,20 @@
* GNUmakefile.am: * GNUmakefile.am:
2009-04-28 Oliver Hunt <oliver@apple.com>
Reviewed by Geoff Garen.
Improve performance of string indexing
Add a cti_get_by_val_string function to specialise indexing into a string object.
This gives us a slight performance win on a number of string tests.
* jit/JITStubs.cpp:
(JSC::JITStubs::cti_op_get_by_val):
(JSC::JITStubs::cti_op_get_by_val_string):
* jit/JITStubs.h:
2009-04-28 Oliver Hunt <oliver@apple.com> 2009-04-28 Oliver Hunt <oliver@apple.com>
Reviewed by Geoff Garen. Reviewed by Geoff Garen.
...@@ -1126,9 +1126,11 @@ JSValueEncodedAsPointer* JITStubs::cti_op_get_by_val(STUB_ARGS) ...@@ -1126,9 +1126,11 @@ JSValueEncodedAsPointer* JITStubs::cti_op_get_by_val(STUB_ARGS)
result = jsArray->getIndex(i); result = jsArray->getIndex(i);
else else
result = jsArray->JSArray::get(callFrame, i); result = jsArray->JSArray::get(callFrame, i);
} else if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i)) } else if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i)) {
// All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_get_by_val_string));
result = asString(baseValue)->getIndex(ARG_globalData, i); result = asString(baseValue)->getIndex(ARG_globalData, i);
else if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) { } else if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
// All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks. // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_get_by_val_byte_array)); ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_get_by_val_byte_array));
return JSValuePtr::encode(asByteArray(baseValue)->getIndex(callFrame, i)); return JSValuePtr::encode(asByteArray(baseValue)->getIndex(callFrame, i));
...@@ -1142,6 +1144,37 @@ JSValueEncodedAsPointer* JITStubs::cti_op_get_by_val(STUB_ARGS) ...@@ -1142,6 +1144,37 @@ JSValueEncodedAsPointer* JITStubs::cti_op_get_by_val(STUB_ARGS)
CHECK_FOR_EXCEPTION_AT_END(); CHECK_FOR_EXCEPTION_AT_END();
return JSValuePtr::encode(result); return JSValuePtr::encode(result);
} }
JSValueEncodedAsPointer* JITStubs::cti_op_get_by_val_string(STUB_ARGS)
{
BEGIN_STUB_FUNCTION();
CallFrame* callFrame = ARG_callFrame;
JSGlobalData* globalData = ARG_globalData;
JSValuePtr baseValue = ARG_src1;
JSValuePtr subscript = ARG_src2;
JSValuePtr result;
if (LIKELY(subscript.isUInt32Fast())) {
uint32_t i = subscript.getUInt32Fast();
if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i))
result = asString(baseValue)->getIndex(ARG_globalData, i);
else {
result = baseValue.get(callFrame, i);
if (!isJSString(globalData, baseValue))
ctiPatchCallByReturnAddress(STUB_RETURN_ADDRESS, reinterpret_cast<void*>(cti_op_get_by_val));
}
} else {
Identifier property(callFrame, subscript.toString(callFrame));
result = baseValue.get(callFrame, property);
}
CHECK_FOR_EXCEPTION_AT_END();
return JSValuePtr::encode(result);
}
JSValueEncodedAsPointer* JITStubs::cti_op_get_by_val_byte_array(STUB_ARGS) JSValueEncodedAsPointer* JITStubs::cti_op_get_by_val_byte_array(STUB_ARGS)
{ {
......
...@@ -128,6 +128,7 @@ namespace JSC { ...@@ -128,6 +128,7 @@ namespace JSC {
static JSValueEncodedAsPointer* JIT_STUB cti_op_get_by_id_string_fail(STUB_ARGS); static JSValueEncodedAsPointer* JIT_STUB cti_op_get_by_id_string_fail(STUB_ARGS);
static JSValueEncodedAsPointer* JIT_STUB cti_op_get_by_val(STUB_ARGS); static JSValueEncodedAsPointer* JIT_STUB cti_op_get_by_val(STUB_ARGS);
static JSValueEncodedAsPointer* JIT_STUB cti_op_get_by_val_byte_array(STUB_ARGS); static JSValueEncodedAsPointer* JIT_STUB cti_op_get_by_val_byte_array(STUB_ARGS);
static JSValueEncodedAsPointer* JIT_STUB cti_op_get_by_val_string(STUB_ARGS);
static JSValueEncodedAsPointer* JIT_STUB cti_op_in(STUB_ARGS); static JSValueEncodedAsPointer* JIT_STUB cti_op_in(STUB_ARGS);
static JSValueEncodedAsPointer* JIT_STUB cti_op_instanceof(STUB_ARGS); static JSValueEncodedAsPointer* JIT_STUB cti_op_instanceof(STUB_ARGS);
static JSValueEncodedAsPointer* JIT_STUB cti_op_is_boolean(STUB_ARGS); static JSValueEncodedAsPointer* JIT_STUB cti_op_is_boolean(STUB_ARGS);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment