| 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 1949 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 // Code common for calls using the IC. |
| 2020 ZoneList<Expression*>* args = expr->arguments(); | 2021 ZoneList<Expression*>* args = expr->arguments(); |
| 2021 int arg_count = args->length(); | 2022 int arg_count = args->length(); |
| 2022 { PreserveStatementPositionScope scope(masm()->positions_recorder()); | 2023 { PreserveStatementPositionScope scope(masm()->positions_recorder()); |
| 2023 for (int i = 0; i < arg_count; i++) { | 2024 for (int i = 0; i < arg_count; i++) { |
| 2024 VisitForStackValue(args->at(i)); | 2025 VisitForStackValue(args->at(i)); |
| 2025 } | 2026 } |
| 2026 VisitForAccumulatorValue(key); | 2027 VisitForAccumulatorValue(key); |
| 2027 __ mov(ecx, eax); | 2028 __ mov(ecx, eax); |
| 2028 } | 2029 } |
| 2029 // Record source position of the IC call. | 2030 // Record source position of the IC call. |
| 2030 SetSourcePosition(expr->position(), FORCED_POSITION); | 2031 SetSourcePosition(expr->position(), FORCED_POSITION); |
| 2031 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; | 2032 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
| 2032 Handle<Code> ic = CodeGenerator::ComputeKeyedCallInitialize( | 2033 Handle<Code> ic = StubCache::ComputeKeyedCallInitialize(arg_count, in_loop); |
| 2033 arg_count, in_loop); | |
| 2034 EmitCallIC(ic, mode); | 2034 EmitCallIC(ic, mode); |
| 2035 // Restore context register. | 2035 // Restore context register. |
| 2036 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2036 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 2037 context()->Plug(eax); | 2037 context()->Plug(eax); |
| 2038 } | 2038 } |
| 2039 | 2039 |
| 2040 | 2040 |
| 2041 void FullCodeGenerator::EmitCallWithStub(Call* expr) { | 2041 void FullCodeGenerator::EmitCallWithStub(Call* expr) { |
| 2042 // Code common for calls using the call stub. | 2042 // Code common for calls using the call stub. |
| 2043 ZoneList<Expression*>* args = expr->arguments(); | 2043 ZoneList<Expression*>* args = expr->arguments(); |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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()) { |
| 3103 // Call the JS runtime function via a call IC. | 3103 // Call the JS runtime function via a call IC. |
| 3104 __ Set(ecx, Immediate(expr->name())); | 3104 __ Set(ecx, Immediate(expr->name())); |
| 3105 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; | 3105 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; |
| 3106 Handle<Code> ic = CodeGenerator::ComputeCallInitialize(arg_count, in_loop); | 3106 Handle<Code> ic = StubCache::ComputeCallInitialize(arg_count, in_loop); |
| 3107 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 3107 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
| 3108 // Restore context register. | 3108 // Restore context register. |
| 3109 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 3109 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 3110 } else { | 3110 } else { |
| 3111 // Call the C runtime function. | 3111 // Call the C runtime function. |
| 3112 __ CallRuntime(expr->function(), arg_count); | 3112 __ CallRuntime(expr->function(), arg_count); |
| 3113 } | 3113 } |
| 3114 context()->Plug(eax); | 3114 context()->Plug(eax); |
| 3115 } | 3115 } |
| 3116 | 3116 |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |