📄 ic-arm.cc.svn-base
字号:
Code::Flags flags = Code::ComputeFlags(Code::CALL_IC, MONOMORPHIC, NORMAL, argc); StubCache::GenerateProbe(masm, flags, r1, r2, r3); // If the stub cache probing failed, the receiver might be a value. // For value objects, we use the map of the prototype objects for // the corresponding JSValue for the cache and that is what we need // to probe. // // Check for number. __ tst(r1, Operand(kSmiTagMask)); __ b(eq, &number); __ ldr(r3, FieldMemOperand(r1, HeapObject::kMapOffset)); __ ldrb(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset)); __ cmp(r3, Operand(HEAP_NUMBER_TYPE)); __ b(ne, &non_number); __ bind(&number); StubCompiler::GenerateLoadGlobalFunctionPrototype( masm, Context::NUMBER_FUNCTION_INDEX, r1); __ b(&probe); // Check for string. __ bind(&non_number); __ cmp(r3, Operand(FIRST_NONSTRING_TYPE)); __ b(hs, &non_string); StubCompiler::GenerateLoadGlobalFunctionPrototype( masm, Context::STRING_FUNCTION_INDEX, r1); __ b(&probe); // Check for boolean. __ bind(&non_string); __ cmp(r1, Operand(Factory::true_value())); __ b(eq, &boolean); __ cmp(r1, Operand(Factory::false_value())); __ b(ne, &miss); __ bind(&boolean); StubCompiler::GenerateLoadGlobalFunctionPrototype( masm, Context::BOOLEAN_FUNCTION_INDEX, r1); // Probe the stub cache for the value object. __ bind(&probe); StubCache::GenerateProbe(masm, flags, r1, r2, r3); // Cache miss: Jump to runtime. __ bind(&miss); Generate(masm, argc, ExternalReference(IC_Utility(kCallIC_Miss)));}void CallIC::GenerateNormal(MacroAssembler* masm, int argc) { // ----------- S t a t e ------------- // -- lr: return address // ----------------------------------- Label miss, probe, done, global; // Get the receiver of the function from the stack into r1. __ ldr(r1, MemOperand(sp, argc * kPointerSize)); // Get the name of the function from the stack; 1 ~ receiver. __ ldr(r2, MemOperand(sp, (argc + 1) * kPointerSize)); // Check that the receiver isn't a smi. __ tst(r1, Operand(kSmiTagMask)); __ b(eq, &miss); // Check that the receiver is a valid JS object. __ ldr(r0, FieldMemOperand(r1, HeapObject::kMapOffset)); __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); __ cmp(r0, Operand(FIRST_JS_OBJECT_TYPE)); __ b(lt, &miss); // If this assert fails, we have to check upper bound too. ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); // Check for access to global object (unlikely). __ cmp(r0, Operand(JS_GLOBAL_OBJECT_TYPE)); __ b(eq, &global); // Search the dictionary placing the result in r1. __ bind(&probe); GenerateDictionaryLoad(masm, &done, &miss, r0, r1); // Check that the value isn't a smi. __ tst(r1, Operand(kSmiTagMask)); __ b(eq, &miss); // Check that the value is a JSFunction. __ ldr(r0, FieldMemOperand(r1, HeapObject::kMapOffset)); __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); __ cmp(r0, Operand(JS_FUNCTION_TYPE)); __ b(ne, &miss); // Patch the function on the stack; 1 ~ receiver. __ str(r1, MemOperand(sp, (argc + 1) * kPointerSize)); // Invoke the function. ParameterCount actual(argc); __ InvokeFunction(r1, actual, JUMP_FUNCTION); // Global object access: Check access rights. __ bind(&global); __ CheckAccessGlobal(r1, r0, &miss); __ b(&probe); // Cache miss: Jump to runtime. __ bind(&miss); Generate(masm, argc, ExternalReference(IC_Utility(kCallIC_Miss)));}void CallIC::Generate(MacroAssembler* masm, int argc, const ExternalReference& f) { // ----------- S t a t e ------------- // -- lr: return address // ----------------------------------- // Get the receiver of the function from the stack. __ ldr(r2, MemOperand(sp, argc * kPointerSize)); // Get the name of the function to call from the stack. __ ldr(r1, MemOperand(sp, (argc + 1) * kPointerSize)); __ EnterInternalFrame(); // Push the receiver and the name of the function. __ stm(db_w, sp, r1.bit() | r2.bit()); // Call the entry. __ mov(r0, Operand(2)); __ mov(r1, Operand(f)); CEntryStub stub; __ CallStub(&stub); // Move result to r1. __ mov(r1, Operand(r0)); __ LeaveInternalFrame(); // Patch the function on the stack; 1 ~ receiver. __ str(r1, MemOperand(sp, (argc + 1) * kPointerSize)); // Invoke the function. ParameterCount actual(argc); __ InvokeFunction(r1, actual, JUMP_FUNCTION);}// Defined in ic.cc.Object* LoadIC_Miss(Arguments args);void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { // ----------- S t a t e ------------- // -- r2 : name // -- lr : return address // -- [sp] : receiver // ----------------------------------- __ ldr(r0, MemOperand(sp, 0)); // Probe the stub cache. Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, MONOMORPHIC); StubCache::GenerateProbe(masm, flags, r0, r2, r3); // Cache miss: Jump to runtime. Generate(masm, ExternalReference(IC_Utility(kLoadIC_Miss)));}void LoadIC::GenerateNormal(MacroAssembler* masm) { // ----------- S t a t e ------------- // -- r2 : name // -- lr : return address // -- [sp] : receiver // ----------------------------------- Label miss, probe, done, global; __ ldr(r0, MemOperand(sp, 0)); // Check that the receiver isn't a smi. __ tst(r0, Operand(kSmiTagMask)); __ b(eq, &miss); // Check that the receiver is a valid JS object. __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); __ ldrb(r1, FieldMemOperand(r1, Map::kInstanceTypeOffset)); __ cmp(r1, Operand(FIRST_JS_OBJECT_TYPE)); __ b(lt, &miss); // If this assert fails, we have to check upper bound too. ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); // Check for access to global object (unlikely). __ cmp(r1, Operand(JS_GLOBAL_OBJECT_TYPE)); __ b(eq, &global); __ bind(&probe); GenerateDictionaryLoad(masm, &done, &miss, r1, r0); __ Ret(); // Global object access: Check access rights. __ bind(&global); __ CheckAccessGlobal(r0, r1, &miss); __ b(&probe); // Cache miss: Restore receiver from stack and jump to runtime. __ bind(&miss); Generate(masm, ExternalReference(IC_Utility(kLoadIC_Miss)));}void LoadIC::GenerateMiss(MacroAssembler* masm) { Generate(masm, ExternalReference(IC_Utility(kLoadIC_Miss)));}void LoadIC::Generate(MacroAssembler* masm, const ExternalReference& f) { // ----------- S t a t e ------------- // -- r2 : name // -- lr : return address // -- [sp] : receiver // ----------------------------------- __ ldr(r0, MemOperand(sp, 0)); __ push(r0); __ push(r2); // Perform tail call to the entry. __ TailCallRuntime(f, 2);}// TODO(1224671): ICs for keyed load/store is not implemented on ARM.void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) {}void KeyedLoadIC::Generate(MacroAssembler* masm, const ExternalReference& f) {}void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {}void KeyedStoreIC::Generate(MacroAssembler* masm, const ExternalReference& f) {}void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) {}// Defined in ic.cc.Object* StoreIC_Miss(Arguments args);void StoreIC::GenerateMegamorphic(MacroAssembler* masm) { // ----------- S t a t e ------------- // -- r0 : value // -- r2 : name // -- lr : return address // -- [sp] : receiver // ----------------------------------- // Get the receiver from the stack and probe the stub cache. __ ldr(r1, MemOperand(sp)); Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, MONOMORPHIC); StubCache::GenerateProbe(masm, flags, r1, r2, r3); // Cache miss: Jump to runtime. Generate(masm, ExternalReference(IC_Utility(kStoreIC_Miss)));}void StoreIC::Generate(MacroAssembler* masm, const ExternalReference& f) { // ----------- S t a t e ------------- // -- r0 : value // -- r2 : name // -- lr : return address // -- [sp] : receiver // ----------------------------------- __ ldr(r3, MemOperand(sp)); // copy receiver __ stm(db_w, sp, r0.bit() | r2.bit() | r3.bit()); // Perform tail call to the entry. __ TailCallRuntime(f, 3);}#undef __} } // namespace v8::internal
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -