| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 // Check that the object is a JS array. | 274 // Check that the object is a JS array. |
| 275 __ CmpObjectType(receiver, JS_ARRAY_TYPE, scratch); | 275 __ CmpObjectType(receiver, JS_ARRAY_TYPE, scratch); |
| 276 __ j(not_equal, miss_label); | 276 __ j(not_equal, miss_label); |
| 277 | 277 |
| 278 // Load length directly from the JS array. | 278 // Load length directly from the JS array. |
| 279 __ movp(rax, FieldOperand(receiver, JSArray::kLengthOffset)); | 279 __ movp(rax, FieldOperand(receiver, JSArray::kLengthOffset)); |
| 280 __ ret(0); | 280 __ ret(0); |
| 281 } | 281 } |
| 282 | 282 |
| 283 | 283 |
| 284 // Generate code to check if an object is a string. If the object is | |
| 285 // a string, the map's instance type is left in the scratch register. | |
| 286 static void GenerateStringCheck(MacroAssembler* masm, | |
| 287 Register receiver, | |
| 288 Register scratch, | |
| 289 Label* smi, | |
| 290 Label* non_string_object) { | |
| 291 // Check that the object isn't a smi. | |
| 292 __ JumpIfSmi(receiver, smi); | |
| 293 | |
| 294 // Check that the object is a string. | |
| 295 __ movp(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | |
| 296 __ movzxbq(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); | |
| 297 STATIC_ASSERT(kNotStringTag != 0); | |
| 298 __ testl(scratch, Immediate(kNotStringTag)); | |
| 299 __ j(not_zero, non_string_object); | |
| 300 } | |
| 301 | |
| 302 | |
| 303 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, | |
| 304 Register receiver, | |
| 305 Register scratch1, | |
| 306 Register scratch2, | |
| 307 Label* miss) { | |
| 308 Label check_wrapper; | |
| 309 | |
| 310 // Check if the object is a string leaving the instance type in the | |
| 311 // scratch register. | |
| 312 GenerateStringCheck(masm, receiver, scratch1, miss, &check_wrapper); | |
| 313 | |
| 314 // Load length directly from the string. | |
| 315 __ movp(rax, FieldOperand(receiver, String::kLengthOffset)); | |
| 316 __ ret(0); | |
| 317 | |
| 318 // Check if the object is a JSValue wrapper. | |
| 319 __ bind(&check_wrapper); | |
| 320 __ cmpl(scratch1, Immediate(JS_VALUE_TYPE)); | |
| 321 __ j(not_equal, miss); | |
| 322 | |
| 323 // Check if the wrapped value is a string and load the length | |
| 324 // directly if it is. | |
| 325 __ movp(scratch2, FieldOperand(receiver, JSValue::kValueOffset)); | |
| 326 GenerateStringCheck(masm, scratch2, scratch1, miss, miss); | |
| 327 __ movp(rax, FieldOperand(scratch2, String::kLengthOffset)); | |
| 328 __ ret(0); | |
| 329 } | |
| 330 | |
| 331 | |
| 332 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, | 284 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, |
| 333 Register receiver, | 285 Register receiver, |
| 334 Register result, | 286 Register result, |
| 335 Register scratch, | 287 Register scratch, |
| 336 Label* miss_label) { | 288 Label* miss_label) { |
| 337 __ TryGetFunctionPrototype(receiver, result, miss_label); | 289 __ TryGetFunctionPrototype(receiver, result, miss_label); |
| 338 if (!result.is(rax)) __ movp(rax, result); | 290 if (!result.is(rax)) __ movp(rax, result); |
| 339 __ ret(0); | 291 __ ret(0); |
| 340 } | 292 } |
| 341 | 293 |
| (...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 // ----------------------------------- | 1426 // ----------------------------------- |
| 1475 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1427 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
| 1476 } | 1428 } |
| 1477 | 1429 |
| 1478 | 1430 |
| 1479 #undef __ | 1431 #undef __ |
| 1480 | 1432 |
| 1481 } } // namespace v8::internal | 1433 } } // namespace v8::internal |
| 1482 | 1434 |
| 1483 #endif // V8_TARGET_ARCH_X64 | 1435 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |