Commit 26be3091 authored by vitalyr@chromium.org's avatar vitalyr@chromium.org

Fix generated code for String.charCodeAt.

Review URL: http://codereview.chromium.org/2468001

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4770 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cdc09c50
...@@ -3177,7 +3177,7 @@ class Internals { ...@@ -3177,7 +3177,7 @@ class Internals {
static const int kProxyProxyOffset = sizeof(void*); static const int kProxyProxyOffset = sizeof(void*);
static const int kJSObjectHeaderSize = 3 * sizeof(void*); static const int kJSObjectHeaderSize = 3 * sizeof(void*);
static const int kFullStringRepresentationMask = 0x07; static const int kFullStringRepresentationMask = 0x07;
static const int kExternalTwoByteRepresentationTag = 0x03; static const int kExternalTwoByteRepresentationTag = 0x02;
// These constants are compiler dependent so their values must be // These constants are compiler dependent so their values must be
// defined within the implementation. // defined within the implementation.
......
...@@ -9283,7 +9283,7 @@ void StringCharCodeAtGenerator::GenerateSlow( ...@@ -9283,7 +9283,7 @@ void StringCharCodeAtGenerator::GenerateSlow(
__ CheckMap(index_, scratch_, __ CheckMap(index_, scratch_,
Factory::heap_number_map(), index_not_number_, true); Factory::heap_number_map(), index_not_number_, true);
call_helper.BeforeCall(masm); call_helper.BeforeCall(masm);
__ Push(object_, index_, result_); __ Push(object_, index_);
__ push(index_); // Consumed by runtime conversion function. __ push(index_); // Consumed by runtime conversion function.
if (index_flags_ == STRING_INDEX_IS_NUMBER) { if (index_flags_ == STRING_INDEX_IS_NUMBER) {
__ CallRuntime(Runtime::kNumberToIntegerMapMinusZero, 1); __ CallRuntime(Runtime::kNumberToIntegerMapMinusZero, 1);
...@@ -9297,9 +9297,11 @@ void StringCharCodeAtGenerator::GenerateSlow( ...@@ -9297,9 +9297,11 @@ void StringCharCodeAtGenerator::GenerateSlow(
// have a chance to overwrite it. // have a chance to overwrite it.
__ mov(scratch_, r0); __ mov(scratch_, r0);
} }
__ pop(result_);
__ pop(index_); __ pop(index_);
__ pop(object_); __ pop(object_);
// Reload the instance type.
__ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset));
__ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset));
call_helper.AfterCall(masm); call_helper.AfterCall(masm);
// If index is still not a smi, it must be out of range. // If index is still not a smi, it must be out of range.
__ BranchOnNotSmi(scratch_, index_out_of_range_); __ BranchOnNotSmi(scratch_, index_out_of_range_);
......
...@@ -12638,7 +12638,6 @@ void StringCharCodeAtGenerator::GenerateSlow( ...@@ -12638,7 +12638,6 @@ void StringCharCodeAtGenerator::GenerateSlow(
call_helper.BeforeCall(masm); call_helper.BeforeCall(masm);
__ push(object_); __ push(object_);
__ push(index_); __ push(index_);
__ push(result_);
__ push(index_); // Consumed by runtime conversion function. __ push(index_); // Consumed by runtime conversion function.
if (index_flags_ == STRING_INDEX_IS_NUMBER) { if (index_flags_ == STRING_INDEX_IS_NUMBER) {
__ CallRuntime(Runtime::kNumberToIntegerMapMinusZero, 1); __ CallRuntime(Runtime::kNumberToIntegerMapMinusZero, 1);
...@@ -12652,9 +12651,11 @@ void StringCharCodeAtGenerator::GenerateSlow( ...@@ -12652,9 +12651,11 @@ void StringCharCodeAtGenerator::GenerateSlow(
// have a chance to overwrite it. // have a chance to overwrite it.
__ mov(scratch_, eax); __ mov(scratch_, eax);
} }
__ pop(result_);
__ pop(index_); __ pop(index_);
__ pop(object_); __ pop(object_);
// Reload the instance type.
__ mov(result_, FieldOperand(object_, HeapObject::kMapOffset));
__ movzx_b(result_, FieldOperand(result_, Map::kInstanceTypeOffset));
call_helper.AfterCall(masm); call_helper.AfterCall(masm);
// If index is still not a smi, it must be out of range. // If index is still not a smi, it must be out of range.
ASSERT(kSmiTag == 0); ASSERT(kSmiTag == 0);
......
...@@ -408,7 +408,7 @@ const uint32_t kStringRepresentationMask = 0x03; ...@@ -408,7 +408,7 @@ const uint32_t kStringRepresentationMask = 0x03;
enum StringRepresentationTag { enum StringRepresentationTag {
kSeqStringTag = 0x0, kSeqStringTag = 0x0,
kConsStringTag = 0x1, kConsStringTag = 0x1,
kExternalStringTag = 0x3 kExternalStringTag = 0x2
}; };
const uint32_t kIsConsStringMask = 0x1; const uint32_t kIsConsStringMask = 0x1;
......
...@@ -10922,7 +10922,6 @@ void StringCharCodeAtGenerator::GenerateSlow( ...@@ -10922,7 +10922,6 @@ void StringCharCodeAtGenerator::GenerateSlow(
call_helper.BeforeCall(masm); call_helper.BeforeCall(masm);
__ push(object_); __ push(object_);
__ push(index_); __ push(index_);
__ push(result_);
__ push(index_); // Consumed by runtime conversion function. __ push(index_); // Consumed by runtime conversion function.
if (index_flags_ == STRING_INDEX_IS_NUMBER) { if (index_flags_ == STRING_INDEX_IS_NUMBER) {
__ CallRuntime(Runtime::kNumberToIntegerMapMinusZero, 1); __ CallRuntime(Runtime::kNumberToIntegerMapMinusZero, 1);
...@@ -10936,9 +10935,11 @@ void StringCharCodeAtGenerator::GenerateSlow( ...@@ -10936,9 +10935,11 @@ void StringCharCodeAtGenerator::GenerateSlow(
// have a chance to overwrite it. // have a chance to overwrite it.
__ movq(scratch_, rax); __ movq(scratch_, rax);
} }
__ pop(result_);
__ pop(index_); __ pop(index_);
__ pop(object_); __ pop(object_);
// Reload the instance type.
__ movq(result_, FieldOperand(object_, HeapObject::kMapOffset));
__ movzxbl(result_, FieldOperand(result_, Map::kInstanceTypeOffset));
call_helper.AfterCall(masm); call_helper.AfterCall(masm);
// If index is still not a smi, it must be out of range. // If index is still not a smi, it must be out of range.
__ JumpIfNotSmi(scratch_, index_out_of_range_); __ JumpIfNotSmi(scratch_, index_out_of_range_);
......
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