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

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

Issue 2365413002: Revert of [stubs] Port SubStringStub to TurboFan (Closed)
Patch Set: Created 4 years, 2 months 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
« no previous file with comments | « src/ppc/code-stubs-ppc.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_S390 5 #if V8_TARGET_ARCH_S390
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/api-arguments.h" 8 #include "src/api-arguments.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 __ bind(&byte_loop); 2195 __ bind(&byte_loop);
2196 __ LoadlB(scratch, MemOperand(src)); 2196 __ LoadlB(scratch, MemOperand(src));
2197 __ la(src, MemOperand(src, 1)); 2197 __ la(src, MemOperand(src, 1));
2198 __ stc(scratch, MemOperand(dest)); 2198 __ stc(scratch, MemOperand(dest));
2199 __ la(dest, MemOperand(dest, 1)); 2199 __ la(dest, MemOperand(dest, 1));
2200 __ BranchOnCount(count, &byte_loop); 2200 __ BranchOnCount(count, &byte_loop);
2201 2201
2202 __ bind(&done); 2202 __ bind(&done);
2203 } 2203 }
2204 2204
2205 void SubStringStub::Generate(MacroAssembler* masm) {
2206 Label runtime;
2207
2208 // Stack frame on entry.
2209 // lr: return address
2210 // sp[0]: to
2211 // sp[4]: from
2212 // sp[8]: string
2213
2214 // This stub is called from the native-call %_SubString(...), so
2215 // nothing can be assumed about the arguments. It is tested that:
2216 // "string" is a sequential string,
2217 // both "from" and "to" are smis, and
2218 // 0 <= from <= to <= string.length.
2219 // If any of these assumptions fail, we call the runtime system.
2220
2221 const int kToOffset = 0 * kPointerSize;
2222 const int kFromOffset = 1 * kPointerSize;
2223 const int kStringOffset = 2 * kPointerSize;
2224
2225 __ LoadP(r4, MemOperand(sp, kToOffset));
2226 __ LoadP(r5, MemOperand(sp, kFromOffset));
2227
2228 // If either to or from had the smi tag bit set, then fail to generic runtime
2229 __ JumpIfNotSmi(r4, &runtime);
2230 __ JumpIfNotSmi(r5, &runtime);
2231 __ SmiUntag(r4);
2232 __ SmiUntag(r5);
2233 // Both r4 and r5 are untagged integers.
2234
2235 // We want to bailout to runtime here if From is negative.
2236 __ blt(&runtime); // From < 0.
2237
2238 __ CmpLogicalP(r5, r4);
2239 __ bgt(&runtime); // Fail if from > to.
2240 __ SubP(r4, r4, r5);
2241
2242 // Make sure first argument is a string.
2243 __ LoadP(r2, MemOperand(sp, kStringOffset));
2244 __ JumpIfSmi(r2, &runtime);
2245 Condition is_string = masm->IsObjectStringType(r2, r3);
2246 __ b(NegateCondition(is_string), &runtime);
2247
2248 Label single_char;
2249 __ CmpP(r4, Operand(1));
2250 __ b(eq, &single_char);
2251
2252 // Short-cut for the case of trivial substring.
2253 Label return_r2;
2254 // r2: original string
2255 // r4: result string length
2256 __ LoadP(r6, FieldMemOperand(r2, String::kLengthOffset));
2257 __ SmiUntag(r0, r6);
2258 __ CmpLogicalP(r4, r0);
2259 // Return original string.
2260 __ beq(&return_r2);
2261 // Longer than original string's length or negative: unsafe arguments.
2262 __ bgt(&runtime);
2263 // Shorter than original string's length: an actual substring.
2264
2265 // Deal with different string types: update the index if necessary
2266 // and put the underlying string into r7.
2267 // r2: original string
2268 // r3: instance type
2269 // r4: length
2270 // r5: from index (untagged)
2271 Label underlying_unpacked, sliced_string, seq_or_external_string;
2272 // If the string is not indirect, it can only be sequential or external.
2273 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag));
2274 STATIC_ASSERT(kIsIndirectStringMask != 0);
2275 __ mov(r0, Operand(kIsIndirectStringMask));
2276 __ AndP(r0, r3);
2277 __ beq(&seq_or_external_string);
2278
2279 __ mov(r0, Operand(kSlicedNotConsMask));
2280 __ AndP(r0, r3);
2281 __ bne(&sliced_string);
2282 // Cons string. Check whether it is flat, then fetch first part.
2283 __ LoadP(r7, FieldMemOperand(r2, ConsString::kSecondOffset));
2284 __ CompareRoot(r7, Heap::kempty_stringRootIndex);
2285 __ bne(&runtime);
2286 __ LoadP(r7, FieldMemOperand(r2, ConsString::kFirstOffset));
2287 // Update instance type.
2288 __ LoadP(r3, FieldMemOperand(r7, HeapObject::kMapOffset));
2289 __ LoadlB(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset));
2290 __ b(&underlying_unpacked);
2291
2292 __ bind(&sliced_string);
2293 // Sliced string. Fetch parent and correct start index by offset.
2294 __ LoadP(r7, FieldMemOperand(r2, SlicedString::kParentOffset));
2295 __ LoadP(r6, FieldMemOperand(r2, SlicedString::kOffsetOffset));
2296 __ SmiUntag(r3, r6);
2297 __ AddP(r5, r3); // Add offset to index.
2298 // Update instance type.
2299 __ LoadP(r3, FieldMemOperand(r7, HeapObject::kMapOffset));
2300 __ LoadlB(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset));
2301 __ b(&underlying_unpacked);
2302
2303 __ bind(&seq_or_external_string);
2304 // Sequential or external string. Just move string to the expected register.
2305 __ LoadRR(r7, r2);
2306
2307 __ bind(&underlying_unpacked);
2308
2309 if (FLAG_string_slices) {
2310 Label copy_routine;
2311 // r7: underlying subject string
2312 // r3: instance type of underlying subject string
2313 // r4: length
2314 // r5: adjusted start index (untagged)
2315 __ CmpP(r4, Operand(SlicedString::kMinLength));
2316 // Short slice. Copy instead of slicing.
2317 __ blt(&copy_routine);
2318 // Allocate new sliced string. At this point we do not reload the instance
2319 // type including the string encoding because we simply rely on the info
2320 // provided by the original string. It does not matter if the original
2321 // string's encoding is wrong because we always have to recheck encoding of
2322 // the newly created string's parent anyways due to externalized strings.
2323 Label two_byte_slice, set_slice_header;
2324 STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0);
2325 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
2326 __ mov(r0, Operand(kStringEncodingMask));
2327 __ AndP(r0, r3);
2328 __ beq(&two_byte_slice);
2329 __ AllocateOneByteSlicedString(r2, r4, r8, r9, &runtime);
2330 __ b(&set_slice_header);
2331 __ bind(&two_byte_slice);
2332 __ AllocateTwoByteSlicedString(r2, r4, r8, r9, &runtime);
2333 __ bind(&set_slice_header);
2334 __ SmiTag(r5);
2335 __ StoreP(r7, FieldMemOperand(r2, SlicedString::kParentOffset));
2336 __ StoreP(r5, FieldMemOperand(r2, SlicedString::kOffsetOffset));
2337 __ b(&return_r2);
2338
2339 __ bind(&copy_routine);
2340 }
2341
2342 // r7: underlying subject string
2343 // r3: instance type of underlying subject string
2344 // r4: length
2345 // r5: adjusted start index (untagged)
2346 Label two_byte_sequential, sequential_string, allocate_result;
2347 STATIC_ASSERT(kExternalStringTag != 0);
2348 STATIC_ASSERT(kSeqStringTag == 0);
2349 __ mov(r0, Operand(kExternalStringTag));
2350 __ AndP(r0, r3);
2351 __ beq(&sequential_string);
2352
2353 // Handle external string.
2354 // Rule out short external strings.
2355 STATIC_ASSERT(kShortExternalStringTag != 0);
2356 __ mov(r0, Operand(kShortExternalStringTag));
2357 __ AndP(r0, r3);
2358 __ bne(&runtime);
2359 __ LoadP(r7, FieldMemOperand(r7, ExternalString::kResourceDataOffset));
2360 // r7 already points to the first character of underlying string.
2361 __ b(&allocate_result);
2362
2363 __ bind(&sequential_string);
2364 // Locate first character of underlying subject string.
2365 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize);
2366 __ AddP(r7, Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag));
2367
2368 __ bind(&allocate_result);
2369 // Sequential acii string. Allocate the result.
2370 STATIC_ASSERT((kOneByteStringTag & kStringEncodingMask) != 0);
2371 __ mov(r0, Operand(kStringEncodingMask));
2372 __ AndP(r0, r3);
2373 __ beq(&two_byte_sequential);
2374
2375 // Allocate and copy the resulting one-byte string.
2376 __ AllocateOneByteString(r2, r4, r6, r8, r9, &runtime);
2377
2378 // Locate first character of substring to copy.
2379 __ AddP(r7, r5);
2380 // Locate first character of result.
2381 __ AddP(r3, r2, Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag));
2382
2383 // r2: result string
2384 // r3: first character of result string
2385 // r4: result string length
2386 // r7: first character of substring to copy
2387 STATIC_ASSERT((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0);
2388 StringHelper::GenerateCopyCharacters(masm, r3, r7, r4, r5,
2389 String::ONE_BYTE_ENCODING);
2390 __ b(&return_r2);
2391
2392 // Allocate and copy the resulting two-byte string.
2393 __ bind(&two_byte_sequential);
2394 __ AllocateTwoByteString(r2, r4, r6, r8, r9, &runtime);
2395
2396 // Locate first character of substring to copy.
2397 __ ShiftLeftP(r3, r5, Operand(1));
2398 __ AddP(r7, r3);
2399 // Locate first character of result.
2400 __ AddP(r3, r2, Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag));
2401
2402 // r2: result string.
2403 // r3: first character of result.
2404 // r4: result length.
2405 // r7: first character of substring to copy.
2406 STATIC_ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0);
2407 StringHelper::GenerateCopyCharacters(masm, r3, r7, r4, r5,
2408 String::TWO_BYTE_ENCODING);
2409
2410 __ bind(&return_r2);
2411 Counters* counters = isolate()->counters();
2412 __ IncrementCounter(counters->sub_string_native(), 1, r5, r6);
2413 __ Drop(3);
2414 __ Ret();
2415
2416 // Just jump to runtime to create the sub string.
2417 __ bind(&runtime);
2418 __ TailCallRuntime(Runtime::kSubString);
2419
2420 __ bind(&single_char);
2421 // r2: original string
2422 // r3: instance type
2423 // r4: length
2424 // r5: from index (untagged)
2425 __ SmiTag(r5, r5);
2426 StringCharAtGenerator generator(r2, r5, r4, r2, &runtime, &runtime, &runtime,
2427 RECEIVER_IS_STRING);
2428 generator.GenerateFast(masm);
2429 __ Drop(3);
2430 __ Ret();
2431 generator.SkipSlow(masm, &runtime);
2432 }
2433
2205 void ToStringStub::Generate(MacroAssembler* masm) { 2434 void ToStringStub::Generate(MacroAssembler* masm) {
2206 // The ToString stub takes one argument in r2. 2435 // The ToString stub takes one argument in r2.
2207 Label done; 2436 Label done;
2208 Label is_number; 2437 Label is_number;
2209 __ JumpIfSmi(r2, &is_number); 2438 __ JumpIfSmi(r2, &is_number);
2210 2439
2211 __ CompareObjectType(r2, r3, r3, FIRST_NONSTRING_TYPE); 2440 __ CompareObjectType(r2, r3, r3, FIRST_NONSTRING_TYPE);
2212 // r2: receiver 2441 // r2: receiver
2213 // r3: receiver instance type 2442 // r3: receiver instance type
2214 __ blt(&done); 2443 __ blt(&done);
(...skipping 2911 matching lines...) Expand 10 before | Expand all | Expand 10 after
5126 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, 5355 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
5127 kStackUnwindSpace, NULL, return_value_operand, NULL); 5356 kStackUnwindSpace, NULL, return_value_operand, NULL);
5128 } 5357 }
5129 5358
5130 #undef __ 5359 #undef __
5131 5360
5132 } // namespace internal 5361 } // namespace internal
5133 } // namespace v8 5362 } // namespace v8
5134 5363
5135 #endif // V8_TARGET_ARCH_S390 5364 #endif // V8_TARGET_ARCH_S390
OLDNEW
« no previous file with comments | « src/ppc/code-stubs-ppc.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698