| 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 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 __ CmpObjectType(receiver, JS_ARRAY_TYPE, scratch); | 300 __ CmpObjectType(receiver, JS_ARRAY_TYPE, scratch); |
| 301 __ j(not_equal, miss_label); | 301 __ j(not_equal, miss_label); |
| 302 | 302 |
| 303 // Load length directly from the JS array. | 303 // Load length directly from the JS array. |
| 304 __ mov(eax, FieldOperand(receiver, JSArray::kLengthOffset)); | 304 __ mov(eax, FieldOperand(receiver, JSArray::kLengthOffset)); |
| 305 __ ret(0); | 305 __ ret(0); |
| 306 } | 306 } |
| 307 | 307 |
| 308 | 308 |
| 309 // Generate code to check if an object is a string. If the object is | |
| 310 // a string, the map's instance type is left in the scratch register. | |
| 311 static void GenerateStringCheck(MacroAssembler* masm, | |
| 312 Register receiver, | |
| 313 Register scratch, | |
| 314 Label* smi, | |
| 315 Label* non_string_object) { | |
| 316 // Check that the object isn't a smi. | |
| 317 __ JumpIfSmi(receiver, smi); | |
| 318 | |
| 319 // Check that the object is a string. | |
| 320 __ mov(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | |
| 321 __ movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); | |
| 322 STATIC_ASSERT(kNotStringTag != 0); | |
| 323 __ test(scratch, Immediate(kNotStringTag)); | |
| 324 __ j(not_zero, non_string_object); | |
| 325 } | |
| 326 | |
| 327 | |
| 328 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, | |
| 329 Register receiver, | |
| 330 Register scratch1, | |
| 331 Register scratch2, | |
| 332 Label* miss) { | |
| 333 Label check_wrapper; | |
| 334 | |
| 335 // Check if the object is a string leaving the instance type in the | |
| 336 // scratch register. | |
| 337 GenerateStringCheck(masm, receiver, scratch1, miss, &check_wrapper); | |
| 338 | |
| 339 // Load length from the string and convert to a smi. | |
| 340 __ mov(eax, FieldOperand(receiver, String::kLengthOffset)); | |
| 341 __ ret(0); | |
| 342 | |
| 343 // Check if the object is a JSValue wrapper. | |
| 344 __ bind(&check_wrapper); | |
| 345 __ cmp(scratch1, JS_VALUE_TYPE); | |
| 346 __ j(not_equal, miss); | |
| 347 | |
| 348 // Check if the wrapped value is a string and load the length | |
| 349 // directly if it is. | |
| 350 __ mov(scratch2, FieldOperand(receiver, JSValue::kValueOffset)); | |
| 351 GenerateStringCheck(masm, scratch2, scratch1, miss, miss); | |
| 352 __ mov(eax, FieldOperand(scratch2, String::kLengthOffset)); | |
| 353 __ ret(0); | |
| 354 } | |
| 355 | |
| 356 | |
| 357 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, | 309 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, |
| 358 Register receiver, | 310 Register receiver, |
| 359 Register scratch1, | 311 Register scratch1, |
| 360 Register scratch2, | 312 Register scratch2, |
| 361 Label* miss_label) { | 313 Label* miss_label) { |
| 362 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); | 314 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); |
| 363 __ mov(eax, scratch1); | 315 __ mov(eax, scratch1); |
| 364 __ ret(0); | 316 __ ret(0); |
| 365 } | 317 } |
| 366 | 318 |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 // ----------------------------------- | 1521 // ----------------------------------- |
| 1570 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1522 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
| 1571 } | 1523 } |
| 1572 | 1524 |
| 1573 | 1525 |
| 1574 #undef __ | 1526 #undef __ |
| 1575 | 1527 |
| 1576 } } // namespace v8::internal | 1528 } } // namespace v8::internal |
| 1577 | 1529 |
| 1578 #endif // V8_TARGET_ARCH_IA32 | 1530 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |