Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: src/arm/code-stubs-arm.cc

Issue 8682010: Porting r10023 and r10054 to arm (pointer cache for external strings). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Adding external string handling. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/arm/codegen-arm.h » ('j') | src/arm/codegen-arm.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5048 matching lines...) Expand 10 before | Expand all | Expand 10 after
5059 5059
5060 // If the index is non-smi trigger the non-smi case. 5060 // If the index is non-smi trigger the non-smi case.
5061 __ JumpIfNotSmi(index_, &index_not_smi_); 5061 __ JumpIfNotSmi(index_, &index_not_smi_);
5062 __ bind(&got_smi_index_); 5062 __ bind(&got_smi_index_);
5063 5063
5064 // Check for index out of range. 5064 // Check for index out of range.
5065 __ ldr(ip, FieldMemOperand(object_, String::kLengthOffset)); 5065 __ ldr(ip, FieldMemOperand(object_, String::kLengthOffset));
5066 __ cmp(ip, Operand(index_)); 5066 __ cmp(ip, Operand(index_));
5067 __ b(ls, index_out_of_range_); 5067 __ b(ls, index_out_of_range_);
5068 5068
5069 // We need special handling for non-flat strings. 5069 __ mov(index_, Operand(index_, ASR, kSmiTagSize));
5070 STATIC_ASSERT(kSeqStringTag == 0);
5071 __ tst(result_, Operand(kStringRepresentationMask));
5072 __ b(eq, &flat_string);
5073 5070
5074 // Handle non-flat strings. 5071 StringCharLoadGenerator::Generate(
5075 __ and_(result_, result_, Operand(kStringRepresentationMask)); 5072 masm, object_, index_, result_, &call_runtime_);
Rico 2011/11/24 06:55:15 move masm up and put parameters on individual line
Yang 2011/11/24 11:15:11 Done.
5076 STATIC_ASSERT(kConsStringTag < kExternalStringTag);
5077 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag);
5078 __ cmp(result_, Operand(kExternalStringTag));
5079 __ b(gt, &sliced_string);
5080 __ b(eq, &call_runtime_);
5081 5073
5082 // ConsString.
5083 // Check whether the right hand side is the empty string (i.e. if
5084 // this is really a flat string in a cons string). If that is not
5085 // the case we would rather go to the runtime system now to flatten
5086 // the string.
5087 Label assure_seq_string;
5088 __ ldr(result_, FieldMemOperand(object_, ConsString::kSecondOffset));
5089 __ LoadRoot(ip, Heap::kEmptyStringRootIndex);
5090 __ cmp(result_, Operand(ip));
5091 __ b(ne, &call_runtime_);
5092 // Get the first of the two parts.
5093 __ ldr(object_, FieldMemOperand(object_, ConsString::kFirstOffset));
5094 __ jmp(&assure_seq_string);
5095
5096 // SlicedString, unpack and add offset.
5097 __ bind(&sliced_string);
5098 __ ldr(result_, FieldMemOperand(object_, SlicedString::kOffsetOffset));
5099 __ add(index_, index_, result_);
5100 __ ldr(object_, FieldMemOperand(object_, SlicedString::kParentOffset));
5101
5102 // Assure that we are dealing with a sequential string. Go to runtime if not.
5103 __ bind(&assure_seq_string);
5104 __ ldr(result_, FieldMemOperand(object_, HeapObject::kMapOffset));
5105 __ ldrb(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset));
5106 // Check that parent is not an external string. Go to runtime otherwise.
5107 // Note that if the original string is a cons or slice with an external
5108 // string as underlying string, we pass that unpacked underlying string with
5109 // the adjusted index to the runtime function.
5110 STATIC_ASSERT(kSeqStringTag == 0);
5111 __ tst(result_, Operand(kStringRepresentationMask));
5112 __ b(ne, &call_runtime_);
5113
5114 // Check for 1-byte or 2-byte string.
5115 __ bind(&flat_string);
5116 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0);
5117 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
5118 __ tst(result_, Operand(kStringEncodingMask));
5119 __ b(ne, &ascii_string);
5120
5121 // 2-byte string.
5122 // Load the 2-byte character code into the result register. We can
5123 // add without shifting since the smi tag size is the log2 of the
5124 // number of bytes in a two-byte character.
5125 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1 && kSmiShiftSize == 0);
5126 __ add(index_, object_, Operand(index_));
5127 __ ldrh(result_, FieldMemOperand(index_, SeqTwoByteString::kHeaderSize));
5128 __ jmp(&got_char_code);
5129
5130 // ASCII string.
5131 // Load the byte into the result register.
5132 __ bind(&ascii_string);
5133 __ add(index_, object_, Operand(index_, LSR, kSmiTagSize));
5134 __ ldrb(result_, FieldMemOperand(index_, SeqAsciiString::kHeaderSize));
5135
5136 __ bind(&got_char_code);
5137 __ mov(result_, Operand(result_, LSL, kSmiTagSize)); 5074 __ mov(result_, Operand(result_, LSL, kSmiTagSize));
5138 __ bind(&exit_); 5075 __ bind(&exit_);
5139 } 5076 }
5140 5077
5141 5078
5142 void StringCharCodeAtGenerator::GenerateSlow( 5079 void StringCharCodeAtGenerator::GenerateSlow(
5143 MacroAssembler* masm, 5080 MacroAssembler* masm,
5144 const RuntimeCallHelper& call_helper) { 5081 const RuntimeCallHelper& call_helper) {
5145 __ Abort("Unexpected fallthrough to CharCodeAt slow case"); 5082 __ Abort("Unexpected fallthrough to CharCodeAt slow case");
5146 5083
(...skipping 26 matching lines...) Expand all
5173 // If index is still not a smi, it must be out of range. 5110 // If index is still not a smi, it must be out of range.
5174 __ JumpIfNotSmi(index_, index_out_of_range_); 5111 __ JumpIfNotSmi(index_, index_out_of_range_);
5175 // Otherwise, return to the fast path. 5112 // Otherwise, return to the fast path.
5176 __ jmp(&got_smi_index_); 5113 __ jmp(&got_smi_index_);
5177 5114
5178 // Call runtime. We get here when the receiver is a string and the 5115 // Call runtime. We get here when the receiver is a string and the
5179 // index is a number, but the code of getting the actual character 5116 // index is a number, but the code of getting the actual character
5180 // is too complex (e.g., when the string needs to be flattened). 5117 // is too complex (e.g., when the string needs to be flattened).
5181 __ bind(&call_runtime_); 5118 __ bind(&call_runtime_);
5182 call_helper.BeforeCall(masm); 5119 call_helper.BeforeCall(masm);
5120 __ mov(index_, Operand(index_, LSL, kSmiTagSize));
5183 __ Push(object_, index_); 5121 __ Push(object_, index_);
5184 __ CallRuntime(Runtime::kStringCharCodeAt, 2); 5122 __ CallRuntime(Runtime::kStringCharCodeAt, 2);
5185 __ Move(result_, r0); 5123 __ Move(result_, r0);
5186 call_helper.AfterCall(masm); 5124 call_helper.AfterCall(masm);
5187 __ jmp(&exit_); 5125 __ jmp(&exit_);
5188 5126
5189 __ Abort("Unexpected fallthrough from CharCodeAt slow case"); 5127 __ Abort("Unexpected fallthrough from CharCodeAt slow case");
5190 } 5128 }
5191 5129
5192 5130
(...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after
7179 __ StoreNumberToDoubleElements(r0, r3, r1, r5, r6, r7, r9, r10, 7117 __ StoreNumberToDoubleElements(r0, r3, r1, r5, r6, r7, r9, r10,
7180 &slow_elements); 7118 &slow_elements);
7181 __ Ret(); 7119 __ Ret();
7182 } 7120 }
7183 7121
7184 #undef __ 7122 #undef __
7185 7123
7186 } } // namespace v8::internal 7124 } } // namespace v8::internal
7187 7125
7188 #endif // V8_TARGET_ARCH_ARM 7126 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/codegen-arm.h » ('j') | src/arm/codegen-arm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698