OLD | NEW |
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 6277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6288 __ push(ecx); | 6288 __ push(ecx); |
6289 GenerateCompareFlatAsciiStrings(masm, edx, eax, ecx, ebx, edi); | 6289 GenerateCompareFlatAsciiStrings(masm, edx, eax, ecx, ebx, edi); |
6290 | 6290 |
6291 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 6291 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
6292 // tagged as a small integer. | 6292 // tagged as a small integer. |
6293 __ bind(&runtime); | 6293 __ bind(&runtime); |
6294 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 6294 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
6295 } | 6295 } |
6296 | 6296 |
6297 | 6297 |
6298 void StringCharAtStub::Generate(MacroAssembler* masm) { | |
6299 // Expects two arguments (object, index) on the stack: | |
6300 | |
6301 // Stack frame on entry. | |
6302 // esp[0]: return address | |
6303 // esp[4]: index | |
6304 // esp[8]: object | |
6305 | |
6306 Register object = ebx; | |
6307 Register index = eax; | |
6308 Register scratch1 = ecx; | |
6309 Register scratch2 = edx; | |
6310 Register result = eax; | |
6311 | |
6312 __ pop(scratch1); // Return address. | |
6313 __ pop(index); | |
6314 __ pop(object); | |
6315 __ push(scratch1); | |
6316 | |
6317 Label need_conversion; | |
6318 Label index_out_of_range; | |
6319 Label done; | |
6320 StringCharAtGenerator generator(object, | |
6321 index, | |
6322 scratch1, | |
6323 scratch2, | |
6324 result, | |
6325 &need_conversion, | |
6326 &need_conversion, | |
6327 &index_out_of_range, | |
6328 STRING_INDEX_IS_NUMBER); | |
6329 generator.GenerateFast(masm); | |
6330 __ jmp(&done); | |
6331 | |
6332 __ bind(&index_out_of_range); | |
6333 // When the index is out of range, the spec requires us to return | |
6334 // the empty string. | |
6335 __ Set(result, Immediate(Factory::empty_string())); | |
6336 __ jmp(&done); | |
6337 | |
6338 __ bind(&need_conversion); | |
6339 // Move smi zero into the result register, which will trigger | |
6340 // conversion. | |
6341 __ Set(result, Immediate(Smi::FromInt(0))); | |
6342 __ jmp(&done); | |
6343 | |
6344 StubRuntimeCallHelper call_helper; | |
6345 generator.GenerateSlow(masm, call_helper); | |
6346 | |
6347 __ bind(&done); | |
6348 __ ret(0); | |
6349 } | |
6350 | |
6351 void ICCompareStub::GenerateSmis(MacroAssembler* masm) { | 6298 void ICCompareStub::GenerateSmis(MacroAssembler* masm) { |
6352 ASSERT(state_ == CompareIC::SMIS); | 6299 ASSERT(state_ == CompareIC::SMIS); |
6353 NearLabel miss; | 6300 NearLabel miss; |
6354 __ mov(ecx, Operand(edx)); | 6301 __ mov(ecx, Operand(edx)); |
6355 __ or_(ecx, Operand(eax)); | 6302 __ or_(ecx, Operand(eax)); |
6356 __ test(ecx, Immediate(kSmiTagMask)); | 6303 __ test(ecx, Immediate(kSmiTagMask)); |
6357 __ j(not_zero, &miss, not_taken); | 6304 __ j(not_zero, &miss, not_taken); |
6358 | 6305 |
6359 if (GetCondition() == equal) { | 6306 if (GetCondition() == equal) { |
6360 // For equality we do not care about the sign of the result. | 6307 // For equality we do not care about the sign of the result. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6478 // Do a tail call to the rewritten stub. | 6425 // Do a tail call to the rewritten stub. |
6479 __ jmp(Operand(edi)); | 6426 __ jmp(Operand(edi)); |
6480 } | 6427 } |
6481 | 6428 |
6482 | 6429 |
6483 #undef __ | 6430 #undef __ |
6484 | 6431 |
6485 } } // namespace v8::internal | 6432 } } // namespace v8::internal |
6486 | 6433 |
6487 #endif // V8_TARGET_ARCH_IA32 | 6434 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |