43
50
#include <wtf/AlwaysInline.h>
44
51
#include <wtf/Vector.h>
47
#define STUB_ARGS_offset 0x10
49
#define STUB_ARGS_offset 0x0C
52
#define STUB_ARGS_code (STUB_ARGS_offset)
53
#define STUB_ARGS_registerFile (STUB_ARGS_offset + 1)
54
#define STUB_ARGS_callFrame (STUB_ARGS_offset + 2)
55
#define STUB_ARGS_exception (STUB_ARGS_offset + 3)
56
#define STUB_ARGS_profilerReference (STUB_ARGS_offset + 4)
57
#define STUB_ARGS_globalData (STUB_ARGS_offset + 5)
59
#define ARG_callFrame static_cast<CallFrame*>(ARGS[STUB_ARGS_callFrame])
60
#define ARG_registerFile static_cast<RegisterFile*>(ARGS[STUB_ARGS_registerFile])
61
#define ARG_exception static_cast<JSValuePtr*>(ARGS[STUB_ARGS_exception])
62
#define ARG_profilerReference static_cast<Profiler**>(ARGS[STUB_ARGS_profilerReference])
63
#define ARG_globalData static_cast<JSGlobalData*>(ARGS[STUB_ARGS_globalData])
65
#define ARG_setCallFrame(newCallFrame) (ARGS[STUB_ARGS_callFrame] = (newCallFrame))
67
#define ARG_src1 JSValuePtr::decode(static_cast<JSValueEncodedAsPointer*>(ARGS[1]))
68
#define ARG_src2 JSValuePtr::decode(static_cast<JSValueEncodedAsPointer*>(ARGS[2]))
69
#define ARG_src3 JSValuePtr::decode(static_cast<JSValueEncodedAsPointer*>(ARGS[3]))
70
#define ARG_src4 JSValuePtr::decode(static_cast<JSValueEncodedAsPointer*>(ARGS[4]))
71
#define ARG_src5 JSValuePtr::decode(static_cast<JSValueEncodedAsPointer*>(ARGS[5]))
72
#define ARG_id1 static_cast<Identifier*>(ARGS[1])
73
#define ARG_id2 static_cast<Identifier*>(ARGS[2])
74
#define ARG_id3 static_cast<Identifier*>(ARGS[3])
75
#define ARG_id4 static_cast<Identifier*>(ARGS[4])
76
#define ARG_int1 static_cast<int32_t>(reinterpret_cast<intptr_t>(ARGS[1]))
77
#define ARG_int2 static_cast<int32_t>(reinterpret_cast<intptr_t>(ARGS[2]))
78
#define ARG_int3 static_cast<int32_t>(reinterpret_cast<intptr_t>(ARGS[3]))
79
#define ARG_int4 static_cast<int32_t>(reinterpret_cast<intptr_t>(ARGS[4]))
80
#define ARG_int5 static_cast<int32_t>(reinterpret_cast<intptr_t>(ARGS[5]))
81
#define ARG_int6 static_cast<int32_t>(reinterpret_cast<intptr_t>(ARGS[6]))
82
#define ARG_func1 static_cast<FuncDeclNode*>(ARGS[1])
83
#define ARG_funcexp1 static_cast<FuncExprNode*>(ARGS[1])
84
#define ARG_regexp1 static_cast<RegExp*>(ARGS[1])
85
#define ARG_pni1 static_cast<JSPropertyNameIterator*>(ARGS[1])
86
#define ARG_returnAddress2 static_cast<void*>(ARGS[2])
87
#define ARG_codeBlock4 static_cast<CodeBlock*>(ARGS[4])
89
#define STUB_RETURN_ADDRESS_SLOT (ARGS[-1])
94
57
class JSPropertyNameIterator;
383
333
static void unlinkCall(CallLinkInfo*);
337
DataLabelPtr storeLocation;
340
JSRInfo(DataLabelPtr storeLocation, Label targetLocation)
341
: storeLocation(storeLocation)
342
, target(targetLocation)
386
347
JIT(JSGlobalData*, CodeBlock* = 0);
388
349
void privateCompileMainPass();
389
350
void privateCompileLinkPass();
390
351
void privateCompileSlowCases();
391
352
void privateCompile();
392
void privateCompileGetByIdSelf(StructureStubInfo*, Structure*, size_t cachedOffset, ProcessorReturnAddress returnAddress);
393
353
void privateCompileGetByIdProto(StructureStubInfo*, Structure*, Structure* prototypeStructure, size_t cachedOffset, ProcessorReturnAddress returnAddress, CallFrame* callFrame);
394
#if USE(CTI_REPATCH_PIC)
395
354
void privateCompileGetByIdSelfList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, size_t cachedOffset);
396
355
void privateCompileGetByIdProtoList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, Structure* prototypeStructure, size_t cachedOffset, CallFrame* callFrame);
397
356
void privateCompileGetByIdChainList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, StructureChain* chain, size_t count, size_t cachedOffset, CallFrame* callFrame);
399
357
void privateCompileGetByIdChain(StructureStubInfo*, Structure*, StructureChain*, size_t count, size_t cachedOffset, ProcessorReturnAddress returnAddress, CallFrame* callFrame);
400
void privateCompilePutByIdReplace(StructureStubInfo*, Structure*, size_t cachedOffset, ProcessorReturnAddress returnAddress);
401
358
void privateCompilePutByIdTransition(StructureStubInfo*, Structure*, Structure*, size_t cachedOffset, StructureChain*, ProcessorReturnAddress returnAddress);
403
void privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executablePool, void** ctiArrayLengthTrampoline, void** ctiStringLengthTrampoline, void** ctiVirtualCallPreLink, void** ctiVirtualCallLink, void** ctiVirtualCall);
360
void privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executablePool, JSGlobalData* data, void** ctiArrayLengthTrampoline, void** ctiStringLengthTrampoline, void** ctiVirtualCallPreLink, void** ctiVirtualCallLink, void** ctiVirtualCall, void** ctiNativeCallThunk);
404
361
void privateCompilePatchGetArrayLength(ProcessorReturnAddress returnAddress);
406
363
void addSlowCase(Jump);
416
373
void compileOpCallInitializeCallFrame();
417
374
void compileOpCallSetupArgs(Instruction*);
418
375
void compileOpCallVarargsSetupArgs(Instruction*);
419
void compileOpCallEvalSetupArgs(Instruction*);
420
376
void compileOpCallSlowCase(Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter, unsigned callLinkInfoIndex, OpcodeID opcodeID);
421
377
void compileOpCallVarargsSlowCase(Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter);
422
378
void compileOpConstructSetupArgs(Instruction*);
423
379
enum CompileOpStrictEqType { OpStrictEq, OpNStrictEq };
424
380
void compileOpStrictEq(Instruction* instruction, CompileOpStrictEqType type);
426
void compileFastArith_op_add(Instruction*);
427
void compileFastArith_op_sub(Instruction*);
428
void compileFastArith_op_mul(Instruction*);
429
void compileFastArith_op_mod(unsigned result, unsigned op1, unsigned op2);
430
void compileFastArith_op_bitand(unsigned result, unsigned op1, unsigned op2);
431
void compileFastArith_op_lshift(unsigned result, unsigned op1, unsigned op2);
432
void compileFastArith_op_rshift(unsigned result, unsigned op1, unsigned op2);
433
void compileFastArith_op_pre_inc(unsigned srcDst);
434
void compileFastArith_op_pre_dec(unsigned srcDst);
435
void compileFastArith_op_post_inc(unsigned result, unsigned srcDst);
436
void compileFastArith_op_post_dec(unsigned result, unsigned srcDst);
437
void compileFastArithSlow_op_add(Instruction*, Vector<SlowCaseEntry>::iterator&);
438
void compileFastArithSlow_op_sub(Instruction*, Vector<SlowCaseEntry>::iterator&);
439
void compileFastArithSlow_op_mul(Instruction*, Vector<SlowCaseEntry>::iterator&);
440
void compileFastArithSlow_op_mod(unsigned result, unsigned op1, unsigned op2, Vector<SlowCaseEntry>::iterator&);
441
void compileFastArithSlow_op_bitand(unsigned result, unsigned op1, unsigned op2, Vector<SlowCaseEntry>::iterator&);
442
void compileFastArithSlow_op_lshift(unsigned result, unsigned op1, unsigned op2, Vector<SlowCaseEntry>::iterator&);
443
void compileFastArithSlow_op_rshift(unsigned result, unsigned op1, unsigned op2, Vector<SlowCaseEntry>::iterator&);
444
void compileFastArithSlow_op_pre_inc(unsigned srcDst, Vector<SlowCaseEntry>::iterator&);
445
void compileFastArithSlow_op_pre_dec(unsigned srcDst, Vector<SlowCaseEntry>::iterator&);
446
void compileFastArithSlow_op_post_inc(unsigned result, unsigned srcDst, Vector<SlowCaseEntry>::iterator&);
447
void compileFastArithSlow_op_post_dec(unsigned result, unsigned srcDst, Vector<SlowCaseEntry>::iterator&);
382
void compileGetDirectOffset(RegisterID base, RegisterID result, Structure* structure, size_t cachedOffset);
383
void compileGetDirectOffset(JSObject* base, RegisterID temp, RegisterID result, size_t cachedOffset);
384
void compilePutDirectOffset(RegisterID base, RegisterID value, Structure* structure, size_t cachedOffset);
388
void emit_op_add(Instruction*);
389
void emit_op_sub(Instruction*);
390
void emit_op_mul(Instruction*);
391
void emit_op_mod(Instruction*);
392
void emit_op_bitand(Instruction*);
393
void emit_op_lshift(Instruction*);
394
void emit_op_rshift(Instruction*);
395
void emit_op_jnless(Instruction*);
396
void emit_op_jnlesseq(Instruction*);
397
void emit_op_pre_inc(Instruction*);
398
void emit_op_pre_dec(Instruction*);
399
void emit_op_post_inc(Instruction*);
400
void emit_op_post_dec(Instruction*);
401
void emitSlow_op_add(Instruction*, Vector<SlowCaseEntry>::iterator&);
402
void emitSlow_op_sub(Instruction*, Vector<SlowCaseEntry>::iterator&);
403
void emitSlow_op_mul(Instruction*, Vector<SlowCaseEntry>::iterator&);
404
void emitSlow_op_mod(Instruction*, Vector<SlowCaseEntry>::iterator&);
405
void emitSlow_op_bitand(Instruction*, Vector<SlowCaseEntry>::iterator&);
406
void emitSlow_op_lshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
407
void emitSlow_op_rshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
408
void emitSlow_op_jnless(Instruction*, Vector<SlowCaseEntry>::iterator&);
409
void emitSlow_op_jnlesseq(Instruction*, Vector<SlowCaseEntry>::iterator&);
410
void emitSlow_op_pre_inc(Instruction*, Vector<SlowCaseEntry>::iterator&);
411
void emitSlow_op_pre_dec(Instruction*, Vector<SlowCaseEntry>::iterator&);
412
void emitSlow_op_post_inc(Instruction*, Vector<SlowCaseEntry>::iterator&);
413
void emitSlow_op_post_dec(Instruction*, Vector<SlowCaseEntry>::iterator&);
415
void emit_op_get_by_val(Instruction*);
416
void emit_op_put_by_val(Instruction*);
417
void emit_op_put_by_index(Instruction*);
418
void emit_op_put_getter(Instruction*);
419
void emit_op_put_setter(Instruction*);
420
void emit_op_del_by_id(Instruction*);
422
void emit_op_mov(Instruction*);
423
void emit_op_end(Instruction*);
424
void emit_op_jmp(Instruction*);
425
void emit_op_loop(Instruction*);
426
void emit_op_loop_if_less(Instruction*);
427
void emit_op_loop_if_lesseq(Instruction*);
428
void emit_op_new_object(Instruction*);
429
void emit_op_put_by_id(Instruction*);
430
void emit_op_get_by_id(Instruction*);
431
void emit_op_instanceof(Instruction*);
432
void emit_op_new_func(Instruction*);
433
void emit_op_call(Instruction*);
434
void emit_op_call_eval(Instruction*);
435
void emit_op_load_varargs(Instruction*);
436
void emit_op_call_varargs(Instruction*);
437
void emit_op_construct(Instruction*);
438
void emit_op_get_global_var(Instruction*);
439
void emit_op_put_global_var(Instruction*);
440
void emit_op_get_scoped_var(Instruction*);
441
void emit_op_put_scoped_var(Instruction*);
442
void emit_op_tear_off_activation(Instruction*);
443
void emit_op_tear_off_arguments(Instruction*);
444
void emit_op_ret(Instruction*);
445
void emit_op_new_array(Instruction*);
446
void emit_op_resolve(Instruction*);
447
void emit_op_construct_verify(Instruction*);
448
void emit_op_to_primitive(Instruction*);
449
void emit_op_strcat(Instruction*);
450
void emit_op_resolve_func(Instruction*);
451
void emit_op_loop_if_true(Instruction*);
452
void emit_op_resolve_base(Instruction*);
453
void emit_op_resolve_skip(Instruction*);
454
void emit_op_resolve_global(Instruction*);
455
void emit_op_not(Instruction*);
456
void emit_op_jfalse(Instruction*);
457
void emit_op_jeq_null(Instruction*);
458
void emit_op_jneq_null(Instruction*);
459
void emit_op_jneq_ptr(Instruction*);
460
void emit_op_unexpected_load(Instruction*);
461
void emit_op_jsr(Instruction*);
462
void emit_op_sret(Instruction*);
463
void emit_op_eq(Instruction*);
464
void emit_op_bitnot(Instruction*);
465
void emit_op_resolve_with_base(Instruction*);
466
void emit_op_new_func_exp(Instruction*);
467
void emit_op_jtrue(Instruction*);
468
void emit_op_neq(Instruction*);
469
void emit_op_bitxor(Instruction*);
470
void emit_op_new_regexp(Instruction*);
471
void emit_op_bitor(Instruction*);
472
void emit_op_throw(Instruction*);
473
void emit_op_next_pname(Instruction*);
474
void emit_op_push_scope(Instruction*);
475
void emit_op_pop_scope(Instruction*);
476
void emit_op_stricteq(Instruction*);
477
void emit_op_nstricteq(Instruction*);
478
void emit_op_to_jsnumber(Instruction*);
479
void emit_op_push_new_scope(Instruction*);
480
void emit_op_catch(Instruction*);
481
void emit_op_jmp_scopes(Instruction*);
482
void emit_op_switch_imm(Instruction*);
483
void emit_op_switch_char(Instruction*);
484
void emit_op_switch_string(Instruction*);
485
void emit_op_new_error(Instruction*);
486
void emit_op_debug(Instruction*);
487
void emit_op_eq_null(Instruction*);
488
void emit_op_neq_null(Instruction*);
489
void emit_op_enter(Instruction*);
490
void emit_op_enter_with_activation(Instruction*);
491
void emit_op_init_arguments(Instruction*);
492
void emit_op_create_arguments(Instruction*);
493
void emit_op_convert_this(Instruction*);
494
void emit_op_profile_will_call(Instruction*);
495
void emit_op_profile_did_call(Instruction*);
497
void emitSlow_op_convert_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
498
void emitSlow_op_construct_verify(Instruction*, Vector<SlowCaseEntry>::iterator&);
499
void emitSlow_op_to_primitive(Instruction*, Vector<SlowCaseEntry>::iterator&);
500
void emitSlow_op_get_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
501
void emitSlow_op_loop_if_less(Instruction*, Vector<SlowCaseEntry>::iterator&);
502
void emitSlow_op_put_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
503
void emitSlow_op_get_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
504
void emitSlow_op_loop_if_lesseq(Instruction*, Vector<SlowCaseEntry>::iterator&);
505
void emitSlow_op_put_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
506
void emitSlow_op_loop_if_true(Instruction*, Vector<SlowCaseEntry>::iterator&);
507
void emitSlow_op_not(Instruction*, Vector<SlowCaseEntry>::iterator&);
508
void emitSlow_op_jfalse(Instruction*, Vector<SlowCaseEntry>::iterator&);
509
void emitSlow_op_bitnot(Instruction*, Vector<SlowCaseEntry>::iterator&);
510
void emitSlow_op_jtrue(Instruction*, Vector<SlowCaseEntry>::iterator&);
511
void emitSlow_op_bitxor(Instruction*, Vector<SlowCaseEntry>::iterator&);
512
void emitSlow_op_bitor(Instruction*, Vector<SlowCaseEntry>::iterator&);
513
void emitSlow_op_eq(Instruction*, Vector<SlowCaseEntry>::iterator&);
514
void emitSlow_op_neq(Instruction*, Vector<SlowCaseEntry>::iterator&);
515
void emitSlow_op_stricteq(Instruction*, Vector<SlowCaseEntry>::iterator&);
516
void emitSlow_op_nstricteq(Instruction*, Vector<SlowCaseEntry>::iterator&);
517
void emitSlow_op_instanceof(Instruction*, Vector<SlowCaseEntry>::iterator&);
518
void emitSlow_op_call(Instruction*, Vector<SlowCaseEntry>::iterator&);
519
void emitSlow_op_call_eval(Instruction*, Vector<SlowCaseEntry>::iterator&);
520
void emitSlow_op_call_varargs(Instruction*, Vector<SlowCaseEntry>::iterator&);
521
void emitSlow_op_construct(Instruction*, Vector<SlowCaseEntry>::iterator&);
522
void emitSlow_op_to_jsnumber(Instruction*, Vector<SlowCaseEntry>::iterator&);
448
524
#if ENABLE(JIT_OPTIMIZE_ARITHMETIC)
449
525
void compileBinaryArithOp(OpcodeID, unsigned dst, unsigned src1, unsigned src2, OperandTypes opi);
450
526
void compileBinaryArithOpSlowCase(OpcodeID, Vector<SlowCaseEntry>::iterator&, unsigned dst, unsigned src1, unsigned src2, OperandTypes opi);