Changeset 46598 in webkit for trunk/JavaScriptCore/jit/JITStubs.cpp
- Timestamp:
- Jul 30, 2009, 1:57:44 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/jit/JITStubs.cpp
r46247 r46598 63 63 namespace JSC { 64 64 65 66 65 #if PLATFORM(DARWIN) || PLATFORM(WIN_OS) 67 66 #define SYMBOL_STRING(name) "_" #name … … 70 69 #endif 71 70 71 #if USE(JSVALUE32_64) 72 72 73 #if COMPILER(GCC) && PLATFORM(X86) 73 74 74 75 // These ASSERTs remind you that, if you change the layout of JITStackFrame, you 75 76 // need to change the assembly trampolines below to match. 76 COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x38, JITStackFrame_callFrame_offset_matches_ctiTrampoline); 77 COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_offset_matches_ctiTrampoline); 78 COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline); 77 COMPILE_ASSERT(offsetof(struct JITStackFrame, code) % 16 == 0x0, JITStackFrame_maintains_16byte_stack_alignment); 78 COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x3c, JITStackFrame_stub_argument_space_matches_ctiTrampoline); 79 COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_callFrame_offset_matches_ctiTrampoline); 80 COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_offset_matches_ctiTrampoline); 79 81 80 82 asm volatile ( … … 86 88 "pushl %edi" "\n" 87 89 "pushl %ebx" "\n" 88 "subl $0x 1c, %esp" "\n"90 "subl $0x3c, %esp" "\n" 89 91 "movl $512, %esi" "\n" 90 "movl 0x 38(%esp), %edi" "\n"91 "call *0x 30(%esp)" "\n"92 "addl $0x 1c, %esp" "\n"92 "movl 0x58(%esp), %edi" "\n" 93 "call *0x50(%esp)" "\n" 94 "addl $0x3c, %esp" "\n" 93 95 "popl %ebx" "\n" 94 96 "popl %edi" "\n" … … 105 107 #endif 106 108 "call " SYMBOL_STRING(cti_vm_throw) "\n" 107 "addl $0x 1c, %esp" "\n"109 "addl $0x3c, %esp" "\n" 108 110 "popl %ebx" "\n" 109 111 "popl %edi" "\n" … … 116 118 ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" 117 119 SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" 118 "addl $0x 1c, %esp" "\n"120 "addl $0x3c, %esp" "\n" 119 121 "popl %ebx" "\n" 120 122 "popl %edi" "\n" … … 132 134 // These ASSERTs remind you that, if you change the layout of JITStackFrame, you 133 135 // need to change the assembly trampolines below to match. 136 COMPILE_ASSERT(offsetof(struct JITStackFrame, code) % 32 == 0x0, JITStackFrame_maintains_32byte_stack_alignment); 137 COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x48, JITStackFrame_stub_argument_space_matches_ctiTrampoline); 134 138 COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x90, JITStackFrame_callFrame_offset_matches_ctiTrampoline); 135 139 COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x80, JITStackFrame_code_offset_matches_ctiTrampoline); 136 COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x48, JITStackFrame_stub_argument_space_matches_ctiTrampoline);137 140 138 141 asm volatile ( … … 262 265 // These ASSERTs remind you that, if you change the layout of JITStackFrame, you 263 266 // need to change the assembly trampolines below to match. 267 COMPILE_ASSERT(offsetof(struct JITStackFrame, code) % 16 == 0x0, JITStackFrame_maintains_16byte_stack_alignment); 268 COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x3c, JITStackFrame_stub_argument_space_matches_ctiTrampoline); 269 COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_callFrame_offset_matches_ctiTrampoline); 270 COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_offset_matches_ctiTrampoline); 271 272 extern "C" { 273 274 __declspec(naked) EncodedJSValue ctiTrampoline(void* code, RegisterFile*, CallFrame*, JSValue* exception, Profiler**, JSGlobalData*) 275 { 276 __asm { 277 push ebp; 278 mov ebp, esp; 279 push esi; 280 push edi; 281 push ebx; 282 sub esp, 0x3c; 283 mov esi, 512; 284 mov ecx, esp; 285 mov edi, [esp + 0x58]; 286 call [esp + 0x50]; 287 add esp, 0x3c; 288 pop ebx; 289 pop edi; 290 pop esi; 291 pop ebp; 292 ret; 293 } 294 } 295 296 __declspec(naked) void ctiVMThrowTrampoline() 297 { 298 __asm { 299 mov ecx, esp; 300 call cti_vm_throw; 301 add esp, 0x3c; 302 pop ebx; 303 pop edi; 304 pop esi; 305 pop ebp; 306 ret; 307 } 308 } 309 310 __declspec(naked) void ctiOpThrowNotCaught() 311 { 312 __asm { 313 add esp, 0x3c; 314 pop ebx; 315 pop edi; 316 pop esi; 317 pop ebp; 318 ret; 319 } 320 } 321 } 322 323 #endif // COMPILER(GCC) && PLATFORM(X86) 324 325 #else // USE(JSVALUE32_64) 326 327 #if COMPILER(GCC) && PLATFORM(X86) 328 329 // These ASSERTs remind you that, if you change the layout of JITStackFrame, you 330 // need to change the assembly trampolines below to match. 331 COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x38, JITStackFrame_callFrame_offset_matches_ctiTrampoline); 332 COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_offset_matches_ctiTrampoline); 333 COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline); 334 335 asm volatile ( 336 ".globl " SYMBOL_STRING(ctiTrampoline) "\n" 337 SYMBOL_STRING(ctiTrampoline) ":" "\n" 338 "pushl %ebp" "\n" 339 "movl %esp, %ebp" "\n" 340 "pushl %esi" "\n" 341 "pushl %edi" "\n" 342 "pushl %ebx" "\n" 343 "subl $0x1c, %esp" "\n" 344 "movl $512, %esi" "\n" 345 "movl 0x38(%esp), %edi" "\n" 346 "call *0x30(%esp)" "\n" 347 "addl $0x1c, %esp" "\n" 348 "popl %ebx" "\n" 349 "popl %edi" "\n" 350 "popl %esi" "\n" 351 "popl %ebp" "\n" 352 "ret" "\n" 353 ); 354 355 asm volatile ( 356 ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" 357 SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" 358 #if !USE(JIT_STUB_ARGUMENT_VA_LIST) 359 "movl %esp, %ecx" "\n" 360 #endif 361 "call " SYMBOL_STRING(cti_vm_throw) "\n" 362 "addl $0x1c, %esp" "\n" 363 "popl %ebx" "\n" 364 "popl %edi" "\n" 365 "popl %esi" "\n" 366 "popl %ebp" "\n" 367 "ret" "\n" 368 ); 369 370 asm volatile ( 371 ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" 372 SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" 373 "addl $0x1c, %esp" "\n" 374 "popl %ebx" "\n" 375 "popl %edi" "\n" 376 "popl %esi" "\n" 377 "popl %ebp" "\n" 378 "ret" "\n" 379 ); 380 381 #elif COMPILER(GCC) && PLATFORM(X86_64) 382 383 #if USE(JIT_STUB_ARGUMENT_VA_LIST) 384 #error "JIT_STUB_ARGUMENT_VA_LIST not supported on x86-64." 385 #endif 386 387 // These ASSERTs remind you that, if you change the layout of JITStackFrame, you 388 // need to change the assembly trampolines below to match. 389 COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x90, JITStackFrame_callFrame_offset_matches_ctiTrampoline); 390 COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x80, JITStackFrame_code_offset_matches_ctiTrampoline); 391 COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x48, JITStackFrame_stub_argument_space_matches_ctiTrampoline); 392 393 asm volatile ( 394 ".globl " SYMBOL_STRING(ctiTrampoline) "\n" 395 SYMBOL_STRING(ctiTrampoline) ":" "\n" 396 "pushq %rbp" "\n" 397 "movq %rsp, %rbp" "\n" 398 "pushq %r12" "\n" 399 "pushq %r13" "\n" 400 "pushq %r14" "\n" 401 "pushq %r15" "\n" 402 "pushq %rbx" "\n" 403 "subq $0x48, %rsp" "\n" 404 "movq $512, %r12" "\n" 405 "movq $0xFFFF000000000000, %r14" "\n" 406 "movq $0xFFFF000000000002, %r15" "\n" 407 "movq 0x90(%rsp), %r13" "\n" 408 "call *0x80(%rsp)" "\n" 409 "addq $0x48, %rsp" "\n" 410 "popq %rbx" "\n" 411 "popq %r15" "\n" 412 "popq %r14" "\n" 413 "popq %r13" "\n" 414 "popq %r12" "\n" 415 "popq %rbp" "\n" 416 "ret" "\n" 417 ); 418 419 asm volatile ( 420 ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" 421 SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" 422 "movq %rsp, %rdi" "\n" 423 "call " SYMBOL_STRING(cti_vm_throw) "\n" 424 "addq $0x48, %rsp" "\n" 425 "popq %rbx" "\n" 426 "popq %r15" "\n" 427 "popq %r14" "\n" 428 "popq %r13" "\n" 429 "popq %r12" "\n" 430 "popq %rbp" "\n" 431 "ret" "\n" 432 ); 433 434 asm volatile ( 435 ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" 436 SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" 437 "addq $0x48, %rsp" "\n" 438 "popq %rbx" "\n" 439 "popq %r15" "\n" 440 "popq %r14" "\n" 441 "popq %r13" "\n" 442 "popq %r12" "\n" 443 "popq %rbp" "\n" 444 "ret" "\n" 445 ); 446 447 #elif COMPILER(GCC) && PLATFORM_ARM_ARCH(7) 448 449 #if USE(JIT_STUB_ARGUMENT_VA_LIST) 450 #error "JIT_STUB_ARGUMENT_VA_LIST not supported on ARMv7." 451 #endif 452 453 asm volatile ( 454 ".text" "\n" 455 ".align 2" "\n" 456 ".globl " SYMBOL_STRING(ctiTrampoline) "\n" 457 ".thumb" "\n" 458 ".thumb_func " SYMBOL_STRING(ctiTrampoline) "\n" 459 SYMBOL_STRING(ctiTrampoline) ":" "\n" 460 "sub sp, sp, #0x3c" "\n" 461 "str lr, [sp, #0x20]" "\n" 462 "str r4, [sp, #0x24]" "\n" 463 "str r5, [sp, #0x28]" "\n" 464 "str r6, [sp, #0x2c]" "\n" 465 "str r1, [sp, #0x30]" "\n" 466 "str r2, [sp, #0x34]" "\n" 467 "str r3, [sp, #0x38]" "\n" 468 "cpy r5, r2" "\n" 469 "mov r6, #512" "\n" 470 "blx r0" "\n" 471 "ldr r6, [sp, #0x2c]" "\n" 472 "ldr r5, [sp, #0x28]" "\n" 473 "ldr r4, [sp, #0x24]" "\n" 474 "ldr lr, [sp, #0x20]" "\n" 475 "add sp, sp, #0x3c" "\n" 476 "bx lr" "\n" 477 ); 478 479 asm volatile ( 480 ".text" "\n" 481 ".align 2" "\n" 482 ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" 483 ".thumb" "\n" 484 ".thumb_func " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" 485 SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" 486 "cpy r0, sp" "\n" 487 "bl " SYMBOL_STRING(cti_vm_throw) "\n" 488 "ldr r6, [sp, #0x2c]" "\n" 489 "ldr r5, [sp, #0x28]" "\n" 490 "ldr r4, [sp, #0x24]" "\n" 491 "ldr lr, [sp, #0x20]" "\n" 492 "add sp, sp, #0x3c" "\n" 493 "bx lr" "\n" 494 ); 495 496 asm volatile ( 497 ".text" "\n" 498 ".align 2" "\n" 499 ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" 500 ".thumb" "\n" 501 ".thumb_func " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" 502 SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" 503 "ldr r6, [sp, #0x2c]" "\n" 504 "ldr r5, [sp, #0x28]" "\n" 505 "ldr r4, [sp, #0x24]" "\n" 506 "ldr lr, [sp, #0x20]" "\n" 507 "add sp, sp, #0x3c" "\n" 508 "bx lr" "\n" 509 ); 510 511 #elif COMPILER(MSVC) 512 513 #if USE(JIT_STUB_ARGUMENT_VA_LIST) 514 #error "JIT_STUB_ARGUMENT_VA_LIST configuration not supported on MSVC." 515 #endif 516 517 // These ASSERTs remind you that, if you change the layout of JITStackFrame, you 518 // need to change the assembly trampolines below to match. 264 519 COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x38, JITStackFrame_callFrame_offset_matches_ctiTrampoline); 265 520 COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_offset_matches_ctiTrampoline); … … 294 549 __asm { 295 550 mov ecx, esp; 296 call JITStubs::cti_vm_throw;551 call cti_vm_throw; 297 552 add esp, 0x1c; 298 553 pop ebx; … … 317 572 } 318 573 319 #endif 574 #endif // COMPILER(GCC) && PLATFORM(X86) 575 576 #endif // USE(JSVALUE32_64) 320 577 321 578 #if ENABLE(OPCODE_SAMPLING) … … 327 584 JITThunks::JITThunks(JSGlobalData* globalData) 328 585 { 329 JIT::compileCTIMachineTrampolines(globalData, &m_executablePool, &m_cti ArrayLengthTrampoline, &m_ctiStringLengthTrampoline, &m_ctiVirtualCallPreLink, &m_ctiVirtualCallLink, &m_ctiVirtualCall, &m_ctiNativeCallThunk);586 JIT::compileCTIMachineTrampolines(globalData, &m_executablePool, &m_ctiStringLengthTrampoline, &m_ctiVirtualCallPreLink, &m_ctiVirtualCallLink, &m_ctiVirtualCall, &m_ctiNativeCallThunk); 330 587 331 588 #if PLATFORM_ARM_ARCH(7) … … 359 616 // Uncacheable: give up. 360 617 if (!slot.isCacheable()) { 361 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr( JITStubs::cti_op_put_by_id_generic));618 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_put_by_id_generic)); 362 619 return; 363 620 } … … 367 624 368 625 if (structure->isDictionary()) { 369 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr( JITStubs::cti_op_put_by_id_generic));626 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_put_by_id_generic)); 370 627 return; 371 628 } … … 373 630 // If baseCell != base, then baseCell must be a proxy for another object. 374 631 if (baseCell != slot.base()) { 375 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr( JITStubs::cti_op_put_by_id_generic));632 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_put_by_id_generic)); 376 633 return; 377 634 } … … 385 642 StructureChain* prototypeChain = structure->prototypeChain(callFrame); 386 643 if (!prototypeChain->isCacheable()) { 387 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr( JITStubs::cti_op_put_by_id_generic));644 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_put_by_id_generic)); 388 645 return; 389 646 } … … 405 662 // FIXME: Cache property access for immediates. 406 663 if (!baseValue.isCell()) { 407 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr( JITStubs::cti_op_get_by_id_generic));664 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_get_by_id_generic)); 408 665 return; 409 666 } … … 425 682 // Uncacheable: give up. 426 683 if (!slot.isCacheable()) { 427 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr( JITStubs::cti_op_get_by_id_generic));684 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_get_by_id_generic)); 428 685 return; 429 686 } … … 433 690 434 691 if (structure->isDictionary()) { 435 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr( JITStubs::cti_op_get_by_id_generic));692 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_get_by_id_generic)); 436 693 return; 437 694 } … … 476 733 StructureChain* prototypeChain = structure->prototypeChain(callFrame); 477 734 if (!prototypeChain->isCacheable()) { 478 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr( JITStubs::cti_op_get_by_id_generic));735 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_get_by_id_generic)); 479 736 return; 480 737 } … … 483 740 } 484 741 485 #endif 742 #endif // ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS) 486 743 487 744 #if USE(JIT_STUB_ARGUMENT_VA_LIST) … … 560 817 #define CHECK_FOR_EXCEPTION() \ 561 818 do { \ 562 if (UNLIKELY(stackFrame.globalData->exception != JSValue())) \819 if (UNLIKELY(stackFrame.globalData->exception)) \ 563 820 VM_THROW_EXCEPTION(); \ 564 821 } while (0) 565 822 #define CHECK_FOR_EXCEPTION_AT_END() \ 566 823 do { \ 567 if (UNLIKELY(stackFrame.globalData->exception != JSValue())) \824 if (UNLIKELY(stackFrame.globalData->exception)) \ 568 825 VM_THROW_EXCEPTION_AT_END(); \ 569 826 } while (0) 570 827 #define CHECK_FOR_EXCEPTION_VOID() \ 571 828 do { \ 572 if (UNLIKELY(stackFrame.globalData->exception != JSValue())) { \829 if (UNLIKELY(stackFrame.globalData->exception)) { \ 573 830 VM_THROW_EXCEPTION_AT_END(); \ 574 831 return; \ 575 832 } \ 576 833 } while (0) 577 578 namespace JITStubs {579 834 580 835 #if PLATFORM_ARM_ARCH(7) … … 602 857 #endif 603 858 604 DEFINE_STUB_FUNCTION( JSObject*, op_convert_this)859 DEFINE_STUB_FUNCTION(EncodedJSValue, op_convert_this) 605 860 { 606 861 STUB_INIT_STACK_FRAME(stackFrame); … … 611 866 JSObject* result = v1.toThisObject(callFrame); 612 867 CHECK_FOR_EXCEPTION_AT_END(); 613 return result;868 return JSValue::encode(result); 614 869 } 615 870 … … 651 906 652 907 if (rightIsNumber & leftIsString) { 653 RefPtr<UString::Rep> value = v2.isInt32 Fast() ?654 concatenate(asString(v1)->value().rep(), v2. getInt32Fast()) :908 RefPtr<UString::Rep> value = v2.isInt32() ? 909 concatenate(asString(v1)->value().rep(), v2.asInt32()) : 655 910 concatenate(asString(v1)->value().rep(), right); 656 911 … … 806 1061 } 807 1062 808 809 DEFINE_STUB_FUNCTION(EncodedJSValue, op_put_by_id_transition_realloc) 1063 DEFINE_STUB_FUNCTION(JSObject*, op_put_by_id_transition_realloc) 810 1064 { 811 1065 STUB_INIT_STACK_FRAME(stackFrame); 812 1066 813 1067 JSValue baseValue = stackFrame.args[0].jsValue(); 814 int32_t oldSize = stackFrame.args[ 1].int32();815 int32_t newSize = stackFrame.args[ 2].int32();1068 int32_t oldSize = stackFrame.args[3].int32(); 1069 int32_t newSize = stackFrame.args[4].int32(); 816 1070 817 1071 ASSERT(baseValue.isObject()); 818 asObject(baseValue)->allocatePropertyStorage(oldSize, newSize); 819 820 return JSValue::encode(baseValue); 1072 JSObject* base = asObject(baseValue); 1073 base->allocatePropertyStorage(oldSize, newSize); 1074 1075 return base; 821 1076 } 822 1077 … … 1117 1372 } 1118 1373 1119 #endif 1374 #endif // ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS) 1120 1375 1121 1376 DEFINE_STUB_FUNCTION(EncodedJSValue, op_instanceof) … … 1264 1519 } 1265 1520 1521 #if ENABLE(JIT_OPTIMIZE_CALL) 1266 1522 DEFINE_STUB_FUNCTION(void*, vm_dontLazyLinkCall) 1267 1523 { … … 1294 1550 return jitCode.addressForCall().executableAddress(); 1295 1551 } 1552 #endif // !ENABLE(JIT_OPTIMIZE_CALL) 1296 1553 1297 1554 DEFINE_STUB_FUNCTION(JSObject*, op_push_activation) … … 1359 1616 Arguments* arguments = new (stackFrame.globalData) Arguments(stackFrame.callFrame); 1360 1617 stackFrame.callFrame->setCalleeArguments(arguments); 1361 stackFrame.callFrame[RegisterFile::ArgumentsRegister] = arguments;1618 stackFrame.callFrame[RegisterFile::ArgumentsRegister] = JSValue(arguments); 1362 1619 } 1363 1620 … … 1368 1625 Arguments* arguments = new (stackFrame.globalData) Arguments(stackFrame.callFrame, Arguments::NoParameters); 1369 1626 stackFrame.callFrame->setCalleeArguments(arguments); 1370 stackFrame.callFrame[RegisterFile::ArgumentsRegister] = arguments;1627 stackFrame.callFrame[RegisterFile::ArgumentsRegister] = JSValue(arguments); 1371 1628 } 1372 1629 … … 1520 1777 JSValue result; 1521 1778 1522 if (LIKELY(subscript.isUInt32 Fast())) {1523 uint32_t i = subscript. getUInt32Fast();1779 if (LIKELY(subscript.isUInt32())) { 1780 uint32_t i = subscript.asUInt32(); 1524 1781 if (isJSArray(globalData, baseValue)) { 1525 1782 JSArray* jsArray = asArray(baseValue); … … 1559 1816 JSValue result; 1560 1817 1561 if (LIKELY(subscript.isUInt32 Fast())) {1562 uint32_t i = subscript. getUInt32Fast();1818 if (LIKELY(subscript.isUInt32())) { 1819 uint32_t i = subscript.asUInt32(); 1563 1820 if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i)) 1564 1821 result = asString(baseValue)->getIndex(stackFrame.globalData, i); … … 1577 1834 } 1578 1835 1579 1580 1836 DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val_byte_array) 1581 1837 { … … 1590 1846 JSValue result; 1591 1847 1592 if (LIKELY(subscript.isUInt32 Fast())) {1593 uint32_t i = subscript. getUInt32Fast();1848 if (LIKELY(subscript.isUInt32())) { 1849 uint32_t i = subscript.asUInt32(); 1594 1850 if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) { 1595 1851 // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks. … … 1609 1865 } 1610 1866 1611 DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_func)1612 {1613 STUB_INIT_STACK_FRAME(stackFrame);1614 1615 CallFrame* callFrame = stackFrame.callFrame;1616 ScopeChainNode* scopeChain = callFrame->scopeChain();1617 1618 ScopeChainIterator iter = scopeChain->begin();1619 ScopeChainIterator end = scopeChain->end();1620 1621 // FIXME: add scopeDepthIsZero optimization1622 1623 ASSERT(iter != end);1624 1625 Identifier& ident = stackFrame.args[0].identifier();1626 JSObject* base;1627 do {1628 base = *iter;1629 PropertySlot slot(base);1630 if (base->getPropertySlot(callFrame, ident, slot)) {1631 // ECMA 11.2.3 says that if we hit an activation the this value should be null.1632 // However, section 10.2.3 says that in the case where the value provided1633 // by the caller is null, the global object should be used. It also says1634 // that the section does not apply to internal functions, but for simplicity1635 // of implementation we use the global object anyway here. This guarantees1636 // that in host objects you always get a valid object for this.1637 // We also handle wrapper substitution for the global object at the same time.1638 JSObject* thisObj = base->toThisObject(callFrame);1639 JSValue result = slot.getValue(callFrame, ident);1640 CHECK_FOR_EXCEPTION_AT_END();1641 1642 callFrame->registers()[stackFrame.args[1].int32()] = JSValue(thisObj);1643 return JSValue::encode(result);1644 }1645 ++iter;1646 } while (iter != end);1647 1648 CodeBlock* codeBlock = callFrame->codeBlock();1649 unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);1650 stackFrame.globalData->exception = createUndefinedVariableError(callFrame, ident, vPCIndex, codeBlock);1651 VM_THROW_EXCEPTION_AT_END();1652 return JSValue::encode(JSValue());1653 }1654 1655 1867 DEFINE_STUB_FUNCTION(EncodedJSValue, op_sub) 1656 1868 { … … 1682 1894 JSValue value = stackFrame.args[2].jsValue(); 1683 1895 1684 if (LIKELY(subscript.isUInt32 Fast())) {1685 uint32_t i = subscript. getUInt32Fast();1896 if (LIKELY(subscript.isUInt32())) { 1897 uint32_t i = subscript.asUInt32(); 1686 1898 if (isJSArray(globalData, baseValue)) { 1687 1899 JSArray* jsArray = asArray(baseValue); … … 1694 1906 ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_put_by_val_byte_array)); 1695 1907 // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks. 1696 if (value.isInt32 Fast()) {1697 jsByteArray->setIndex(i, value. getInt32Fast());1908 if (value.isInt32()) { 1909 jsByteArray->setIndex(i, value.asInt32()); 1698 1910 return; 1699 1911 } else { … … 1733 1945 asArray(baseValue)->JSArray::put(callFrame, i, value); 1734 1946 else { 1735 // This should work since we're re-boxing an immediate unboxed in JIT code. 1736 ASSERT(JSValue::makeInt32Fast(i)); 1737 Identifier property(callFrame, JSValue::makeInt32Fast(i).toString(callFrame)); 1738 // FIXME: can toString throw an exception here? 1739 if (!stackFrame.globalData->exception) { // Don't put to an object if toString threw an exception. 1740 PutPropertySlot slot; 1741 baseValue.put(callFrame, property, value, slot); 1742 } 1947 Identifier property(callFrame, UString::from(i)); 1948 PutPropertySlot slot; 1949 baseValue.put(callFrame, property, value, slot); 1743 1950 } 1744 1951 … … 1757 1964 JSValue value = stackFrame.args[2].jsValue(); 1758 1965 1759 if (LIKELY(subscript.isUInt32 Fast())) {1760 uint32_t i = subscript. getUInt32Fast();1966 if (LIKELY(subscript.isUInt32())) { 1967 uint32_t i = subscript.asUInt32(); 1761 1968 if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) { 1762 1969 JSByteArray* jsByteArray = asByteArray(baseValue); 1763 1970 1764 1971 // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks. 1765 if (value.isInt32 Fast()) {1766 jsByteArray->setIndex(i, value. getInt32Fast());1972 if (value.isInt32()) { 1973 jsByteArray->setIndex(i, value.asInt32()); 1767 1974 return; 1768 1975 } else { … … 1815 2022 { 1816 2023 STUB_INIT_STACK_FRAME(stackFrame); 2024 1817 2025 CallFrame* callFrame = stackFrame.callFrame; 1818 2026 RegisterFile* registerFile = stackFrame.registerFile; … … 1829 2037 VM_THROW_EXCEPTION(); 1830 2038 } 1831 int32_t expectedParams = asFunction(callFrame->registers()[RegisterFile::Callee].jsValue())->body()->parameterCount();2039 int32_t expectedParams = callFrame->callee()->body()->parameterCount(); 1832 2040 int32_t inplaceArgs = min(providedParams, expectedParams); 1833 2041 … … 1961 2169 1962 2170 CallFrame* callFrame = stackFrame.callFrame; 1963 JSGlobalObject* globalObject = asGlobalObject(stackFrame.args[0].jsValue());2171 JSGlobalObject* globalObject = stackFrame.args[0].globalObject(); 1964 2172 Identifier& ident = stackFrame.args[1].identifier(); 1965 2173 unsigned globalResolveInfoIndex = stackFrame.args[2].int32(); … … 2085 2293 } 2086 2294 2087 DEFINE_STUB_FUNCTION(EncodedJSValue, op_eq) 2295 #if USE(JSVALUE32_64) 2296 2297 DEFINE_STUB_FUNCTION(bool, op_eq) 2088 2298 { 2089 2299 STUB_INIT_STACK_FRAME(stackFrame); … … 2092 2302 JSValue src2 = stackFrame.args[1].jsValue(); 2093 2303 2094 CallFrame* callFrame = stackFrame.callFrame; 2095 2096 ASSERT(!JSValue::areBothInt32Fast(src1, src2)); 2097 JSValue result = jsBoolean(JSValue::equalSlowCaseInline(callFrame, src1, src2)); 2098 CHECK_FOR_EXCEPTION_AT_END(); 2099 return JSValue::encode(result); 2100 } 2304 start: 2305 if (src2.isUndefined()) { 2306 return src1.isNull() || 2307 (src1.isCell() && asCell(src1)->structure()->typeInfo().masqueradesAsUndefined()) || 2308 src1.isUndefined(); 2309 } 2310 2311 if (src2.isNull()) { 2312 return src1.isUndefined() || 2313 (src1.isCell() && asCell(src1)->structure()->typeInfo().masqueradesAsUndefined()) || 2314 src1.isNull(); 2315 } 2316 2317 if (src1.isInt32()) { 2318 if (src2.isDouble()) 2319 return src1.asInt32() == src2.asDouble(); 2320 double d = src2.toNumber(stackFrame.callFrame); 2321 CHECK_FOR_EXCEPTION(); 2322 return src1.asInt32() == d; 2323 } 2324 2325 if (src1.isDouble()) { 2326 if (src2.isInt32()) 2327 return src1.asDouble() == src2.asInt32(); 2328 double d = src2.toNumber(stackFrame.callFrame); 2329 CHECK_FOR_EXCEPTION(); 2330 return src1.asDouble() == d; 2331 } 2332 2333 if (src1.isTrue()) { 2334 if (src2.isFalse()) 2335 return false; 2336 double d = src2.toNumber(stackFrame.callFrame); 2337 CHECK_FOR_EXCEPTION(); 2338 return d == 1.0; 2339 } 2340 2341 if (src1.isFalse()) { 2342 if (src2.isTrue()) 2343 return false; 2344 double d = src2.toNumber(stackFrame.callFrame); 2345 CHECK_FOR_EXCEPTION(); 2346 return d == 0.0; 2347 } 2348 2349 if (src1.isUndefined()) 2350 return src2.isCell() && asCell(src2)->structure()->typeInfo().masqueradesAsUndefined(); 2351 2352 if (src1.isNull()) 2353 return src2.isCell() && asCell(src2)->structure()->typeInfo().masqueradesAsUndefined(); 2354 2355 ASSERT(src1.isCell()); 2356 2357 JSCell* cell1 = asCell(src1); 2358 2359 if (cell1->isString()) { 2360 if (src2.isInt32()) 2361 return static_cast<JSString*>(cell1)->value().toDouble() == src2.asInt32(); 2362 2363 if (src2.isDouble()) 2364 return static_cast<JSString*>(cell1)->value().toDouble() == src2.asDouble(); 2365 2366 if (src2.isTrue()) 2367 return static_cast<JSString*>(cell1)->value().toDouble() == 1.0; 2368 2369 if (src2.isFalse()) 2370 return static_cast<JSString*>(cell1)->value().toDouble() == 0.0; 2371 2372 ASSERT(src2.isCell()); 2373 JSCell* cell2 = asCell(src2); 2374 if (cell2->isString()) 2375 return static_cast<JSString*>(cell1)->value() == static_cast<JSString*>(cell2)->value(); 2376 2377 ASSERT(cell2->isObject()); 2378 src2 = static_cast<JSObject*>(cell2)->toPrimitive(stackFrame.callFrame); 2379 CHECK_FOR_EXCEPTION(); 2380 goto start; 2381 } 2382 2383 ASSERT(cell1->isObject()); 2384 if (src2.isObject()) 2385 return static_cast<JSObject*>(cell1) == asObject(src2); 2386 src1 = static_cast<JSObject*>(cell1)->toPrimitive(stackFrame.callFrame); 2387 CHECK_FOR_EXCEPTION(); 2388 goto start; 2389 } 2390 2391 DEFINE_STUB_FUNCTION(bool, op_eq_strings) 2392 { 2393 STUB_INIT_STACK_FRAME(stackFrame); 2394 2395 JSString* string1 = stackFrame.args[0].jsString(); 2396 JSString* string2 = stackFrame.args[1].jsString(); 2397 2398 ASSERT(string1->isString()); 2399 ASSERT(string2->isString()); 2400 return string1->value() == string2->value(); 2401 } 2402 2403 #else // USE(JSVALUE32_64) 2404 2405 DEFINE_STUB_FUNCTION(bool, op_eq) 2406 { 2407 STUB_INIT_STACK_FRAME(stackFrame); 2408 2409 JSValue src1 = stackFrame.args[0].jsValue(); 2410 JSValue src2 = stackFrame.args[1].jsValue(); 2411 2412 CallFrame* callFrame = stackFrame.callFrame; 2413 2414 bool result = JSValue::equalSlowCaseInline(callFrame, src1, src2); 2415 CHECK_FOR_EXCEPTION_AT_END(); 2416 return result; 2417 } 2418 2419 #endif // USE(JSVALUE32_64) 2101 2420 2102 2421 DEFINE_STUB_FUNCTION(EncodedJSValue, op_lshift) … … 2107 2426 JSValue shift = stackFrame.args[1].jsValue(); 2108 2427 2109 int32_t left;2110 uint32_t right;2111 if (JSValue::areBothInt32Fast(val, shift))2112 return JSValue::encode(jsNumber(stackFrame.globalData, val.getInt32Fast() << (shift.getInt32Fast() & 0x1f)));2113 if (val.numberToInt32(left) && shift.numberToUInt32(right))2114 return JSValue::encode(jsNumber(stackFrame.globalData, left << (right & 0x1f)));2115 2116 2428 CallFrame* callFrame = stackFrame.callFrame; 2117 2429 JSValue result = jsNumber(stackFrame.globalData, (val.toInt32(callFrame)) << (shift.toUInt32(callFrame) & 0x1f)); … … 2127 2439 JSValue src2 = stackFrame.args[1].jsValue(); 2128 2440 2129 int32_t left; 2130 int32_t right; 2131 if (src1.numberToInt32(left) && src2.numberToInt32(right)) 2132 return JSValue::encode(jsNumber(stackFrame.globalData, left & right)); 2133 2441 ASSERT(!src1.isInt32() || !src2.isInt32()); 2134 2442 CallFrame* callFrame = stackFrame.callFrame; 2135 2443 JSValue result = jsNumber(stackFrame.globalData, src1.toInt32(callFrame) & src2.toInt32(callFrame)); … … 2145 2453 JSValue shift = stackFrame.args[1].jsValue(); 2146 2454 2147 int32_t left;2148 uint32_t right;2149 if (JSFastMath::canDoFastRshift(val, shift))2150 return JSValue::encode(JSFastMath::rightShiftImmediateNumbers(val, shift));2151 if (val.numberToInt32(left) && shift.numberToUInt32(right))2152 return JSValue::encode(jsNumber(stackFrame.globalData, left >> (right & 0x1f)));2153 2154 2455 CallFrame* callFrame = stackFrame.callFrame; 2155 2456 JSValue result = jsNumber(stackFrame.globalData, (val.toInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f)); 2457 2156 2458 CHECK_FOR_EXCEPTION_AT_END(); 2157 2459 return JSValue::encode(result); … … 2164 2466 JSValue src = stackFrame.args[0].jsValue(); 2165 2467 2166 int value; 2167 if (src.numberToInt32(value)) 2168 return JSValue::encode(jsNumber(stackFrame.globalData, ~value)); 2169 2468 ASSERT(!src.isInt32()); 2170 2469 CallFrame* callFrame = stackFrame.callFrame; 2171 2470 JSValue result = jsNumber(stackFrame.globalData, ~src.toInt32(callFrame)); … … 2241 2540 } 2242 2541 2243 DEFINE_STUB_FUNCTION(EncodedJSValue, op_neq)2244 {2245 STUB_INIT_STACK_FRAME(stackFrame);2246 2247 JSValue src1 = stackFrame.args[0].jsValue();2248 JSValue src2 = stackFrame.args[1].jsValue();2249 2250 ASSERT(!JSValue::areBothInt32Fast(src1, src2));2251 2252 CallFrame* callFrame = stackFrame.callFrame;2253 JSValue result = jsBoolean(!JSValue::equalSlowCaseInline(callFrame, src1, src2));2254 CHECK_FOR_EXCEPTION_AT_END();2255 return JSValue::encode(result);2256 }2257 2258 2542 DEFINE_STUB_FUNCTION(EncodedJSValue, op_post_dec) 2259 2543 { … … 2279 2563 2280 2564 CallFrame* callFrame = stackFrame.callFrame; 2281 2282 if (JSFastMath::canDoFastUrshift(val, shift)) 2283 return JSValue::encode(JSFastMath::rightShiftImmediateNumbers(val, shift)); 2284 else { 2285 JSValue result = jsNumber(stackFrame.globalData, (val.toUInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f)); 2286 CHECK_FOR_EXCEPTION_AT_END(); 2287 return JSValue::encode(result); 2288 } 2565 JSValue result = jsNumber(stackFrame.globalData, (val.toUInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f)); 2566 CHECK_FOR_EXCEPTION_AT_END(); 2567 return JSValue::encode(result); 2289 2568 } 2290 2569 … … 2345 2624 JSValue exceptionValue; 2346 2625 JSValue result = interpreter->callEval(callFrame, registerFile, argv, argCount, registerOffset, exceptionValue); 2347 if (UNLIKELY(exceptionValue != JSValue())) {2626 if (UNLIKELY(exceptionValue)) { 2348 2627 stackFrame.globalData->exception = exceptionValue; 2349 2628 VM_THROW_EXCEPTION_AT_END(); … … 2583 2862 CodeBlock* codeBlock = callFrame->codeBlock(); 2584 2863 2585 if (scrutinee.isInt32 Fast())2586 return codeBlock->immediateSwitchJumpTable(tableIndex).ctiForValue(scrutinee. getInt32Fast()).executableAddress();2864 if (scrutinee.isInt32()) 2865 return codeBlock->immediateSwitchJumpTable(tableIndex).ctiForValue(scrutinee.asInt32()).executableAddress(); 2587 2866 else { 2588 2867 double value; … … 2738 3017 } 2739 3018 2740 } // namespace JITStubs2741 2742 3019 } // namespace JSC 2743 3020
Note:
See TracChangeset
for help on using the changeset viewer.