Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 4654002: Move common static helpers from codegen to the macro-assembler files. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 __ j(not_equal, slow); 947 __ j(not_equal, slow);
948 // Load next context in chain. 948 // Load next context in chain.
949 __ mov(temp, ContextOperand(temp, Context::CLOSURE_INDEX)); 949 __ mov(temp, ContextOperand(temp, Context::CLOSURE_INDEX));
950 __ mov(temp, FieldOperand(temp, JSFunction::kContextOffset)); 950 __ mov(temp, FieldOperand(temp, JSFunction::kContextOffset));
951 __ jmp(&next); 951 __ jmp(&next);
952 __ bind(&fast); 952 __ bind(&fast);
953 } 953 }
954 954
955 // All extension objects were empty and it is safe to use a global 955 // All extension objects were empty and it is safe to use a global
956 // load IC call. 956 // load IC call.
957 __ mov(eax, CodeGenerator::GlobalObject()); 957 __ mov(eax, GlobalObjectOperand());
958 __ mov(ecx, slot->var()->name()); 958 __ mov(ecx, slot->var()->name());
959 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); 959 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
960 RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF) 960 RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF)
961 ? RelocInfo::CODE_TARGET 961 ? RelocInfo::CODE_TARGET
962 : RelocInfo::CODE_TARGET_CONTEXT; 962 : RelocInfo::CODE_TARGET_CONTEXT;
963 EmitCallIC(ic, mode); 963 EmitCallIC(ic, mode);
964 } 964 }
965 965
966 966
967 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions( 967 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 // Four cases: non-this global variables, lookup slots, all other 1050 // Four cases: non-this global variables, lookup slots, all other
1051 // types of slots, and parameters that rewrite to explicit property 1051 // types of slots, and parameters that rewrite to explicit property
1052 // accesses on the arguments object. 1052 // accesses on the arguments object.
1053 Slot* slot = var->AsSlot(); 1053 Slot* slot = var->AsSlot();
1054 Property* property = var->AsProperty(); 1054 Property* property = var->AsProperty();
1055 1055
1056 if (var->is_global() && !var->is_this()) { 1056 if (var->is_global() && !var->is_this()) {
1057 Comment cmnt(masm_, "Global variable"); 1057 Comment cmnt(masm_, "Global variable");
1058 // Use inline caching. Variable name is passed in ecx and the global 1058 // Use inline caching. Variable name is passed in ecx and the global
1059 // object on the stack. 1059 // object on the stack.
1060 __ mov(eax, CodeGenerator::GlobalObject()); 1060 __ mov(eax, GlobalObjectOperand());
1061 __ mov(ecx, var->name()); 1061 __ mov(ecx, var->name());
1062 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); 1062 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
1063 EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT); 1063 EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT);
1064 context()->Plug(eax); 1064 context()->Plug(eax);
1065 1065
1066 } else if (slot != NULL && slot->type() == Slot::LOOKUP) { 1066 } else if (slot != NULL && slot->type() == Slot::LOOKUP) {
1067 Label done, slow; 1067 Label done, slow;
1068 1068
1069 // Generate code for loading from variables potentially shadowed 1069 // Generate code for loading from variables potentially shadowed
1070 // by eval-introduced variables. 1070 // by eval-introduced variables.
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 // here. 1827 // here.
1828 ASSERT(var != NULL); 1828 ASSERT(var != NULL);
1829 ASSERT(var->is_global() || var->AsSlot() != NULL); 1829 ASSERT(var->is_global() || var->AsSlot() != NULL);
1830 1830
1831 if (var->is_global()) { 1831 if (var->is_global()) {
1832 ASSERT(!var->is_this()); 1832 ASSERT(!var->is_this());
1833 // Assignment to a global variable. Use inline caching for the 1833 // Assignment to a global variable. Use inline caching for the
1834 // assignment. Right-hand-side value is passed in eax, variable name in 1834 // assignment. Right-hand-side value is passed in eax, variable name in
1835 // ecx, and the global object on the stack. 1835 // ecx, and the global object on the stack.
1836 __ mov(ecx, var->name()); 1836 __ mov(ecx, var->name());
1837 __ mov(edx, CodeGenerator::GlobalObject()); 1837 __ mov(edx, GlobalObjectOperand());
1838 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); 1838 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
1839 EmitCallIC(ic, RelocInfo::CODE_TARGET); 1839 EmitCallIC(ic, RelocInfo::CODE_TARGET);
1840 1840
1841 } else if (var->mode() != Variable::CONST || op == Token::INIT_CONST) { 1841 } else if (var->mode() != Variable::CONST || op == Token::INIT_CONST) {
1842 // Perform the assignment for non-const variables and for initialization 1842 // Perform the assignment for non-const variables and for initialization
1843 // of const variables. Const assignments are simply skipped. 1843 // of const variables. Const assignments are simply skipped.
1844 Label done; 1844 Label done;
1845 Slot* slot = var->AsSlot(); 1845 Slot* slot = var->AsSlot();
1846 switch (slot->type()) { 1846 switch (slot->type()) {
1847 case Slot::PARAMETER: 1847 case Slot::PARAMETER:
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 // Record source position for debugger. 2102 // Record source position for debugger.
2103 SetSourcePosition(expr->position(), FORCED_POSITION); 2103 SetSourcePosition(expr->position(), FORCED_POSITION);
2104 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; 2104 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP;
2105 CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_VALUE); 2105 CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_VALUE);
2106 __ CallStub(&stub); 2106 __ CallStub(&stub);
2107 // Restore context register. 2107 // Restore context register.
2108 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 2108 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2109 context()->DropAndPlug(1, eax); 2109 context()->DropAndPlug(1, eax);
2110 } else if (var != NULL && !var->is_this() && var->is_global()) { 2110 } else if (var != NULL && !var->is_this() && var->is_global()) {
2111 // Push global object as receiver for the call IC. 2111 // Push global object as receiver for the call IC.
2112 __ push(CodeGenerator::GlobalObject()); 2112 __ push(GlobalObjectOperand());
2113 EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT); 2113 EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT);
2114 } else if (var != NULL && var->AsSlot() != NULL && 2114 } else if (var != NULL && var->AsSlot() != NULL &&
2115 var->AsSlot()->type() == Slot::LOOKUP) { 2115 var->AsSlot()->type() == Slot::LOOKUP) {
2116 // Call to a lookup slot (dynamically introduced variable). 2116 // Call to a lookup slot (dynamically introduced variable).
2117 Label slow, done; 2117 Label slow, done;
2118 2118
2119 { PreserveStatementPositionScope scope(masm()->positions_recorder()); 2119 { PreserveStatementPositionScope scope(masm()->positions_recorder());
2120 // Generate code for loading from variables potentially shadowed 2120 // Generate code for loading from variables potentially shadowed
2121 // by eval-introduced variables. 2121 // by eval-introduced variables.
2122 EmitDynamicLoadFromSlotFastCase(var->AsSlot(), 2122 EmitDynamicLoadFromSlotFastCase(var->AsSlot(),
(...skipping 14 matching lines...) Expand all
2137 // If fast case code has been generated, emit code to push the 2137 // If fast case code has been generated, emit code to push the
2138 // function and receiver and have the slow path jump around this 2138 // function and receiver and have the slow path jump around this
2139 // code. 2139 // code.
2140 if (done.is_linked()) { 2140 if (done.is_linked()) {
2141 Label call; 2141 Label call;
2142 __ jmp(&call); 2142 __ jmp(&call);
2143 __ bind(&done); 2143 __ bind(&done);
2144 // Push function. 2144 // Push function.
2145 __ push(eax); 2145 __ push(eax);
2146 // Push global receiver. 2146 // Push global receiver.
2147 __ mov(ebx, CodeGenerator::GlobalObject()); 2147 __ mov(ebx, GlobalObjectOperand());
2148 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); 2148 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset));
2149 __ bind(&call); 2149 __ bind(&call);
2150 } 2150 }
2151 2151
2152 EmitCallWithStub(expr); 2152 EmitCallWithStub(expr);
2153 } else if (fun->AsProperty() != NULL) { 2153 } else if (fun->AsProperty() != NULL) {
2154 // Call to an object property. 2154 // Call to an object property.
2155 Property* prop = fun->AsProperty(); 2155 Property* prop = fun->AsProperty();
2156 Literal* key = prop->key()->AsLiteral(); 2156 Literal* key = prop->key()->AsLiteral();
2157 if (key != NULL && key->handle()->IsSymbol()) { 2157 if (key != NULL && key->handle()->IsSymbol()) {
(...skipping 13 matching lines...) Expand all
2171 } 2171 }
2172 // Record source code position for IC call. 2172 // Record source code position for IC call.
2173 SetSourcePosition(prop->position(), FORCED_POSITION); 2173 SetSourcePosition(prop->position(), FORCED_POSITION);
2174 __ pop(edx); // We do not need to keep the receiver. 2174 __ pop(edx); // We do not need to keep the receiver.
2175 2175
2176 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); 2176 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
2177 EmitCallIC(ic, RelocInfo::CODE_TARGET); 2177 EmitCallIC(ic, RelocInfo::CODE_TARGET);
2178 // Push result (function). 2178 // Push result (function).
2179 __ push(eax); 2179 __ push(eax);
2180 // Push Global receiver. 2180 // Push Global receiver.
2181 __ mov(ecx, CodeGenerator::GlobalObject()); 2181 __ mov(ecx, GlobalObjectOperand());
2182 __ push(FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset)); 2182 __ push(FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset));
2183 EmitCallWithStub(expr); 2183 EmitCallWithStub(expr);
2184 } else { 2184 } else {
2185 EmitKeyedCallWithIC(expr, prop->key(), RelocInfo::CODE_TARGET); 2185 EmitKeyedCallWithIC(expr, prop->key(), RelocInfo::CODE_TARGET);
2186 } 2186 }
2187 } 2187 }
2188 } else { 2188 } else {
2189 // Call to some other expression. If the expression is an anonymous 2189 // 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 2190 // function literal not called in a loop, mark it as one that should
2191 // also use the full code generator. 2191 // also use the full code generator.
2192 FunctionLiteral* lit = fun->AsFunctionLiteral(); 2192 FunctionLiteral* lit = fun->AsFunctionLiteral();
2193 if (lit != NULL && 2193 if (lit != NULL &&
2194 lit->name()->Equals(Heap::empty_string()) && 2194 lit->name()->Equals(Heap::empty_string()) &&
2195 loop_depth() == 0) { 2195 loop_depth() == 0) {
2196 lit->set_try_full_codegen(true); 2196 lit->set_try_full_codegen(true);
2197 } 2197 }
2198 { PreserveStatementPositionScope scope(masm()->positions_recorder()); 2198 { PreserveStatementPositionScope scope(masm()->positions_recorder());
2199 VisitForStackValue(fun); 2199 VisitForStackValue(fun);
2200 } 2200 }
2201 // Load global receiver object. 2201 // Load global receiver object.
2202 __ mov(ebx, CodeGenerator::GlobalObject()); 2202 __ mov(ebx, GlobalObjectOperand());
2203 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); 2203 __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset));
2204 // Emit function call. 2204 // Emit function call.
2205 EmitCallWithStub(expr); 2205 EmitCallWithStub(expr);
2206 } 2206 }
2207 } 2207 }
2208 2208
2209 2209
2210 void FullCodeGenerator::VisitCallNew(CallNew* expr) { 2210 void FullCodeGenerator::VisitCallNew(CallNew* expr) {
2211 Comment cmnt(masm_, "[ CallNew"); 2211 Comment cmnt(masm_, "[ CallNew");
2212 // According to ECMA-262, section 11.2.2, page 44, the function 2212 // According to ECMA-262, section 11.2.2, page 44, the function
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
3082 Comment cmnt(masm_, "[ InlineRuntimeCall"); 3082 Comment cmnt(masm_, "[ InlineRuntimeCall");
3083 EmitInlineRuntimeCall(expr); 3083 EmitInlineRuntimeCall(expr);
3084 return; 3084 return;
3085 } 3085 }
3086 3086
3087 Comment cmnt(masm_, "[ CallRuntime"); 3087 Comment cmnt(masm_, "[ CallRuntime");
3088 ZoneList<Expression*>* args = expr->arguments(); 3088 ZoneList<Expression*>* args = expr->arguments();
3089 3089
3090 if (expr->is_jsruntime()) { 3090 if (expr->is_jsruntime()) {
3091 // Prepare for calling JS runtime function. 3091 // Prepare for calling JS runtime function.
3092 __ mov(eax, CodeGenerator::GlobalObject()); 3092 __ mov(eax, GlobalObjectOperand());
3093 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); 3093 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset));
3094 } 3094 }
3095 3095
3096 // Push the arguments ("left-to-right"). 3096 // Push the arguments ("left-to-right").
3097 int arg_count = args->length(); 3097 int arg_count = args->length();
3098 for (int i = 0; i < arg_count; i++) { 3098 for (int i = 0; i < arg_count; i++) {
3099 VisitForStackValue(args->at(i)); 3099 VisitForStackValue(args->at(i));
3100 } 3100 }
3101 3101
3102 if (expr->is_jsruntime()) { 3102 if (expr->is_jsruntime()) {
(...skipping 30 matching lines...) Expand all
3133 // Result of deleting non-global, non-dynamic variables is false. 3133 // Result of deleting non-global, non-dynamic variables is false.
3134 // The subexpression does not have side effects. 3134 // The subexpression does not have side effects.
3135 context()->Plug(false); 3135 context()->Plug(false);
3136 } else { 3136 } else {
3137 // Property or variable reference. Call the delete builtin with 3137 // Property or variable reference. Call the delete builtin with
3138 // object and property name as arguments. 3138 // object and property name as arguments.
3139 if (prop != NULL) { 3139 if (prop != NULL) {
3140 VisitForStackValue(prop->obj()); 3140 VisitForStackValue(prop->obj());
3141 VisitForStackValue(prop->key()); 3141 VisitForStackValue(prop->key());
3142 } else if (var->is_global()) { 3142 } else if (var->is_global()) {
3143 __ push(CodeGenerator::GlobalObject()); 3143 __ push(GlobalObjectOperand());
3144 __ push(Immediate(var->name())); 3144 __ push(Immediate(var->name()));
3145 } else { 3145 } else {
3146 // Non-global variable. Call the runtime to look up the context 3146 // Non-global variable. Call the runtime to look up the context
3147 // where the variable was introduced. 3147 // where the variable was introduced.
3148 __ push(context_register()); 3148 __ push(context_register());
3149 __ push(Immediate(var->name())); 3149 __ push(Immediate(var->name()));
3150 __ CallRuntime(Runtime::kLookupContext, 2); 3150 __ CallRuntime(Runtime::kLookupContext, 2);
3151 __ push(eax); 3151 __ push(eax);
3152 __ push(Immediate(var->name())); 3152 __ push(Immediate(var->name()));
3153 } 3153 }
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
3411 } 3411 }
3412 3412
3413 3413
3414 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { 3414 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) {
3415 VariableProxy* proxy = expr->AsVariableProxy(); 3415 VariableProxy* proxy = expr->AsVariableProxy();
3416 ASSERT(!context()->IsEffect()); 3416 ASSERT(!context()->IsEffect());
3417 ASSERT(!context()->IsTest()); 3417 ASSERT(!context()->IsTest());
3418 3418
3419 if (proxy != NULL && !proxy->var()->is_this() && proxy->var()->is_global()) { 3419 if (proxy != NULL && !proxy->var()->is_this() && proxy->var()->is_global()) {
3420 Comment cmnt(masm_, "Global variable"); 3420 Comment cmnt(masm_, "Global variable");
3421 __ mov(eax, CodeGenerator::GlobalObject()); 3421 __ mov(eax, GlobalObjectOperand());
3422 __ mov(ecx, Immediate(proxy->name())); 3422 __ mov(ecx, Immediate(proxy->name()));
3423 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); 3423 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
3424 // Use a regular load, not a contextual load, to avoid a reference 3424 // Use a regular load, not a contextual load, to avoid a reference
3425 // error. 3425 // error.
3426 EmitCallIC(ic, RelocInfo::CODE_TARGET); 3426 EmitCallIC(ic, RelocInfo::CODE_TARGET);
3427 context()->Plug(eax); 3427 context()->Plug(eax);
3428 } else if (proxy != NULL && 3428 } else if (proxy != NULL &&
3429 proxy->var()->AsSlot() != NULL && 3429 proxy->var()->AsSlot() != NULL &&
3430 proxy->var()->AsSlot()->type() == Slot::LOOKUP) { 3430 proxy->var()->AsSlot()->type() == Slot::LOOKUP) {
3431 Label done, slow; 3431 Label done, slow;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
3750 // And return. 3750 // And return.
3751 __ ret(0); 3751 __ ret(0);
3752 } 3752 }
3753 3753
3754 3754
3755 #undef __ 3755 #undef __
3756 3756
3757 } } // namespace v8::internal 3757 } } // namespace v8::internal
3758 3758
3759 #endif // V8_TARGET_ARCH_IA32 3759 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698