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

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

Issue 8662009: Porting r10023 and r10054 to x64 (pointer cache for external strings). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month 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
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 4139 matching lines...) Expand 10 before | Expand all | Expand 10 after
4150 __ j(not_zero, receiver_not_string_); 4150 __ j(not_zero, receiver_not_string_);
4151 4151
4152 // If the index is non-smi trigger the non-smi case. 4152 // If the index is non-smi trigger the non-smi case.
4153 __ JumpIfNotSmi(index_, &index_not_smi_); 4153 __ JumpIfNotSmi(index_, &index_not_smi_);
4154 __ bind(&got_smi_index_); 4154 __ bind(&got_smi_index_);
4155 4155
4156 // Check for index out of range. 4156 // Check for index out of range.
4157 __ SmiCompare(index_, FieldOperand(object_, String::kLengthOffset)); 4157 __ SmiCompare(index_, FieldOperand(object_, String::kLengthOffset));
4158 __ j(above_equal, index_out_of_range_); 4158 __ j(above_equal, index_out_of_range_);
4159 4159
4160 // We need special handling for non-flat strings. 4160 __ SmiToInteger32(index_, index_);
4161 STATIC_ASSERT(kSeqStringTag == 0);
4162 __ testb(result_, Immediate(kStringRepresentationMask));
4163 __ j(zero, &flat_string);
4164 4161
4165 // Handle non-flat strings. 4162 StringCharLoadGenerator::Generate(
4166 __ and_(result_, Immediate(kStringRepresentationMask)); 4163 masm, object_, index_, result_, &call_runtime_);
4167 STATIC_ASSERT(kConsStringTag < kExternalStringTag);
4168 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag);
4169 __ cmpb(result_, Immediate(kExternalStringTag));
4170 __ j(greater, &sliced_string);
4171 __ j(equal, &call_runtime_);
4172 4164
4173 // ConsString.
4174 // Check whether the right hand side is the empty string (i.e. if
4175 // this is really a flat string in a cons string). If that is not
4176 // the case we would rather go to the runtime system now to flatten
4177 // the string.
4178 Label assure_seq_string;
4179 __ CompareRoot(FieldOperand(object_, ConsString::kSecondOffset),
4180 Heap::kEmptyStringRootIndex);
4181 __ j(not_equal, &call_runtime_);
4182 // Get the first of the two parts.
4183 __ movq(object_, FieldOperand(object_, ConsString::kFirstOffset));
4184 __ jmp(&assure_seq_string, Label::kNear);
4185
4186 // SlicedString, unpack and add offset.
4187 __ bind(&sliced_string);
4188 __ addq(index_, FieldOperand(object_, SlicedString::kOffsetOffset));
4189 __ movq(object_, FieldOperand(object_, SlicedString::kParentOffset));
4190
4191 // Assure that we are dealing with a sequential string. Go to runtime if not.
4192 // Note that if the original string is a cons or slice with an external
4193 // string as underlying string, we pass that unpacked underlying string with
4194 // the adjusted index to the runtime function.
4195 __ bind(&assure_seq_string);
4196 __ movq(result_, FieldOperand(object_, HeapObject::kMapOffset));
4197 __ movzxbl(result_, FieldOperand(result_, Map::kInstanceTypeOffset));
4198 STATIC_ASSERT(kSeqStringTag == 0);
4199 __ testb(result_, Immediate(kStringRepresentationMask));
4200 __ j(not_zero, &call_runtime_);
4201
4202 // Check for 1-byte or 2-byte string.
4203 __ bind(&flat_string);
4204 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0);
4205 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
4206 __ SmiToInteger32(index_, index_);
4207 __ testb(result_, Immediate(kStringEncodingMask));
4208 __ j(not_zero, &ascii_string);
4209
4210 // 2-byte string.
4211 // Load the 2-byte character code into the result register.
4212 __ movzxwl(result_, FieldOperand(object_,
4213 index_, times_2,
4214 SeqTwoByteString::kHeaderSize));
4215 __ jmp(&got_char_code);
4216
4217 // ASCII string.
4218 // Load the byte into the result register.
4219 __ bind(&ascii_string);
4220 __ movzxbl(result_, FieldOperand(object_,
4221 index_, times_1,
4222 SeqAsciiString::kHeaderSize));
4223 __ bind(&got_char_code);
4224 __ Integer32ToSmi(result_, result_); 4165 __ Integer32ToSmi(result_, result_);
4225 __ bind(&exit_); 4166 __ bind(&exit_);
4226 } 4167 }
4227 4168
4228 4169
4229 void StringCharCodeAtGenerator::GenerateSlow( 4170 void StringCharCodeAtGenerator::GenerateSlow(
4230 MacroAssembler* masm, 4171 MacroAssembler* masm,
4231 const RuntimeCallHelper& call_helper) { 4172 const RuntimeCallHelper& call_helper) {
4232 __ Abort("Unexpected fallthrough to CharCodeAt slow case"); 4173 __ Abort("Unexpected fallthrough to CharCodeAt slow case");
4233 4174
(...skipping 29 matching lines...) Expand all
4263 __ JumpIfNotSmi(index_, index_out_of_range_); 4204 __ JumpIfNotSmi(index_, index_out_of_range_);
4264 // Otherwise, return to the fast path. 4205 // Otherwise, return to the fast path.
4265 __ jmp(&got_smi_index_); 4206 __ jmp(&got_smi_index_);
4266 4207
4267 // Call runtime. We get here when the receiver is a string and the 4208 // Call runtime. We get here when the receiver is a string and the
4268 // index is a number, but the code of getting the actual character 4209 // index is a number, but the code of getting the actual character
4269 // is too complex (e.g., when the string needs to be flattened). 4210 // is too complex (e.g., when the string needs to be flattened).
4270 __ bind(&call_runtime_); 4211 __ bind(&call_runtime_);
4271 call_helper.BeforeCall(masm); 4212 call_helper.BeforeCall(masm);
4272 __ push(object_); 4213 __ push(object_);
4214 __ Integer32ToSmi(index_, index_);
4273 __ push(index_); 4215 __ push(index_);
4274 __ CallRuntime(Runtime::kStringCharCodeAt, 2); 4216 __ CallRuntime(Runtime::kStringCharCodeAt, 2);
4275 if (!result_.is(rax)) { 4217 if (!result_.is(rax)) {
4276 __ movq(result_, rax); 4218 __ movq(result_, rax);
4277 } 4219 }
4278 call_helper.AfterCall(masm); 4220 call_helper.AfterCall(masm);
4279 __ jmp(&exit_); 4221 __ jmp(&exit_);
4280 4222
4281 __ Abort("Unexpected fallthrough from CharCodeAt slow case"); 4223 __ Abort("Unexpected fallthrough from CharCodeAt slow case");
4282 } 4224 }
(...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after
6104 xmm0, 6046 xmm0,
6105 &slow_elements); 6047 &slow_elements);
6106 __ ret(0); 6048 __ ret(0);
6107 } 6049 }
6108 6050
6109 #undef __ 6051 #undef __
6110 6052
6111 } } // namespace v8::internal 6053 } } // namespace v8::internal
6112 6054
6113 #endif // V8_TARGET_ARCH_X64 6055 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | src/x64/codegen-x64.h » ('j') | src/x64/codegen-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698