| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 #if defined(V8_TARGET_ARCH_IA32) | 30 #if defined(V8_TARGET_ARCH_IA32) |
| 31 | 31 |
| 32 #include "code-stubs.h" | 32 #include "code-stubs.h" |
| 33 #include "codegen-inl.h" | 33 #include "codegen-inl.h" |
| 34 #include "compiler.h" | 34 #include "compiler.h" |
| 35 #include "debug.h" | 35 #include "debug.h" |
| 36 #include "full-codegen.h" | 36 #include "full-codegen.h" |
| 37 #include "parser.h" | 37 #include "parser.h" |
| 38 #include "scopes.h" | 38 #include "scopes.h" |
| 39 #include "stub-cache.h" |
| 39 | 40 |
| 40 namespace v8 { | 41 namespace v8 { |
| 41 namespace internal { | 42 namespace internal { |
| 42 | 43 |
| 43 #define __ ACCESS_MASM(masm_) | 44 #define __ ACCESS_MASM(masm_) |
| 44 | 45 |
| 45 // Generate code for a JS function. On entry to the function the receiver | 46 // Generate code for a JS function. On entry to the function the receiver |
| 46 // and arguments have been pushed on the stack left to right, with the | 47 // and arguments have been pushed on the stack left to right, with the |
| 47 // return address on top of them. The actual argument count matches the | 48 // return address on top of them. The actual argument count matches the |
| 48 // formal parameter count expected by the function. | 49 // formal parameter count expected by the function. |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 __ j(not_equal, slow); | 948 __ j(not_equal, slow); |
| 948 // Load next context in chain. | 949 // Load next context in chain. |
| 949 __ mov(temp, ContextOperand(temp, Context::CLOSURE_INDEX)); | 950 __ mov(temp, ContextOperand(temp, Context::CLOSURE_INDEX)); |
| 950 __ mov(temp, FieldOperand(temp, JSFunction::kContextOffset)); | 951 __ mov(temp, FieldOperand(temp, JSFunction::kContextOffset)); |
| 951 __ jmp(&next); | 952 __ jmp(&next); |
| 952 __ bind(&fast); | 953 __ bind(&fast); |
| 953 } | 954 } |
| 954 | 955 |
| 955 // All extension objects were empty and it is safe to use a global | 956 // All extension objects were empty and it is safe to use a global |
| 956 // load IC call. | 957 // load IC call. |
| 957 __ mov(eax, CodeGenerator::GlobalObject()); | 958 __ mov(eax, GlobalObjectOperand()); |
| 958 __ mov(ecx, slot->var()->name()); | 959 __ mov(ecx, slot->var()->name()); |
| 959 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | 960 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); |
| 960 RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF) | 961 RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF) |
| 961 ? RelocInfo::CODE_TARGET | 962 ? RelocInfo::CODE_TARGET |
| 962 : RelocInfo::CODE_TARGET_CONTEXT; | 963 : RelocInfo::CODE_TARGET_CONTEXT; |
| 963 EmitCallIC(ic, mode); | 964 EmitCallIC(ic, mode); |
| 964 } | 965 } |
| 965 | 966 |
| 966 | 967 |
| 967 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions( | 968 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 // Four cases: non-this global variables, lookup slots, all other | 1051 // Four cases: non-this global variables, lookup slots, all other |
| 1051 // types of slots, and parameters that rewrite to explicit property | 1052 // types of slots, and parameters that rewrite to explicit property |
| 1052 // accesses on the arguments object. | 1053 // accesses on the arguments object. |
| 1053 Slot* slot = var->AsSlot(); | 1054 Slot* slot = var->AsSlot(); |
| 1054 Property* property = var->AsProperty(); | 1055 Property* property = var->AsProperty(); |
| 1055 | 1056 |
| 1056 if (var->is_global() && !var->is_this()) { | 1057 if (var->is_global() && !var->is_this()) { |
| 1057 Comment cmnt(masm_, "Global variable"); | 1058 Comment cmnt(masm_, "Global variable"); |
| 1058 // Use inline caching. Variable name is passed in ecx and the global | 1059 // Use inline caching. Variable name is passed in ecx and the global |
| 1059 // object on the stack. | 1060 // object on the stack. |
| 1060 __ mov(eax, CodeGenerator::GlobalObject()); | 1061 __ mov(eax, GlobalObjectOperand()); |
| 1061 __ mov(ecx, var->name()); | 1062 __ mov(ecx, var->name()); |
| 1062 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | 1063 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); |
| 1063 EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT); | 1064 EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT); |
| 1064 context()->Plug(eax); | 1065 context()->Plug(eax); |
| 1065 | 1066 |
| 1066 } else if (slot != NULL && slot->type() == Slot::LOOKUP) { | 1067 } else if (slot != NULL && slot->type() == Slot::LOOKUP) { |
| 1067 Label done, slow; | 1068 Label done, slow; |
| 1068 | 1069 |
| 1069 // Generate code for loading from variables potentially shadowed | 1070 // Generate code for loading from variables potentially shadowed |
| 1070 // by eval-introduced variables. | 1071 // by eval-introduced variables. |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 // here. | 1828 // here. |
| 1828 ASSERT(var != NULL); | 1829 ASSERT(var != NULL); |
| 1829 ASSERT(var->is_global() || var->AsSlot() != NULL); | 1830 ASSERT(var->is_global() || var->AsSlot() != NULL); |
| 1830 | 1831 |
| 1831 if (var->is_global()) { | 1832 if (var->is_global()) { |
| 1832 ASSERT(!var->is_this()); | 1833 ASSERT(!var->is_this()); |
| 1833 // Assignment to a global variable. Use inline caching for the | 1834 // Assignment to a global variable. Use inline caching for the |
| 1834 // assignment. Right-hand-side value is passed in eax, variable name in | 1835 // assignment. Right-hand-side value is passed in eax, variable name in |
| 1835 // ecx, and the global object on the stack. | 1836 // ecx, and the global object on the stack. |
| 1836 __ mov(ecx, var->name()); | 1837 __ mov(ecx, var->name()); |
| 1837 __ mov(edx, CodeGenerator::GlobalObject()); | 1838 __ mov(edx, GlobalObjectOperand()); |
| 1838 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 1839 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); |
| 1839 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 1840 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
| 1840 | 1841 |
| 1841 } else if (var->mode() != Variable::CONST || op == Token::INIT_CONST) { | 1842 } else if (var->mode() != Variable::CONST || op == Token::INIT_CONST) { |
| 1842 // Perform the assignment for non-const variables and for initialization | 1843 // Perform the assignment for non-const variables and for initialization |
| 1843 // of const variables. Const assignments are simply skipped. | 1844 // of const variables. Const assignments are simply skipped. |
| 1844 Label done; | 1845 Label done; |
| 1845 Slot* slot = var->AsSlot(); | 1846 Slot* slot = var->AsSlot(); |
| 1846 switch (slot->type()) { | 1847 switch (slot->type()) { |
| 1847 case Slot::PARAMETER: | 1848 case Slot::PARAMETER: |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1998 int arg_count = args->length(); | 1999 int arg_count = args->length(); |
| 1999 { PreserveStatementPositionScope scope(masm()->positions_recorder()); | 2000 { PreserveStatementPositionScope scope(masm()->positions_recorder()); |
| 2000 for (int i = 0; i < arg_count; i++) { | 2001 for (int i = 0; i < arg_count; i++) { |
| 2001 VisitForStackValue(args->at(i)); | 2002 VisitForStackValue(args->at(i)); |
| 2002 } | 2003 } |
| 2003 __ Set(ecx, Immediate(name)); | 2004 __ Set(ecx, Immediate(name)); |
| 2004 } | 2005 } |
| 2005 // Record source position of the IC call. | 2006 // Record source position of the IC call. |
| 2006 SetSourcePosition(expr->position(), FORCED_POSITION); | 2007 SetSourcePosition(expr->position(), FORCED_POSITION); |
| 2007 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; | 2008 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
| 2008 Handle<Code> ic = CodeGenerator::ComputeCallInitialize(arg_count, in_loop); | 2009 Handle<Code> ic = StubCache::ComputeCallInitialize(arg_count, in_loop); |
| 2009 EmitCallIC(ic, mode); | 2010 EmitCallIC(ic, mode); |
| 2010 // Restore context register. | 2011 // Restore context register. |
| 2011 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2012 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 2012 context()->Plug(eax); | 2013 context()->Plug(eax); |
| 2013 } | 2014 } |
| 2014 | 2015 |
| 2015 | 2016 |
| 2016 void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, | 2017 void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, |
| 2017 Expression* key, | 2018 Expression* key, |
| 2018 RelocInfo::Mode mode) { | 2019 RelocInfo::Mode mode) { |
| 2019 // Code common for calls using the IC. | 2020 // Load the key. |
| 2021 VisitForAccumulatorValue(key); |
| 2022 |
| 2023 // Swap the name of the function and the receiver on the stack to follow |
| 2024 // the calling convention for call ICs. |
| 2025 __ pop(ecx); |
| 2026 __ push(eax); |
| 2027 __ push(ecx); |
| 2028 |
| 2029 // Load the arguments. |
| 2020 ZoneList<Expression*>* args = expr->arguments(); | 2030 ZoneList<Expression*>* args = expr->arguments(); |
| 2021 int arg_count = args->length(); | 2031 int arg_count = args->length(); |
| 2022 { PreserveStatementPositionScope scope(masm()->positions_recorder()); | 2032 { PreserveStatementPositionScope scope(masm()->positions_recorder()); |
| 2023 for (int i = 0; i < arg_count; i++) { | 2033 for (int i = 0; i < arg_count; i++) { |
| 2024 VisitForStackValue(args->at(i)); | 2034 VisitForStackValue(args->at(i)); |
| 2025 } | 2035 } |
| 2026 VisitForAccumulatorValue(key); | |
| 2027 __ mov(ecx, eax); | |
| 2028 } | 2036 } |
| 2029 // Record source position of the IC call. | 2037 // Record source position of the IC call. |
| 2030 SetSourcePosition(expr->position(), FORCED_POSITION); | 2038 SetSourcePosition(expr->position(), FORCED_POSITION); |
| 2031 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; | 2039 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
| 2032 Handle<Code> ic = CodeGenerator::ComputeKeyedCallInitialize( | 2040 Handle<Code> ic = StubCache::ComputeKeyedCallInitialize(arg_count, in_loop); |
| 2033 arg_count, in_loop); | 2041 __ mov(ecx, Operand(esp, (arg_count + 1) * kPointerSize)); // Key. |
| 2034 EmitCallIC(ic, mode); | 2042 EmitCallIC(ic, mode); |
| 2035 // Restore context register. | 2043 // Restore context register. |
| 2036 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2044 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 2037 context()->Plug(eax); | 2045 context()->DropAndPlug(1, eax); // Drop the key still on the stack. |
| 2038 } | 2046 } |
| 2039 | 2047 |
| 2040 | 2048 |
| 2041 void FullCodeGenerator::EmitCallWithStub(Call* expr) { | 2049 void FullCodeGenerator::EmitCallWithStub(Call* expr) { |
| 2042 // Code common for calls using the call stub. | 2050 // Code common for calls using the call stub. |
| 2043 ZoneList<Expression*>* args = expr->arguments(); | 2051 ZoneList<Expression*>* args = expr->arguments(); |
| 2044 int arg_count = args->length(); | 2052 int arg_count = args->length(); |
| 2045 { PreserveStatementPositionScope scope(masm()->positions_recorder()); | 2053 { PreserveStatementPositionScope scope(masm()->positions_recorder()); |
| 2046 for (int i = 0; i < arg_count; i++) { | 2054 for (int i = 0; i < arg_count; i++) { |
| 2047 VisitForStackValue(args->at(i)); | 2055 VisitForStackValue(args->at(i)); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 // Record source position for debugger. | 2110 // Record source position for debugger. |
| 2103 SetSourcePosition(expr->position(), FORCED_POSITION); | 2111 SetSourcePosition(expr->position(), FORCED_POSITION); |
| 2104 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; | 2112 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
| 2105 CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_VALUE); | 2113 CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_VALUE); |
| 2106 __ CallStub(&stub); | 2114 __ CallStub(&stub); |
| 2107 // Restore context register. | 2115 // Restore context register. |
| 2108 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2116 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 2109 context()->DropAndPlug(1, eax); | 2117 context()->DropAndPlug(1, eax); |
| 2110 } else if (var != NULL && !var->is_this() && var->is_global()) { | 2118 } else if (var != NULL && !var->is_this() && var->is_global()) { |
| 2111 // Push global object as receiver for the call IC. | 2119 // Push global object as receiver for the call IC. |
| 2112 __ push(CodeGenerator::GlobalObject()); | 2120 __ push(GlobalObjectOperand()); |
| 2113 EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT); | 2121 EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT); |
| 2114 } else if (var != NULL && var->AsSlot() != NULL && | 2122 } else if (var != NULL && var->AsSlot() != NULL && |
| 2115 var->AsSlot()->type() == Slot::LOOKUP) { | 2123 var->AsSlot()->type() == Slot::LOOKUP) { |
| 2116 // Call to a lookup slot (dynamically introduced variable). | 2124 // Call to a lookup slot (dynamically introduced variable). |
| 2117 Label slow, done; | 2125 Label slow, done; |
| 2118 | 2126 |
| 2119 { PreserveStatementPositionScope scope(masm()->positions_recorder()); | 2127 { PreserveStatementPositionScope scope(masm()->positions_recorder()); |
| 2120 // Generate code for loading from variables potentially shadowed | 2128 // Generate code for loading from variables potentially shadowed |
| 2121 // by eval-introduced variables. | 2129 // by eval-introduced variables. |
| 2122 EmitDynamicLoadFromSlotFastCase(var->AsSlot(), | 2130 EmitDynamicLoadFromSlotFastCase(var->AsSlot(), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2137 // If fast case code has been generated, emit code to push the | 2145 // If fast case code has been generated, emit code to push the |
| 2138 // function and receiver and have the slow path jump around this | 2146 // function and receiver and have the slow path jump around this |
| 2139 // code. | 2147 // code. |
| 2140 if (done.is_linked()) { | 2148 if (done.is_linked()) { |
| 2141 Label call; | 2149 Label call; |
| 2142 __ jmp(&call); | 2150 __ jmp(&call); |
| 2143 __ bind(&done); | 2151 __ bind(&done); |
| 2144 // Push function. | 2152 // Push function. |
| 2145 __ push(eax); | 2153 __ push(eax); |
| 2146 // Push global receiver. | 2154 // Push global receiver. |
| 2147 __ mov(ebx, CodeGenerator::GlobalObject()); | 2155 __ mov(ebx, GlobalObjectOperand()); |
| 2148 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); | 2156 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); |
| 2149 __ bind(&call); | 2157 __ bind(&call); |
| 2150 } | 2158 } |
| 2151 | 2159 |
| 2152 EmitCallWithStub(expr); | 2160 EmitCallWithStub(expr); |
| 2153 } else if (fun->AsProperty() != NULL) { | 2161 } else if (fun->AsProperty() != NULL) { |
| 2154 // Call to an object property. | 2162 // Call to an object property. |
| 2155 Property* prop = fun->AsProperty(); | 2163 Property* prop = fun->AsProperty(); |
| 2156 Literal* key = prop->key()->AsLiteral(); | 2164 Literal* key = prop->key()->AsLiteral(); |
| 2157 if (key != NULL && key->handle()->IsSymbol()) { | 2165 if (key != NULL && key->handle()->IsSymbol()) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2171 } | 2179 } |
| 2172 // Record source code position for IC call. | 2180 // Record source code position for IC call. |
| 2173 SetSourcePosition(prop->position(), FORCED_POSITION); | 2181 SetSourcePosition(prop->position(), FORCED_POSITION); |
| 2174 __ pop(edx); // We do not need to keep the receiver. | 2182 __ pop(edx); // We do not need to keep the receiver. |
| 2175 | 2183 |
| 2176 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); | 2184 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); |
| 2177 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 2185 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
| 2178 // Push result (function). | 2186 // Push result (function). |
| 2179 __ push(eax); | 2187 __ push(eax); |
| 2180 // Push Global receiver. | 2188 // Push Global receiver. |
| 2181 __ mov(ecx, CodeGenerator::GlobalObject()); | 2189 __ mov(ecx, GlobalObjectOperand()); |
| 2182 __ push(FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset)); | 2190 __ push(FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset)); |
| 2183 EmitCallWithStub(expr); | 2191 EmitCallWithStub(expr); |
| 2184 } else { | 2192 } else { |
| 2185 EmitKeyedCallWithIC(expr, prop->key(), RelocInfo::CODE_TARGET); | 2193 EmitKeyedCallWithIC(expr, prop->key(), RelocInfo::CODE_TARGET); |
| 2186 } | 2194 } |
| 2187 } | 2195 } |
| 2188 } else { | 2196 } else { |
| 2189 // Call to some other expression. If the expression is an anonymous | 2197 // Call to some other expression. If the expression is an anonymous |
| 2190 // function literal not called in a loop, mark it as one that should | 2198 // function literal not called in a loop, mark it as one that should |
| 2191 // also use the full code generator. | 2199 // also use the full code generator. |
| 2192 FunctionLiteral* lit = fun->AsFunctionLiteral(); | 2200 FunctionLiteral* lit = fun->AsFunctionLiteral(); |
| 2193 if (lit != NULL && | 2201 if (lit != NULL && |
| 2194 lit->name()->Equals(Heap::empty_string()) && | 2202 lit->name()->Equals(Heap::empty_string()) && |
| 2195 loop_depth() == 0) { | 2203 loop_depth() == 0) { |
| 2196 lit->set_try_full_codegen(true); | 2204 lit->set_try_full_codegen(true); |
| 2197 } | 2205 } |
| 2198 { PreserveStatementPositionScope scope(masm()->positions_recorder()); | 2206 { PreserveStatementPositionScope scope(masm()->positions_recorder()); |
| 2199 VisitForStackValue(fun); | 2207 VisitForStackValue(fun); |
| 2200 } | 2208 } |
| 2201 // Load global receiver object. | 2209 // Load global receiver object. |
| 2202 __ mov(ebx, CodeGenerator::GlobalObject()); | 2210 __ mov(ebx, GlobalObjectOperand()); |
| 2203 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); | 2211 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); |
| 2204 // Emit function call. | 2212 // Emit function call. |
| 2205 EmitCallWithStub(expr); | 2213 EmitCallWithStub(expr); |
| 2206 } | 2214 } |
| 2207 } | 2215 } |
| 2208 | 2216 |
| 2209 | 2217 |
| 2210 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 2218 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
| 2211 Comment cmnt(masm_, "[ CallNew"); | 2219 Comment cmnt(masm_, "[ CallNew"); |
| 2212 // According to ECMA-262, section 11.2.2, page 44, the function | 2220 // According to ECMA-262, section 11.2.2, page 44, the function |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3082 Comment cmnt(masm_, "[ InlineRuntimeCall"); | 3090 Comment cmnt(masm_, "[ InlineRuntimeCall"); |
| 3083 EmitInlineRuntimeCall(expr); | 3091 EmitInlineRuntimeCall(expr); |
| 3084 return; | 3092 return; |
| 3085 } | 3093 } |
| 3086 | 3094 |
| 3087 Comment cmnt(masm_, "[ CallRuntime"); | 3095 Comment cmnt(masm_, "[ CallRuntime"); |
| 3088 ZoneList<Expression*>* args = expr->arguments(); | 3096 ZoneList<Expression*>* args = expr->arguments(); |
| 3089 | 3097 |
| 3090 if (expr->is_jsruntime()) { | 3098 if (expr->is_jsruntime()) { |
| 3091 // Prepare for calling JS runtime function. | 3099 // Prepare for calling JS runtime function. |
| 3092 __ mov(eax, CodeGenerator::GlobalObject()); | 3100 __ mov(eax, GlobalObjectOperand()); |
| 3093 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); | 3101 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); |
| 3094 } | 3102 } |
| 3095 | 3103 |
| 3096 // Push the arguments ("left-to-right"). | 3104 // Push the arguments ("left-to-right"). |
| 3097 int arg_count = args->length(); | 3105 int arg_count = args->length(); |
| 3098 for (int i = 0; i < arg_count; i++) { | 3106 for (int i = 0; i < arg_count; i++) { |
| 3099 VisitForStackValue(args->at(i)); | 3107 VisitForStackValue(args->at(i)); |
| 3100 } | 3108 } |
| 3101 | 3109 |
| 3102 if (expr->is_jsruntime()) { | 3110 if (expr->is_jsruntime()) { |
| 3103 // Call the JS runtime function via a call IC. | 3111 // Call the JS runtime function via a call IC. |
| 3104 __ Set(ecx, Immediate(expr->name())); | 3112 __ Set(ecx, Immediate(expr->name())); |
| 3105 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; | 3113 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
| 3106 Handle<Code> ic = CodeGenerator::ComputeCallInitialize(arg_count, in_loop); | 3114 Handle<Code> ic = StubCache::ComputeCallInitialize(arg_count, in_loop); |
| 3107 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 3115 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
| 3108 // Restore context register. | 3116 // Restore context register. |
| 3109 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 3117 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 3110 } else { | 3118 } else { |
| 3111 // Call the C runtime function. | 3119 // Call the C runtime function. |
| 3112 __ CallRuntime(expr->function(), arg_count); | 3120 __ CallRuntime(expr->function(), arg_count); |
| 3113 } | 3121 } |
| 3114 context()->Plug(eax); | 3122 context()->Plug(eax); |
| 3115 } | 3123 } |
| 3116 | 3124 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3133 // Result of deleting non-global, non-dynamic variables is false. | 3141 // Result of deleting non-global, non-dynamic variables is false. |
| 3134 // The subexpression does not have side effects. | 3142 // The subexpression does not have side effects. |
| 3135 context()->Plug(false); | 3143 context()->Plug(false); |
| 3136 } else { | 3144 } else { |
| 3137 // Property or variable reference. Call the delete builtin with | 3145 // Property or variable reference. Call the delete builtin with |
| 3138 // object and property name as arguments. | 3146 // object and property name as arguments. |
| 3139 if (prop != NULL) { | 3147 if (prop != NULL) { |
| 3140 VisitForStackValue(prop->obj()); | 3148 VisitForStackValue(prop->obj()); |
| 3141 VisitForStackValue(prop->key()); | 3149 VisitForStackValue(prop->key()); |
| 3142 } else if (var->is_global()) { | 3150 } else if (var->is_global()) { |
| 3143 __ push(CodeGenerator::GlobalObject()); | 3151 __ push(GlobalObjectOperand()); |
| 3144 __ push(Immediate(var->name())); | 3152 __ push(Immediate(var->name())); |
| 3145 } else { | 3153 } else { |
| 3146 // Non-global variable. Call the runtime to look up the context | 3154 // Non-global variable. Call the runtime to look up the context |
| 3147 // where the variable was introduced. | 3155 // where the variable was introduced. |
| 3148 __ push(context_register()); | 3156 __ push(context_register()); |
| 3149 __ push(Immediate(var->name())); | 3157 __ push(Immediate(var->name())); |
| 3150 __ CallRuntime(Runtime::kLookupContext, 2); | 3158 __ CallRuntime(Runtime::kLookupContext, 2); |
| 3151 __ push(eax); | 3159 __ push(eax); |
| 3152 __ push(Immediate(var->name())); | 3160 __ push(Immediate(var->name())); |
| 3153 } | 3161 } |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3411 } | 3419 } |
| 3412 | 3420 |
| 3413 | 3421 |
| 3414 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { | 3422 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
| 3415 VariableProxy* proxy = expr->AsVariableProxy(); | 3423 VariableProxy* proxy = expr->AsVariableProxy(); |
| 3416 ASSERT(!context()->IsEffect()); | 3424 ASSERT(!context()->IsEffect()); |
| 3417 ASSERT(!context()->IsTest()); | 3425 ASSERT(!context()->IsTest()); |
| 3418 | 3426 |
| 3419 if (proxy != NULL && !proxy->var()->is_this() && proxy->var()->is_global()) { | 3427 if (proxy != NULL && !proxy->var()->is_this() && proxy->var()->is_global()) { |
| 3420 Comment cmnt(masm_, "Global variable"); | 3428 Comment cmnt(masm_, "Global variable"); |
| 3421 __ mov(eax, CodeGenerator::GlobalObject()); | 3429 __ mov(eax, GlobalObjectOperand()); |
| 3422 __ mov(ecx, Immediate(proxy->name())); | 3430 __ mov(ecx, Immediate(proxy->name())); |
| 3423 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | 3431 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); |
| 3424 // Use a regular load, not a contextual load, to avoid a reference | 3432 // Use a regular load, not a contextual load, to avoid a reference |
| 3425 // error. | 3433 // error. |
| 3426 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 3434 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
| 3427 context()->Plug(eax); | 3435 context()->Plug(eax); |
| 3428 } else if (proxy != NULL && | 3436 } else if (proxy != NULL && |
| 3429 proxy->var()->AsSlot() != NULL && | 3437 proxy->var()->AsSlot() != NULL && |
| 3430 proxy->var()->AsSlot()->type() == Slot::LOOKUP) { | 3438 proxy->var()->AsSlot()->type() == Slot::LOOKUP) { |
| 3431 Label done, slow; | 3439 Label done, slow; |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3750 // And return. | 3758 // And return. |
| 3751 __ ret(0); | 3759 __ ret(0); |
| 3752 } | 3760 } |
| 3753 | 3761 |
| 3754 | 3762 |
| 3755 #undef __ | 3763 #undef __ |
| 3756 | 3764 |
| 3757 } } // namespace v8::internal | 3765 } } // namespace v8::internal |
| 3758 | 3766 |
| 3759 #endif // V8_TARGET_ARCH_IA32 | 3767 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |