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 2573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2584 __ b(&next); | 2584 __ b(&next); |
2585 __ bind(&fast); | 2585 __ bind(&fast); |
2586 } | 2586 } |
2587 | 2587 |
2588 // All extension objects were empty and it is safe to use a global | 2588 // All extension objects were empty and it is safe to use a global |
2589 // load IC call. | 2589 // load IC call. |
2590 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | 2590 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); |
2591 // Load the global object. | 2591 // Load the global object. |
2592 LoadGlobal(); | 2592 LoadGlobal(); |
2593 // Setup the name register. | 2593 // Setup the name register. |
2594 Result name(r2); | |
2595 __ mov(r2, Operand(slot->var()->name())); | 2594 __ mov(r2, Operand(slot->var()->name())); |
2596 // Call IC stub. | 2595 // Call IC stub. |
2597 if (typeof_state == INSIDE_TYPEOF) { | 2596 if (typeof_state == INSIDE_TYPEOF) { |
2598 frame_->CallCodeObject(ic, RelocInfo::CODE_TARGET, &name, 0); | 2597 frame_->CallCodeObject(ic, RelocInfo::CODE_TARGET, 0); |
2599 } else { | 2598 } else { |
2600 frame_->CallCodeObject(ic, RelocInfo::CODE_TARGET_CONTEXT, &name, 0); | 2599 frame_->CallCodeObject(ic, RelocInfo::CODE_TARGET_CONTEXT, 0); |
2601 } | 2600 } |
2602 | 2601 |
2603 // Drop the global object. The result is in r0. | 2602 // Drop the global object. The result is in r0. |
2604 frame_->Drop(); | 2603 frame_->Drop(); |
2605 } | 2604 } |
2606 | 2605 |
2607 | 2606 |
2608 void CodeGenerator::VisitSlot(Slot* node) { | 2607 void CodeGenerator::VisitSlot(Slot* node) { |
2609 #ifdef DEBUG | 2608 #ifdef DEBUG |
2610 int original_height = frame_->height(); | 2609 int original_height = frame_->height(); |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3153 LoadGlobal(); | 3152 LoadGlobal(); |
3154 | 3153 |
3155 // Push the arguments ("left-to-right") on the stack. | 3154 // Push the arguments ("left-to-right") on the stack. |
3156 ZoneList<Expression*>* args = node->arguments(); | 3155 ZoneList<Expression*>* args = node->arguments(); |
3157 int arg_count = args->length(); | 3156 int arg_count = args->length(); |
3158 for (int i = 0; i < arg_count; i++) { | 3157 for (int i = 0; i < arg_count; i++) { |
3159 LoadAndSpill(args->at(i)); | 3158 LoadAndSpill(args->at(i)); |
3160 } | 3159 } |
3161 | 3160 |
3162 // r0: the number of arguments. | 3161 // r0: the number of arguments. |
3163 Result num_args(r0); | |
3164 __ mov(r0, Operand(arg_count)); | 3162 __ mov(r0, Operand(arg_count)); |
3165 | |
3166 // Load the function into r1 as per calling convention. | 3163 // Load the function into r1 as per calling convention. |
3167 Result function(r1); | |
3168 __ ldr(r1, frame_->ElementAt(arg_count + 1)); | 3164 __ ldr(r1, frame_->ElementAt(arg_count + 1)); |
3169 | 3165 |
3170 // Call the construct call builtin that handles allocation and | 3166 // Call the construct call builtin that handles allocation and |
3171 // constructor invocation. | 3167 // constructor invocation. |
3172 CodeForSourcePosition(node->position()); | 3168 CodeForSourcePosition(node->position()); |
3173 Handle<Code> ic(Builtins::builtin(Builtins::JSConstructCall)); | 3169 Handle<Code> ic(Builtins::builtin(Builtins::JSConstructCall)); |
3174 frame_->CallCodeObject(ic, | 3170 frame_->CallCodeObject(ic, RelocInfo::CONSTRUCT_CALL, arg_count + 1); |
3175 RelocInfo::CONSTRUCT_CALL, | |
3176 &num_args, | |
3177 &function, | |
3178 arg_count + 1); | |
3179 | 3171 |
3180 // Discard old TOS value and push r0 on the stack (same as Pop(), push(r0)). | 3172 // Discard old TOS value and push r0 on the stack (same as Pop(), push(r0)). |
3181 __ str(r0, frame_->Top()); | 3173 __ str(r0, frame_->Top()); |
3182 ASSERT(frame_->height() == original_height + 1); | 3174 ASSERT(frame_->height() == original_height + 1); |
3183 } | 3175 } |
3184 | 3176 |
3185 | 3177 |
3186 void CodeGenerator::GenerateClassOf(ZoneList<Expression*>* args) { | 3178 void CodeGenerator::GenerateClassOf(ZoneList<Expression*>* args) { |
3187 VirtualFrame::SpilledScope spilled_scope; | 3179 VirtualFrame::SpilledScope spilled_scope; |
3188 ASSERT(args->length() == 1); | 3180 ASSERT(args->length() == 1); |
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4325 break; | 4317 break; |
4326 } | 4318 } |
4327 | 4319 |
4328 case NAMED: { | 4320 case NAMED: { |
4329 VirtualFrame* frame = cgen_->frame(); | 4321 VirtualFrame* frame = cgen_->frame(); |
4330 Comment cmnt(masm, "[ Load from named Property"); | 4322 Comment cmnt(masm, "[ Load from named Property"); |
4331 Handle<String> name(GetName()); | 4323 Handle<String> name(GetName()); |
4332 Variable* var = expression_->AsVariableProxy()->AsVariable(); | 4324 Variable* var = expression_->AsVariableProxy()->AsVariable(); |
4333 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | 4325 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); |
4334 // Setup the name register. | 4326 // Setup the name register. |
4335 Result name_reg(r2); | |
4336 __ mov(r2, Operand(name)); | 4327 __ mov(r2, Operand(name)); |
4337 ASSERT(var == NULL || var->is_global()); | 4328 ASSERT(var == NULL || var->is_global()); |
4338 RelocInfo::Mode rmode = (var == NULL) | 4329 RelocInfo::Mode rmode = (var == NULL) |
4339 ? RelocInfo::CODE_TARGET | 4330 ? RelocInfo::CODE_TARGET |
4340 : RelocInfo::CODE_TARGET_CONTEXT; | 4331 : RelocInfo::CODE_TARGET_CONTEXT; |
4341 frame->CallCodeObject(ic, rmode, &name_reg, 0); | 4332 frame->CallCodeObject(ic, rmode, 0); |
4342 frame->EmitPush(r0); | 4333 frame->EmitPush(r0); |
4343 break; | 4334 break; |
4344 } | 4335 } |
4345 | 4336 |
4346 case KEYED: { | 4337 case KEYED: { |
4347 // TODO(181): Implement inlined version of array indexing once | 4338 // TODO(181): Implement inlined version of array indexing once |
4348 // loop nesting is properly tracked on ARM. | 4339 // loop nesting is properly tracked on ARM. |
4349 ASSERT(property != NULL); | 4340 ASSERT(property != NULL); |
4350 Variable* var = expression_->AsVariableProxy()->AsVariable(); | 4341 Variable* var = expression_->AsVariableProxy()->AsVariable(); |
4351 ASSERT(var == NULL || var->is_global()); | 4342 ASSERT(var == NULL || var->is_global()); |
(...skipping 30 matching lines...) Expand all Loading... |
4382 cgen_->UnloadReference(this); | 4373 cgen_->UnloadReference(this); |
4383 break; | 4374 break; |
4384 } | 4375 } |
4385 | 4376 |
4386 case NAMED: { | 4377 case NAMED: { |
4387 Comment cmnt(masm, "[ Store to named Property"); | 4378 Comment cmnt(masm, "[ Store to named Property"); |
4388 // Call the appropriate IC code. | 4379 // Call the appropriate IC code. |
4389 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 4380 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); |
4390 Handle<String> name(GetName()); | 4381 Handle<String> name(GetName()); |
4391 | 4382 |
4392 Result value(r0); | |
4393 frame->EmitPop(r0); | 4383 frame->EmitPop(r0); |
4394 | |
4395 // Setup the name register. | 4384 // Setup the name register. |
4396 Result property_name(r2); | |
4397 __ mov(r2, Operand(name)); | 4385 __ mov(r2, Operand(name)); |
4398 frame->CallCodeObject(ic, | 4386 frame->CallCodeObject(ic, RelocInfo::CODE_TARGET, 0); |
4399 RelocInfo::CODE_TARGET, | |
4400 &value, | |
4401 &property_name, | |
4402 0); | |
4403 frame->EmitPush(r0); | 4387 frame->EmitPush(r0); |
4404 cgen_->UnloadReference(this); | 4388 cgen_->UnloadReference(this); |
4405 break; | 4389 break; |
4406 } | 4390 } |
4407 | 4391 |
4408 case KEYED: { | 4392 case KEYED: { |
4409 Comment cmnt(masm, "[ Store to keyed Property"); | 4393 Comment cmnt(masm, "[ Store to keyed Property"); |
4410 Property* property = expression_->AsProperty(); | 4394 Property* property = expression_->AsProperty(); |
4411 ASSERT(property != NULL); | 4395 ASSERT(property != NULL); |
4412 cgen_->CodeForSourcePosition(property->position()); | 4396 cgen_->CodeForSourcePosition(property->position()); |
4413 | 4397 |
4414 // Call IC code. | 4398 // Call IC code. |
4415 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); | 4399 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); |
4416 // TODO(1222589): Make the IC grab the values from the stack. | 4400 // TODO(1222589): Make the IC grab the values from the stack. |
4417 Result value(r0); | |
4418 frame->EmitPop(r0); // value | 4401 frame->EmitPop(r0); // value |
4419 frame->CallCodeObject(ic, RelocInfo::CODE_TARGET, &value, 0); | 4402 frame->CallCodeObject(ic, RelocInfo::CODE_TARGET, 0); |
4420 frame->EmitPush(r0); | 4403 frame->EmitPush(r0); |
4421 cgen_->UnloadReference(this); | 4404 cgen_->UnloadReference(this); |
4422 break; | 4405 break; |
4423 } | 4406 } |
4424 | 4407 |
4425 default: | 4408 default: |
4426 UNREACHABLE(); | 4409 UNREACHABLE(); |
4427 } | 4410 } |
4428 } | 4411 } |
4429 | 4412 |
(...skipping 2513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6943 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 6926 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
6944 // tagged as a small integer. | 6927 // tagged as a small integer. |
6945 __ bind(&runtime); | 6928 __ bind(&runtime); |
6946 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1); | 6929 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1); |
6947 } | 6930 } |
6948 | 6931 |
6949 | 6932 |
6950 #undef __ | 6933 #undef __ |
6951 | 6934 |
6952 } } // namespace v8::internal | 6935 } } // namespace v8::internal |
OLD | NEW |