OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 // The result is discarded. | 1181 // The result is discarded. |
1182 } | 1182 } |
1183 | 1183 |
1184 | 1184 |
1185 void CodeGenerator::VisitDeclaration(Declaration* node) { | 1185 void CodeGenerator::VisitDeclaration(Declaration* node) { |
1186 #ifdef DEBUG | 1186 #ifdef DEBUG |
1187 int original_height = frame_->height(); | 1187 int original_height = frame_->height(); |
1188 #endif | 1188 #endif |
1189 VirtualFrame::SpilledScope spilled_scope; | 1189 VirtualFrame::SpilledScope spilled_scope; |
1190 Comment cmnt(masm_, "[ Declaration"); | 1190 Comment cmnt(masm_, "[ Declaration"); |
1191 CodeForStatementPosition(node); | |
1192 Variable* var = node->proxy()->var(); | 1191 Variable* var = node->proxy()->var(); |
1193 ASSERT(var != NULL); // must have been resolved | 1192 ASSERT(var != NULL); // must have been resolved |
1194 Slot* slot = var->slot(); | 1193 Slot* slot = var->slot(); |
1195 | 1194 |
1196 // If it was not possible to allocate the variable at compile time, | 1195 // If it was not possible to allocate the variable at compile time, |
1197 // we need to "declare" it at runtime to make sure it actually | 1196 // we need to "declare" it at runtime to make sure it actually |
1198 // exists in the local context. | 1197 // exists in the local context. |
1199 if (slot != NULL && slot->type() == Slot::LOOKUP) { | 1198 if (slot != NULL && slot->type() == Slot::LOOKUP) { |
1200 // Variables with a "LOOKUP" slot were introduced as non-locals | 1199 // Variables with a "LOOKUP" slot were introduced as non-locals |
1201 // during variable resolution and must have mode DYNAMIC. | 1200 // during variable resolution and must have mode DYNAMIC. |
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2804 ASSERT(frame_->height() == original_height + 1); | 2803 ASSERT(frame_->height() == original_height + 1); |
2805 } | 2804 } |
2806 | 2805 |
2807 | 2806 |
2808 void CodeGenerator::VisitAssignment(Assignment* node) { | 2807 void CodeGenerator::VisitAssignment(Assignment* node) { |
2809 #ifdef DEBUG | 2808 #ifdef DEBUG |
2810 int original_height = frame_->height(); | 2809 int original_height = frame_->height(); |
2811 #endif | 2810 #endif |
2812 VirtualFrame::SpilledScope spilled_scope; | 2811 VirtualFrame::SpilledScope spilled_scope; |
2813 Comment cmnt(masm_, "[ Assignment"); | 2812 Comment cmnt(masm_, "[ Assignment"); |
2814 CodeForStatementPosition(node); | |
2815 | 2813 |
2816 { Reference target(this, node->target()); | 2814 { Reference target(this, node->target()); |
2817 if (target.is_illegal()) { | 2815 if (target.is_illegal()) { |
2818 // Fool the virtual frame into thinking that we left the assignment's | 2816 // Fool the virtual frame into thinking that we left the assignment's |
2819 // value on the frame. | 2817 // value on the frame. |
2820 __ mov(r0, Operand(Smi::FromInt(0))); | 2818 __ mov(r0, Operand(Smi::FromInt(0))); |
2821 frame_->EmitPush(r0); | 2819 frame_->EmitPush(r0); |
2822 ASSERT(frame_->height() == original_height + 1); | 2820 ASSERT(frame_->height() == original_height + 1); |
2823 return; | 2821 return; |
2824 } | 2822 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2904 | 2902 |
2905 void CodeGenerator::VisitCall(Call* node) { | 2903 void CodeGenerator::VisitCall(Call* node) { |
2906 #ifdef DEBUG | 2904 #ifdef DEBUG |
2907 int original_height = frame_->height(); | 2905 int original_height = frame_->height(); |
2908 #endif | 2906 #endif |
2909 VirtualFrame::SpilledScope spilled_scope; | 2907 VirtualFrame::SpilledScope spilled_scope; |
2910 Comment cmnt(masm_, "[ Call"); | 2908 Comment cmnt(masm_, "[ Call"); |
2911 | 2909 |
2912 ZoneList<Expression*>* args = node->arguments(); | 2910 ZoneList<Expression*>* args = node->arguments(); |
2913 | 2911 |
2914 CodeForStatementPosition(node); | |
2915 // Standard function call. | 2912 // Standard function call. |
2916 | |
2917 // Check if the function is a variable or a property. | 2913 // Check if the function is a variable or a property. |
2918 Expression* function = node->expression(); | 2914 Expression* function = node->expression(); |
2919 Variable* var = function->AsVariableProxy()->AsVariable(); | 2915 Variable* var = function->AsVariableProxy()->AsVariable(); |
2920 Property* property = function->AsProperty(); | 2916 Property* property = function->AsProperty(); |
2921 | 2917 |
2922 // ------------------------------------------------------------------------ | 2918 // ------------------------------------------------------------------------ |
2923 // Fast-case: Use inline caching. | 2919 // Fast-case: Use inline caching. |
2924 // --- | 2920 // --- |
2925 // According to ECMA-262, section 11.2.3, page 44, the function to call | 2921 // According to ECMA-262, section 11.2.3, page 44, the function to call |
2926 // must be resolved after the arguments have been evaluated. The IC code | 2922 // must be resolved after the arguments have been evaluated. The IC code |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3060 VirtualFrame::SpilledScope spilled_scope; | 3056 VirtualFrame::SpilledScope spilled_scope; |
3061 Comment cmnt(masm_, "[ CallEval"); | 3057 Comment cmnt(masm_, "[ CallEval"); |
3062 | 3058 |
3063 // In a call to eval, we first call %ResolvePossiblyDirectEval to resolve | 3059 // In a call to eval, we first call %ResolvePossiblyDirectEval to resolve |
3064 // the function we need to call and the receiver of the call. | 3060 // the function we need to call and the receiver of the call. |
3065 // Then we call the resolved function using the given arguments. | 3061 // Then we call the resolved function using the given arguments. |
3066 | 3062 |
3067 ZoneList<Expression*>* args = node->arguments(); | 3063 ZoneList<Expression*>* args = node->arguments(); |
3068 Expression* function = node->expression(); | 3064 Expression* function = node->expression(); |
3069 | 3065 |
3070 CodeForStatementPosition(node); | |
3071 | |
3072 // Prepare stack for call to resolved function. | 3066 // Prepare stack for call to resolved function. |
3073 LoadAndSpill(function); | 3067 LoadAndSpill(function); |
3074 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); | 3068 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); |
3075 frame_->EmitPush(r2); // Slot for receiver | 3069 frame_->EmitPush(r2); // Slot for receiver |
3076 int arg_count = args->length(); | 3070 int arg_count = args->length(); |
3077 for (int i = 0; i < arg_count; i++) { | 3071 for (int i = 0; i < arg_count; i++) { |
3078 LoadAndSpill(args->at(i)); | 3072 LoadAndSpill(args->at(i)); |
3079 } | 3073 } |
3080 | 3074 |
3081 // Prepare stack for call to ResolvePossiblyDirectEval. | 3075 // Prepare stack for call to ResolvePossiblyDirectEval. |
(...skipping 29 matching lines...) Expand all Loading... |
3111 ASSERT(frame_->height() == original_height + 1); | 3105 ASSERT(frame_->height() == original_height + 1); |
3112 } | 3106 } |
3113 | 3107 |
3114 | 3108 |
3115 void CodeGenerator::VisitCallNew(CallNew* node) { | 3109 void CodeGenerator::VisitCallNew(CallNew* node) { |
3116 #ifdef DEBUG | 3110 #ifdef DEBUG |
3117 int original_height = frame_->height(); | 3111 int original_height = frame_->height(); |
3118 #endif | 3112 #endif |
3119 VirtualFrame::SpilledScope spilled_scope; | 3113 VirtualFrame::SpilledScope spilled_scope; |
3120 Comment cmnt(masm_, "[ CallNew"); | 3114 Comment cmnt(masm_, "[ CallNew"); |
3121 CodeForStatementPosition(node); | |
3122 | 3115 |
3123 // According to ECMA-262, section 11.2.2, page 44, the function | 3116 // According to ECMA-262, section 11.2.2, page 44, the function |
3124 // expression in new calls must be evaluated before the | 3117 // expression in new calls must be evaluated before the |
3125 // arguments. This is different from ordinary calls, where the | 3118 // arguments. This is different from ordinary calls, where the |
3126 // actual function to call is resolved after the arguments have been | 3119 // actual function to call is resolved after the arguments have been |
3127 // evaluated. | 3120 // evaluated. |
3128 | 3121 |
3129 // Compute function to call and use the global object as the | 3122 // Compute function to call and use the global object as the |
3130 // receiver. There is no need to use the global proxy here because | 3123 // receiver. There is no need to use the global proxy here because |
3131 // it will always be replaced with a newly allocated object. | 3124 // it will always be replaced with a newly allocated object. |
(...skipping 3136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6268 int CompareStub::MinorKey() { | 6261 int CompareStub::MinorKey() { |
6269 // Encode the two parameters in a unique 16 bit value. | 6262 // Encode the two parameters in a unique 16 bit value. |
6270 ASSERT(static_cast<unsigned>(cc_) >> 28 < (1 << 15)); | 6263 ASSERT(static_cast<unsigned>(cc_) >> 28 < (1 << 15)); |
6271 return (static_cast<unsigned>(cc_) >> 27) | (strict_ ? 1 : 0); | 6264 return (static_cast<unsigned>(cc_) >> 27) | (strict_ ? 1 : 0); |
6272 } | 6265 } |
6273 | 6266 |
6274 | 6267 |
6275 #undef __ | 6268 #undef __ |
6276 | 6269 |
6277 } } // namespace v8::internal | 6270 } } // namespace v8::internal |
OLD | NEW |