OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 // Check that the object is a JS array. | 299 // Check that the object is a JS array. |
300 __ JumpIfNotObjectType(receiver, scratch, scratch, JS_ARRAY_TYPE, | 300 __ JumpIfNotObjectType(receiver, scratch, scratch, JS_ARRAY_TYPE, |
301 miss_label); | 301 miss_label); |
302 | 302 |
303 // Load length directly from the JS array. | 303 // Load length directly from the JS array. |
304 __ Ldr(x0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | 304 __ Ldr(x0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
305 __ Ret(); | 305 __ Ret(); |
306 } | 306 } |
307 | 307 |
308 | 308 |
309 // Generate code to check if an object is a string. If the object is a | |
310 // heap object, its map's instance type is left in the scratch1 register. | |
311 static void GenerateStringCheck(MacroAssembler* masm, | |
312 Register receiver, | |
313 Register scratch1, | |
314 Label* smi, | |
315 Label* non_string_object) { | |
316 // Check that the receiver isn't a smi. | |
317 __ JumpIfSmi(receiver, smi); | |
318 | |
319 // Get the object's instance type filed. | |
320 __ Ldr(scratch1, FieldMemOperand(receiver, HeapObject::kMapOffset)); | |
321 __ Ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); | |
322 // Check if the "not string" bit is set. | |
323 __ Tbnz(scratch1, MaskToBit(kNotStringTag), non_string_object); | |
324 } | |
325 | |
326 | |
327 // Generate code to load the length from a string object and return the length. | |
328 // If the receiver object is not a string or a wrapped string object the | |
329 // execution continues at the miss label. The register containing the | |
330 // receiver is not clobbered if the receiver is not a string. | |
331 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, | |
332 Register receiver, | |
333 Register scratch1, | |
334 Register scratch2, | |
335 Label* miss) { | |
336 // Input registers can't alias because we don't want to clobber the | |
337 // receiver register if the object is not a string. | |
338 ASSERT(!AreAliased(receiver, scratch1, scratch2)); | |
339 | |
340 Label check_wrapper; | |
341 | |
342 // Check if the object is a string leaving the instance type in the | |
343 // scratch1 register. | |
344 GenerateStringCheck(masm, receiver, scratch1, miss, &check_wrapper); | |
345 | |
346 // Load length directly from the string. | |
347 __ Ldr(x0, FieldMemOperand(receiver, String::kLengthOffset)); | |
348 __ Ret(); | |
349 | |
350 // Check if the object is a JSValue wrapper. | |
351 __ Bind(&check_wrapper); | |
352 __ Cmp(scratch1, Operand(JS_VALUE_TYPE)); | |
353 __ B(ne, miss); | |
354 | |
355 // Unwrap the value and check if the wrapped value is a string. | |
356 __ Ldr(scratch1, FieldMemOperand(receiver, JSValue::kValueOffset)); | |
357 GenerateStringCheck(masm, scratch1, scratch2, miss, miss); | |
358 __ Ldr(x0, FieldMemOperand(scratch1, String::kLengthOffset)); | |
359 __ Ret(); | |
360 } | |
361 | |
362 | |
363 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, | 309 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, |
364 Register receiver, | 310 Register receiver, |
365 Register scratch1, | 311 Register scratch1, |
366 Register scratch2, | 312 Register scratch2, |
367 Label* miss_label) { | 313 Label* miss_label) { |
368 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); | 314 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); |
369 // TryGetFunctionPrototype can't put the result directly in x0 because the | 315 // TryGetFunctionPrototype can't put the result directly in x0 because the |
370 // 3 inputs registers can't alias and we call this function from | 316 // 3 inputs registers can't alias and we call this function from |
371 // LoadIC::GenerateFunctionPrototype, where receiver is x0. So we explicitly | 317 // LoadIC::GenerateFunctionPrototype, where receiver is x0. So we explicitly |
372 // move the result in x0. | 318 // move the result in x0. |
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 | 1486 |
1541 // Miss case, call the runtime. | 1487 // Miss case, call the runtime. |
1542 __ Bind(&miss); | 1488 __ Bind(&miss); |
1543 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1489 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
1544 } | 1490 } |
1545 | 1491 |
1546 | 1492 |
1547 } } // namespace v8::internal | 1493 } } // namespace v8::internal |
1548 | 1494 |
1549 #endif // V8_TARGET_ARCH_A64 | 1495 #endif // V8_TARGET_ARCH_A64 |
OLD | NEW |