| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // o esi: our context | 111 // o esi: our context |
| 112 // o ebp: our caller's frame pointer | 112 // o ebp: our caller's frame pointer |
| 113 // o esp: stack pointer (pointing to return address) | 113 // o esp: stack pointer (pointing to return address) |
| 114 // | 114 // |
| 115 // The function builds a JS frame. Please see JavaScriptFrameConstants in | 115 // The function builds a JS frame. Please see JavaScriptFrameConstants in |
| 116 // frames-ia32.h for its layout. | 116 // frames-ia32.h for its layout. |
| 117 void FullCodeGenerator::Generate() { | 117 void FullCodeGenerator::Generate() { |
| 118 CompilationInfo* info = info_; | 118 CompilationInfo* info = info_; |
| 119 handler_table_ = | 119 handler_table_ = |
| 120 isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); | 120 isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); |
| 121 |
| 122 InitializeFeedbackVector(); |
| 123 |
| 121 profiling_counter_ = isolate()->factory()->NewCell( | 124 profiling_counter_ = isolate()->factory()->NewCell( |
| 122 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); | 125 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); |
| 123 SetFunctionPosition(function()); | 126 SetFunctionPosition(function()); |
| 124 Comment cmnt(masm_, "[ function compiled by full code generator"); | 127 Comment cmnt(masm_, "[ function compiled by full code generator"); |
| 125 | 128 |
| 126 ProfileEntryHookStub::MaybeCallEntryHook(masm_); | 129 ProfileEntryHookStub::MaybeCallEntryHook(masm_); |
| 127 | 130 |
| 128 #ifdef DEBUG | 131 #ifdef DEBUG |
| 129 if (strlen(FLAG_stop_at) > 0 && | 132 if (strlen(FLAG_stop_at) > 0 && |
| 130 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 133 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 VisitStatements(clause->statements()); | 1017 VisitStatements(clause->statements()); |
| 1015 } | 1018 } |
| 1016 | 1019 |
| 1017 __ bind(nested_statement.break_label()); | 1020 __ bind(nested_statement.break_label()); |
| 1018 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1021 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
| 1019 } | 1022 } |
| 1020 | 1023 |
| 1021 | 1024 |
| 1022 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { | 1025 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
| 1023 Comment cmnt(masm_, "[ ForInStatement"); | 1026 Comment cmnt(masm_, "[ ForInStatement"); |
| 1027 int slot = stmt->ForInFeedbackSlot(); |
| 1028 |
| 1024 SetStatementPosition(stmt); | 1029 SetStatementPosition(stmt); |
| 1025 | 1030 |
| 1026 Label loop, exit; | 1031 Label loop, exit; |
| 1027 ForIn loop_statement(this, stmt); | 1032 ForIn loop_statement(this, stmt); |
| 1028 increment_loop_depth(); | 1033 increment_loop_depth(); |
| 1029 | 1034 |
| 1030 // Get the object to enumerate over. If the object is null or undefined, skip | 1035 // Get the object to enumerate over. If the object is null or undefined, skip |
| 1031 // over the loop. See ECMA-262 version 5, section 12.6.4. | 1036 // over the loop. See ECMA-262 version 5, section 12.6.4. |
| 1032 VisitForAccumulatorValue(stmt->enumerable()); | 1037 VisitForAccumulatorValue(stmt->enumerable()); |
| 1033 __ cmp(eax, isolate()->factory()->undefined_value()); | 1038 __ cmp(eax, isolate()->factory()->undefined_value()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 __ jmp(&loop); | 1097 __ jmp(&loop); |
| 1093 | 1098 |
| 1094 __ bind(&no_descriptors); | 1099 __ bind(&no_descriptors); |
| 1095 __ add(esp, Immediate(kPointerSize)); | 1100 __ add(esp, Immediate(kPointerSize)); |
| 1096 __ jmp(&exit); | 1101 __ jmp(&exit); |
| 1097 | 1102 |
| 1098 // We got a fixed array in register eax. Iterate through that. | 1103 // We got a fixed array in register eax. Iterate through that. |
| 1099 Label non_proxy; | 1104 Label non_proxy; |
| 1100 __ bind(&fixed_array); | 1105 __ bind(&fixed_array); |
| 1101 | 1106 |
| 1102 Handle<Cell> cell = isolate()->factory()->NewCell( | 1107 Handle<Object> feedback = Handle<Object>( |
| 1103 Handle<Object>(Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker), | 1108 Smi::FromInt(TypeFeedbackInfo::kForInFastCaseMarker), |
| 1104 isolate())); | 1109 isolate()); |
| 1105 RecordTypeFeedbackCell(stmt->ForInFeedbackId(), cell); | 1110 StoreFeedbackVectorSlot(slot, feedback); |
| 1106 __ LoadHeapObject(ebx, cell); | 1111 |
| 1107 __ mov(FieldOperand(ebx, Cell::kValueOffset), | 1112 // No need for a write barrier, we are storing a Smi in the feedback vector. |
| 1108 Immediate(Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker))); | 1113 __ LoadHeapObject(ebx, FeedbackVector()); |
| 1114 __ mov(FieldOperand(ebx, FixedArray::OffsetOfElementAt(slot)), |
| 1115 Immediate(Smi::FromInt(TypeFeedbackInfo::kForInSlowCaseMarker))); |
| 1109 | 1116 |
| 1110 __ mov(ebx, Immediate(Smi::FromInt(1))); // Smi indicates slow check | 1117 __ mov(ebx, Immediate(Smi::FromInt(1))); // Smi indicates slow check |
| 1111 __ mov(ecx, Operand(esp, 0 * kPointerSize)); // Get enumerated object | 1118 __ mov(ecx, Operand(esp, 0 * kPointerSize)); // Get enumerated object |
| 1112 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); | 1119 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); |
| 1113 __ CmpObjectType(ecx, LAST_JS_PROXY_TYPE, ecx); | 1120 __ CmpObjectType(ecx, LAST_JS_PROXY_TYPE, ecx); |
| 1114 __ j(above, &non_proxy); | 1121 __ j(above, &non_proxy); |
| 1115 __ Set(ebx, Immediate(Smi::FromInt(0))); // Zero indicates proxy | 1122 __ Set(ebx, Immediate(Smi::FromInt(0))); // Zero indicates proxy |
| 1116 __ bind(&non_proxy); | 1123 __ bind(&non_proxy); |
| 1117 __ push(ebx); // Smi | 1124 __ push(ebx); // Smi |
| 1118 __ push(eax); // Array | 1125 __ push(eax); // Array |
| (...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2661 int arg_count = args->length(); | 2668 int arg_count = args->length(); |
| 2662 { PreservePositionScope scope(masm()->positions_recorder()); | 2669 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2663 for (int i = 0; i < arg_count; i++) { | 2670 for (int i = 0; i < arg_count; i++) { |
| 2664 VisitForStackValue(args->at(i)); | 2671 VisitForStackValue(args->at(i)); |
| 2665 } | 2672 } |
| 2666 } | 2673 } |
| 2667 // Record source position for debugger. | 2674 // Record source position for debugger. |
| 2668 SetSourcePosition(expr->position()); | 2675 SetSourcePosition(expr->position()); |
| 2669 | 2676 |
| 2670 Handle<Object> uninitialized = | 2677 Handle<Object> uninitialized = |
| 2671 TypeFeedbackCells::UninitializedSentinel(isolate()); | 2678 TypeFeedbackInfo::UninitializedSentinel(isolate()); |
| 2672 Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized); | 2679 StoreFeedbackVectorSlot(expr->CallFeedbackSlot(), uninitialized); |
| 2673 RecordTypeFeedbackCell(expr->CallFeedbackId(), cell); | 2680 __ LoadHeapObject(ebx, FeedbackVector()); |
| 2674 __ mov(ebx, cell); | 2681 __ mov(edx, Immediate(Smi::FromInt(expr->CallFeedbackSlot()))); |
| 2675 | 2682 |
| 2676 // Record call targets in unoptimized code. | 2683 // Record call targets in unoptimized code. |
| 2677 CallFunctionStub stub(arg_count, RECORD_CALL_TARGET); | 2684 CallFunctionStub stub(arg_count, RECORD_CALL_TARGET); |
| 2678 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 2685 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
| 2679 __ CallStub(&stub, expr->CallFeedbackId()); | 2686 __ CallStub(&stub); |
| 2680 | 2687 |
| 2681 RecordJSReturnSite(expr); | 2688 RecordJSReturnSite(expr); |
| 2682 // Restore context register. | 2689 // Restore context register. |
| 2683 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2690 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 2684 context()->DropAndPlug(1, eax); | 2691 context()->DropAndPlug(1, eax); |
| 2685 } | 2692 } |
| 2686 | 2693 |
| 2687 | 2694 |
| 2688 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { | 2695 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
| 2689 // Push copy of the first argument or undefined if it doesn't exist. | 2696 // Push copy of the first argument or undefined if it doesn't exist. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2841 // Call the construct call builtin that handles allocation and | 2848 // Call the construct call builtin that handles allocation and |
| 2842 // constructor invocation. | 2849 // constructor invocation. |
| 2843 SetSourcePosition(expr->position()); | 2850 SetSourcePosition(expr->position()); |
| 2844 | 2851 |
| 2845 // Load function and argument count into edi and eax. | 2852 // Load function and argument count into edi and eax. |
| 2846 __ Set(eax, Immediate(arg_count)); | 2853 __ Set(eax, Immediate(arg_count)); |
| 2847 __ mov(edi, Operand(esp, arg_count * kPointerSize)); | 2854 __ mov(edi, Operand(esp, arg_count * kPointerSize)); |
| 2848 | 2855 |
| 2849 // Record call targets in unoptimized code. | 2856 // Record call targets in unoptimized code. |
| 2850 Handle<Object> uninitialized = | 2857 Handle<Object> uninitialized = |
| 2851 TypeFeedbackCells::UninitializedSentinel(isolate()); | 2858 TypeFeedbackInfo::UninitializedSentinel(isolate()); |
| 2852 Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized); | 2859 StoreFeedbackVectorSlot(expr->CallNewFeedbackSlot(), uninitialized); |
| 2853 RecordTypeFeedbackCell(expr->CallNewFeedbackId(), cell); | 2860 __ LoadHeapObject(ebx, FeedbackVector()); |
| 2854 __ mov(ebx, cell); | 2861 __ mov(edx, Immediate(Smi::FromInt(expr->CallNewFeedbackSlot()))); |
| 2855 | 2862 |
| 2856 CallConstructStub stub(RECORD_CALL_TARGET); | 2863 CallConstructStub stub(RECORD_CALL_TARGET); |
| 2857 __ call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL); | 2864 __ call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL); |
| 2858 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 2865 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
| 2859 context()->Plug(eax); | 2866 context()->Plug(eax); |
| 2860 } | 2867 } |
| 2861 | 2868 |
| 2862 | 2869 |
| 2863 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 2870 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
| 2864 ZoneList<Expression*>* args = expr->arguments(); | 2871 ZoneList<Expression*>* args = expr->arguments(); |
| (...skipping 2047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4912 | 4919 |
| 4913 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4920 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4914 Assembler::target_address_at(call_target_address)); | 4921 Assembler::target_address_at(call_target_address)); |
| 4915 return OSR_AFTER_STACK_CHECK; | 4922 return OSR_AFTER_STACK_CHECK; |
| 4916 } | 4923 } |
| 4917 | 4924 |
| 4918 | 4925 |
| 4919 } } // namespace v8::internal | 4926 } } // namespace v8::internal |
| 4920 | 4927 |
| 4921 #endif // V8_TARGET_ARCH_IA32 | 4928 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |