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

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

Issue 8569008: Port r10023 to x64 (Add pointer cache field to external string). (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 4096 matching lines...) Expand 10 before | Expand all | Expand 10 after
4107 __ j(not_zero, receiver_not_string_); 4107 __ j(not_zero, receiver_not_string_);
4108 4108
4109 // If the index is non-smi trigger the non-smi case. 4109 // If the index is non-smi trigger the non-smi case.
4110 __ JumpIfNotSmi(index_, &index_not_smi_); 4110 __ JumpIfNotSmi(index_, &index_not_smi_);
4111 __ bind(&got_smi_index_); 4111 __ bind(&got_smi_index_);
4112 4112
4113 // Check for index out of range. 4113 // Check for index out of range.
4114 __ SmiCompare(index_, FieldOperand(object_, String::kLengthOffset)); 4114 __ SmiCompare(index_, FieldOperand(object_, String::kLengthOffset));
4115 __ j(above_equal, index_out_of_range_); 4115 __ j(above_equal, index_out_of_range_);
4116 4116
4117 // We need special handling for non-flat strings. 4117 __ SmiToInteger32(index_, index_);
4118 STATIC_ASSERT(kSeqStringTag == 0);
4119 __ testb(result_, Immediate(kStringRepresentationMask));
4120 __ j(zero, &flat_string);
4121 4118
4122 // Handle non-flat strings. 4119 StringCharLoadGenerator::Generate(
4123 __ and_(result_, Immediate(kStringRepresentationMask)); 4120 masm, object_, index_, result_, &call_runtime_);
4124 STATIC_ASSERT(kConsStringTag < kExternalStringTag);
4125 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag);
4126 __ cmpb(result_, Immediate(kExternalStringTag));
4127 __ j(greater, &sliced_string);
4128 __ j(equal, &call_runtime_);
4129 4121
4130 // ConsString.
4131 // Check whether the right hand side is the empty string (i.e. if
4132 // this is really a flat string in a cons string). If that is not
4133 // the case we would rather go to the runtime system now to flatten
4134 // the string.
4135 Label assure_seq_string;
4136 __ CompareRoot(FieldOperand(object_, ConsString::kSecondOffset),
4137 Heap::kEmptyStringRootIndex);
4138 __ j(not_equal, &call_runtime_);
4139 // Get the first of the two parts.
4140 __ movq(object_, FieldOperand(object_, ConsString::kFirstOffset));
4141 __ jmp(&assure_seq_string, Label::kNear);
4142
4143 // SlicedString, unpack and add offset.
4144 __ bind(&sliced_string);
4145 __ addq(index_, FieldOperand(object_, SlicedString::kOffsetOffset));
4146 __ movq(object_, FieldOperand(object_, SlicedString::kParentOffset));
4147
4148 // Assure that we are dealing with a sequential string. Go to runtime if not.
4149 // Note that if the original string is a cons or slice with an external
4150 // string as underlying string, we pass that unpacked underlying string with
4151 // the adjusted index to the runtime function.
4152 __ bind(&assure_seq_string);
4153 __ movq(result_, FieldOperand(object_, HeapObject::kMapOffset));
4154 __ movzxbl(result_, FieldOperand(result_, Map::kInstanceTypeOffset));
4155 STATIC_ASSERT(kSeqStringTag == 0);
4156 __ testb(result_, Immediate(kStringRepresentationMask));
4157 __ j(not_zero, &call_runtime_);
4158
4159 // Check for 1-byte or 2-byte string.
4160 __ bind(&flat_string);
4161 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0);
4162 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
4163 __ SmiToInteger32(index_, index_);
4164 __ testb(result_, Immediate(kStringEncodingMask));
4165 __ j(not_zero, &ascii_string);
4166
4167 // 2-byte string.
4168 // Load the 2-byte character code into the result register.
4169 __ movzxwl(result_, FieldOperand(object_,
4170 index_, times_2,
4171 SeqTwoByteString::kHeaderSize));
4172 __ jmp(&got_char_code);
4173
4174 // ASCII string.
4175 // Load the byte into the result register.
4176 __ bind(&ascii_string);
4177 __ movzxbl(result_, FieldOperand(object_,
4178 index_, times_1,
4179 SeqAsciiString::kHeaderSize));
4180 __ bind(&got_char_code);
4181 __ Integer32ToSmi(result_, result_); 4122 __ Integer32ToSmi(result_, result_);
4182 __ bind(&exit_); 4123 __ bind(&exit_);
4183 } 4124 }
4184 4125
4185 4126
4186 void StringCharCodeAtGenerator::GenerateSlow( 4127 void StringCharCodeAtGenerator::GenerateSlow(
4187 MacroAssembler* masm, 4128 MacroAssembler* masm,
4188 const RuntimeCallHelper& call_helper) { 4129 const RuntimeCallHelper& call_helper) {
4189 __ Abort("Unexpected fallthrough to CharCodeAt slow case"); 4130 __ Abort("Unexpected fallthrough to CharCodeAt slow case");
4190 4131
(...skipping 29 matching lines...) Expand all
4220 __ JumpIfNotSmi(index_, index_out_of_range_); 4161 __ JumpIfNotSmi(index_, index_out_of_range_);
4221 // Otherwise, return to the fast path. 4162 // Otherwise, return to the fast path.
4222 __ jmp(&got_smi_index_); 4163 __ jmp(&got_smi_index_);
4223 4164
4224 // Call runtime. We get here when the receiver is a string and the 4165 // Call runtime. We get here when the receiver is a string and the
4225 // index is a number, but the code of getting the actual character 4166 // index is a number, but the code of getting the actual character
4226 // is too complex (e.g., when the string needs to be flattened). 4167 // is too complex (e.g., when the string needs to be flattened).
4227 __ bind(&call_runtime_); 4168 __ bind(&call_runtime_);
4228 call_helper.BeforeCall(masm); 4169 call_helper.BeforeCall(masm);
4229 __ push(object_); 4170 __ push(object_);
4171 __ Integer32ToSmi(index_, index_);
4230 __ push(index_); 4172 __ push(index_);
4231 __ CallRuntime(Runtime::kStringCharCodeAt, 2); 4173 __ CallRuntime(Runtime::kStringCharCodeAt, 2);
4232 if (!result_.is(rax)) { 4174 if (!result_.is(rax)) {
4233 __ movq(result_, rax); 4175 __ movq(result_, rax);
4234 } 4176 }
4235 call_helper.AfterCall(masm); 4177 call_helper.AfterCall(masm);
4236 __ jmp(&exit_); 4178 __ jmp(&exit_);
4237 4179
4238 __ Abort("Unexpected fallthrough from CharCodeAt slow case"); 4180 __ Abort("Unexpected fallthrough from CharCodeAt slow case");
4239 } 4181 }
(...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after
6061 xmm0, 6003 xmm0,
6062 &slow_elements); 6004 &slow_elements);
6063 __ ret(0); 6005 __ ret(0);
6064 } 6006 }
6065 6007
6066 #undef __ 6008 #undef __
6067 6009
6068 } } // namespace v8::internal 6010 } } // namespace v8::internal
6069 6011
6070 #endif // V8_TARGET_ARCH_X64 6012 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698