Chromium Code Reviews| 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 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1050 smi.Bind(); | 1050 smi.Bind(); |
| 1051 __ cmp(r1, Operand(r0)); | 1051 __ cmp(r1, Operand(r0)); |
| 1052 | 1052 |
| 1053 exit.Bind(); | 1053 exit.Bind(); |
| 1054 cc_reg_ = cc; | 1054 cc_reg_ = cc; |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 | 1057 |
| 1058 class CallFunctionStub: public CodeStub { | 1058 class CallFunctionStub: public CodeStub { |
| 1059 public: | 1059 public: |
| 1060 explicit CallFunctionStub(int argc) : argc_(argc) {} | 1060 CallFunctionStub(int argc, InlineCacheInLoop in_loop) |
|
Kevin Millikin (Chromium)
2009/05/25 11:00:42
I like a name that indicates flaggishness. InLoop
| |
| 1061 : argc_(argc), in_loop_(in_loop) {} | |
| 1061 | 1062 |
| 1062 void Generate(MacroAssembler* masm); | 1063 void Generate(MacroAssembler* masm); |
| 1063 | 1064 |
| 1064 private: | 1065 private: |
| 1065 int argc_; | 1066 int argc_; |
| 1067 InlineCacheInLoop in_loop_; | |
| 1066 | 1068 |
| 1067 #if defined(DEBUG) | 1069 #if defined(DEBUG) |
| 1068 void Print() { PrintF("CallFunctionStub (argc %d)\n", argc_); } | 1070 void Print() { PrintF("CallFunctionStub (argc %d)\n", argc_); } |
| 1069 #endif // defined(DEBUG) | 1071 #endif // defined(DEBUG) |
| 1070 | 1072 |
| 1071 Major MajorKey() { return CallFunction; } | 1073 Major MajorKey() { return CallFunction; } |
| 1072 int MinorKey() { return argc_; } | 1074 int MinorKey() { return argc_; } |
| 1075 InlineCacheInLoop InLoop() { return in_loop_; } | |
| 1073 }; | 1076 }; |
| 1074 | 1077 |
| 1075 | 1078 |
| 1076 // Call the function on the stack with the given arguments. | 1079 // Call the function on the stack with the given arguments. |
| 1077 void CodeGenerator::CallWithArguments(ZoneList<Expression*>* args, | 1080 void CodeGenerator::CallWithArguments(ZoneList<Expression*>* args, |
| 1078 int position) { | 1081 int position) { |
| 1079 VirtualFrame::SpilledScope spilled_scope; | 1082 VirtualFrame::SpilledScope spilled_scope; |
| 1080 // Push the arguments ("left-to-right") on the stack. | 1083 // Push the arguments ("left-to-right") on the stack. |
| 1081 int arg_count = args->length(); | 1084 int arg_count = args->length(); |
| 1082 for (int i = 0; i < arg_count; i++) { | 1085 for (int i = 0; i < arg_count; i++) { |
| 1083 LoadAndSpill(args->at(i)); | 1086 LoadAndSpill(args->at(i)); |
| 1084 } | 1087 } |
| 1085 | 1088 |
| 1086 // Record the position for debugging purposes. | 1089 // Record the position for debugging purposes. |
| 1087 CodeForSourcePosition(position); | 1090 CodeForSourcePosition(position); |
| 1088 | 1091 |
| 1089 // Use the shared code stub to call the function. | 1092 // Use the shared code stub to call the function. |
| 1090 CallFunctionStub call_function(arg_count); | 1093 InlineCacheInLoop in_loop = loop_nesting() > 0 ? IN_LOOP : NOT_IN_LOOP; |
| 1094 CallFunctionStub call_function(arg_count, in_loop); | |
| 1091 frame_->CallStub(&call_function, arg_count + 1); | 1095 frame_->CallStub(&call_function, arg_count + 1); |
| 1092 | 1096 |
| 1093 // Restore context and pop function from the stack. | 1097 // Restore context and pop function from the stack. |
| 1094 __ ldr(cp, frame_->Context()); | 1098 __ ldr(cp, frame_->Context()); |
| 1095 frame_->Drop(); // discard the TOS | 1099 frame_->Drop(); // discard the TOS |
| 1096 } | 1100 } |
| 1097 | 1101 |
| 1098 | 1102 |
| 1099 void CodeGenerator::Branch(bool if_true, JumpTarget* target) { | 1103 void CodeGenerator::Branch(bool if_true, JumpTarget* target) { |
| 1100 VirtualFrame::SpilledScope spilled_scope; | 1104 VirtualFrame::SpilledScope spilled_scope; |
| (...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3043 // invoked function. | 3047 // invoked function. |
| 3044 LoadGlobal(); | 3048 LoadGlobal(); |
| 3045 | 3049 |
| 3046 // Load the arguments. | 3050 // Load the arguments. |
| 3047 int arg_count = args->length(); | 3051 int arg_count = args->length(); |
| 3048 for (int i = 0; i < arg_count; i++) { | 3052 for (int i = 0; i < arg_count; i++) { |
| 3049 LoadAndSpill(args->at(i)); | 3053 LoadAndSpill(args->at(i)); |
| 3050 } | 3054 } |
| 3051 | 3055 |
| 3052 // Setup the receiver register and call the IC initialization code. | 3056 // Setup the receiver register and call the IC initialization code. |
| 3053 Handle<Code> stub = ComputeCallInitialize(arg_count); | 3057 InlineCacheInLoop in_loop = loop_nesting() > 0 ? IN_LOOP : NOT_IN_LOOP; |
| 3058 Handle<Code> stub = ComputeCallInitialize(arg_count, in_loop); | |
| 3054 CodeForSourcePosition(node->position()); | 3059 CodeForSourcePosition(node->position()); |
| 3055 frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET_CONTEXT, | 3060 frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET_CONTEXT, |
| 3056 arg_count + 1); | 3061 arg_count + 1); |
| 3057 __ ldr(cp, frame_->Context()); | 3062 __ ldr(cp, frame_->Context()); |
| 3058 // Remove the function from the stack. | 3063 // Remove the function from the stack. |
| 3059 frame_->Drop(); | 3064 frame_->Drop(); |
| 3060 frame_->EmitPush(r0); | 3065 frame_->EmitPush(r0); |
| 3061 | 3066 |
| 3062 } else if (var != NULL && var->slot() != NULL && | 3067 } else if (var != NULL && var->slot() != NULL && |
| 3063 var->slot()->type() == Slot::LOOKUP) { | 3068 var->slot()->type() == Slot::LOOKUP) { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 3094 frame_->EmitPush(r0); | 3099 frame_->EmitPush(r0); |
| 3095 LoadAndSpill(property->obj()); | 3100 LoadAndSpill(property->obj()); |
| 3096 | 3101 |
| 3097 // Load the arguments. | 3102 // Load the arguments. |
| 3098 int arg_count = args->length(); | 3103 int arg_count = args->length(); |
| 3099 for (int i = 0; i < arg_count; i++) { | 3104 for (int i = 0; i < arg_count; i++) { |
| 3100 LoadAndSpill(args->at(i)); | 3105 LoadAndSpill(args->at(i)); |
| 3101 } | 3106 } |
| 3102 | 3107 |
| 3103 // Set the receiver register and call the IC initialization code. | 3108 // Set the receiver register and call the IC initialization code. |
| 3104 Handle<Code> stub = ComputeCallInitialize(arg_count); | 3109 InlineCacheInLoop in_loop = loop_nesting() > 0 ? IN_LOOP : NOT_IN_LOOP; |
| 3110 Handle<Code> stub = ComputeCallInitialize(arg_count, in_loop); | |
| 3105 CodeForSourcePosition(node->position()); | 3111 CodeForSourcePosition(node->position()); |
| 3106 frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET, arg_count + 1); | 3112 frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET, arg_count + 1); |
| 3107 __ ldr(cp, frame_->Context()); | 3113 __ ldr(cp, frame_->Context()); |
| 3108 | 3114 |
| 3109 // Remove the function from the stack. | 3115 // Remove the function from the stack. |
| 3110 frame_->Drop(); | 3116 frame_->Drop(); |
| 3111 | 3117 |
| 3112 frame_->EmitPush(r0); // push after get rid of function from the stack | 3118 frame_->EmitPush(r0); // push after get rid of function from the stack |
| 3113 | 3119 |
| 3114 } else { | 3120 } else { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3192 | 3198 |
| 3193 // Touch up stack with the right values for the function and the receiver. | 3199 // Touch up stack with the right values for the function and the receiver. |
| 3194 __ ldr(r1, FieldMemOperand(r0, FixedArray::kHeaderSize)); | 3200 __ ldr(r1, FieldMemOperand(r0, FixedArray::kHeaderSize)); |
| 3195 __ str(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 3201 __ str(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 3196 __ ldr(r1, FieldMemOperand(r0, FixedArray::kHeaderSize + kPointerSize)); | 3202 __ ldr(r1, FieldMemOperand(r0, FixedArray::kHeaderSize + kPointerSize)); |
| 3197 __ str(r1, MemOperand(sp, arg_count * kPointerSize)); | 3203 __ str(r1, MemOperand(sp, arg_count * kPointerSize)); |
| 3198 | 3204 |
| 3199 // Call the function. | 3205 // Call the function. |
| 3200 CodeForSourcePosition(node->position()); | 3206 CodeForSourcePosition(node->position()); |
| 3201 | 3207 |
| 3202 CallFunctionStub call_function(arg_count); | 3208 InlineCacheInLoop in_loop = loop_nesting() > 0 ? IN_LOOP : NOT_IN_LOOP; |
| 3209 CallFunctionStub call_function(arg_count, in_loop); | |
| 3203 frame_->CallStub(&call_function, arg_count + 1); | 3210 frame_->CallStub(&call_function, arg_count + 1); |
| 3204 | 3211 |
| 3205 __ ldr(cp, frame_->Context()); | 3212 __ ldr(cp, frame_->Context()); |
| 3206 // Remove the function from the stack. | 3213 // Remove the function from the stack. |
| 3207 frame_->Drop(); | 3214 frame_->Drop(); |
| 3208 frame_->EmitPush(r0); | 3215 frame_->EmitPush(r0); |
| 3209 ASSERT(frame_->height() == original_height + 1); | 3216 ASSERT(frame_->height() == original_height + 1); |
| 3210 } | 3217 } |
| 3211 | 3218 |
| 3212 | 3219 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3454 } | 3461 } |
| 3455 | 3462 |
| 3456 // Push the arguments ("left-to-right"). | 3463 // Push the arguments ("left-to-right"). |
| 3457 int arg_count = args->length(); | 3464 int arg_count = args->length(); |
| 3458 for (int i = 0; i < arg_count; i++) { | 3465 for (int i = 0; i < arg_count; i++) { |
| 3459 LoadAndSpill(args->at(i)); | 3466 LoadAndSpill(args->at(i)); |
| 3460 } | 3467 } |
| 3461 | 3468 |
| 3462 if (function == NULL) { | 3469 if (function == NULL) { |
| 3463 // Call the JS runtime function. | 3470 // Call the JS runtime function. |
| 3464 Handle<Code> stub = ComputeCallInitialize(arg_count); | 3471 InlineCacheInLoop in_loop = loop_nesting() > 0 ? IN_LOOP : NOT_IN_LOOP; |
| 3472 Handle<Code> stub = ComputeCallInitialize(arg_count, in_loop); | |
| 3465 frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET, arg_count + 1); | 3473 frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET, arg_count + 1); |
| 3466 __ ldr(cp, frame_->Context()); | 3474 __ ldr(cp, frame_->Context()); |
| 3467 frame_->Drop(); | 3475 frame_->Drop(); |
| 3468 frame_->EmitPush(r0); | 3476 frame_->EmitPush(r0); |
| 3469 } else { | 3477 } else { |
| 3470 // Call the C runtime function. | 3478 // Call the C runtime function. |
| 3471 frame_->CallRuntime(function, arg_count); | 3479 frame_->CallRuntime(function, arg_count); |
| 3472 frame_->EmitPush(r0); | 3480 frame_->EmitPush(r0); |
| 3473 } | 3481 } |
| 3474 ASSERT(frame_->height() == original_height + 1); | 3482 ASSERT(frame_->height() == original_height + 1); |
| (...skipping 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5180 __ mov(r2, Operand(0)); | 5188 __ mov(r2, Operand(0)); |
| 5181 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); | 5189 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); |
| 5182 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), | 5190 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), |
| 5183 RelocInfo::CODE_TARGET); | 5191 RelocInfo::CODE_TARGET); |
| 5184 } | 5192 } |
| 5185 | 5193 |
| 5186 | 5194 |
| 5187 #undef __ | 5195 #undef __ |
| 5188 | 5196 |
| 5189 } } // namespace v8::internal | 5197 } } // namespace v8::internal |
| OLD | NEW |