Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 812446 - Optimize str[double], str.char[Code]At(double). r=nbp
Browse files Browse the repository at this point in the history
  • Loading branch information
evilpie committed Dec 12, 2012
1 parent 1ae1958 commit b278f50
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 4 additions & 2 deletions js/src/ion/MCallOptimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,8 @@ IonBuilder::inlineStrCharCodeAt(uint32_t argc, bool constructing)
return InliningStatus_NotInlined;
if (getInlineArgType(argc, 0) != MIRType_String)
return InliningStatus_NotInlined;
if (getInlineArgType(argc, 1) != MIRType_Int32)
MIRType argType = getInlineArgType(argc, 1);
if (argType != MIRType_Int32 && argType != MIRType_Double)
return InliningStatus_NotInlined;

MDefinitionVector argv;
Expand Down Expand Up @@ -768,7 +769,8 @@ IonBuilder::inlineStrCharAt(uint32_t argc, bool constructing)
return InliningStatus_NotInlined;
if (getInlineArgType(argc, 0) != MIRType_String)
return InliningStatus_NotInlined;
if (getInlineArgType(argc, 1) != MIRType_Int32)
MIRType argType = getInlineArgType(argc, 1);
if (argType != MIRType_Int32 && argType != MIRType_Double)
return InliningStatus_NotInlined;

MDefinitionVector argv;
Expand Down
5 changes: 3 additions & 2 deletions js/src/ion/TypeOracle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,15 @@ TypeInferenceOracle::elementReadIsTypedArray(JSScript *script, jsbytecode *pc, i
bool
TypeInferenceOracle::elementReadIsString(JSScript *script, jsbytecode *pc)
{
// Check for string[int32].
// Check for string[index].
StackTypeSet *value = script->analysis()->poppedTypes(pc, 1);
StackTypeSet *id = script->analysis()->poppedTypes(pc, 0);

if (value->getKnownTypeTag() != JSVAL_TYPE_STRING)
return false;

if (id->getKnownTypeTag() != JSVAL_TYPE_INT32)
JSValueType idType = id->getKnownTypeTag();
if (idType != JSVAL_TYPE_INT32 && idType != JSVAL_TYPE_DOUBLE)
return false;

// This function is used for jsop_getelem_string which should return
Expand Down
8 changes: 4 additions & 4 deletions js/src/jsinterpinlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -790,11 +790,11 @@ GetElementOperation(JSContext *cx, JSOp op, HandleValue lref, HandleValue rref,
AssertCanGC();
JS_ASSERT(op == JSOP_GETELEM || op == JSOP_CALLELEM);

if (lref.isString() && rref.isInt32()) {
uint32_t index;
if (lref.isString() && IsDefinitelyIndex(rref, &index)) {
JSString *str = lref.toString();
int32_t i = rref.toInt32();
if (size_t(i) < str->length()) {
str = cx->runtime->staticStrings.getUnitStringForElement(cx, str, size_t(i));
if (index < str->length()) {
str = cx->runtime->staticStrings.getUnitStringForElement(cx, str, index);
if (!str)
return false;
res.setString(str);
Expand Down

0 comments on commit b278f50

Please sign in to comment.