Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(688)

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 5274002: Version 2.5.8... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 // Remove the pointers stored on the stack. 873 // Remove the pointers stored on the stack.
874 __ bind(loop_statement.break_target()); 874 __ bind(loop_statement.break_target());
875 __ add(Operand(esp), Immediate(5 * kPointerSize)); 875 __ add(Operand(esp), Immediate(5 * kPointerSize));
876 876
877 // Exit and decrement the loop depth. 877 // Exit and decrement the loop depth.
878 __ bind(&exit); 878 __ bind(&exit);
879 decrement_loop_depth(); 879 decrement_loop_depth();
880 } 880 }
881 881
882 882
883 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info) { 883 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info,
884 bool pretenure) {
884 // Use the fast case closure allocation code that allocates in new 885 // Use the fast case closure allocation code that allocates in new
885 // space for nested functions that don't need literals cloning. 886 // space for nested functions that don't need literals cloning.
886 if (scope()->is_function_scope() && info->num_literals() == 0) { 887 if (scope()->is_function_scope() &&
888 info->num_literals() == 0 &&
889 !pretenure) {
887 FastNewClosureStub stub; 890 FastNewClosureStub stub;
888 __ push(Immediate(info)); 891 __ push(Immediate(info));
889 __ CallStub(&stub); 892 __ CallStub(&stub);
890 } else { 893 } else {
891 __ push(esi); 894 __ push(esi);
892 __ push(Immediate(info)); 895 __ push(Immediate(info));
893 __ CallRuntime(Runtime::kNewClosure, 2); 896 __ push(Immediate(pretenure
897 ? Factory::true_value()
898 : Factory::false_value()));
899 __ CallRuntime(Runtime::kNewClosure, 3);
894 } 900 }
895 context()->Plug(eax); 901 context()->Plug(eax);
896 } 902 }
897 903
898 904
899 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { 905 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
900 Comment cmnt(masm_, "[ VariableProxy"); 906 Comment cmnt(masm_, "[ VariableProxy");
901 EmitVariableLoad(expr->var()); 907 EmitVariableLoad(expr->var());
902 } 908 }
903 909
(...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after
3077 __ AbortIfNotString(eax); 3083 __ AbortIfNotString(eax);
3078 } 3084 }
3079 3085
3080 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset)); 3086 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset));
3081 __ IndexFromHash(eax, eax); 3087 __ IndexFromHash(eax, eax);
3082 3088
3083 context()->Plug(eax); 3089 context()->Plug(eax);
3084 } 3090 }
3085 3091
3086 3092
3093 void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList<Expression*>* args) {
3094 Label bailout;
3095 Label done;
3096
3097 ASSERT(args->length() == 2);
3098 // We will leave the separator on the stack until the end of the function.
3099 VisitForStackValue(args->at(1));
3100 // Load this to eax (= array)
3101 VisitForAccumulatorValue(args->at(0));
3102
3103 // All aliases of the same register have disjoint lifetimes.
3104 Register array = eax;
3105 Register result_pos = no_reg;
3106
3107 Register index = edi;
3108
3109 Register current_string_length = ecx; // Will be ecx when live.
3110
3111 Register current_string = edx;
3112
3113 Register scratch = ebx;
3114
3115 Register scratch_2 = esi;
3116 Register new_padding_chars = scratch_2;
3117
3118 Operand separator = Operand(esp, 4 * kPointerSize); // Already pushed.
3119 Operand elements = Operand(esp, 3 * kPointerSize);
3120 Operand result = Operand(esp, 2 * kPointerSize);
3121 Operand padding_chars = Operand(esp, 1 * kPointerSize);
3122 Operand array_length = Operand(esp, 0);
3123 __ sub(Operand(esp), Immediate(4 * kPointerSize));
3124
3125
3126 // Check that eax is a JSArray
3127 __ test(array, Immediate(kSmiTagMask));
3128 __ j(zero, &bailout);
3129 __ CmpObjectType(array, JS_ARRAY_TYPE, scratch);
3130 __ j(not_equal, &bailout);
3131
3132 // Check that the array has fast elements.
3133 __ test_b(FieldOperand(scratch, Map::kBitField2Offset),
3134 1 << Map::kHasFastElements);
3135 __ j(zero, &bailout);
3136
3137 // If the array is empty, return the empty string.
3138 __ mov(scratch, FieldOperand(array, JSArray::kLengthOffset));
3139 __ sar(scratch, 1);
3140 Label non_trivial;
3141 __ j(not_zero, &non_trivial);
3142 __ mov(result, Factory::empty_string());
3143 __ jmp(&done);
3144
3145 __ bind(&non_trivial);
3146 __ mov(array_length, scratch);
3147
3148 __ mov(scratch, FieldOperand(array, JSArray::kElementsOffset));
3149 __ mov(elements, scratch);
3150
3151 // End of array's live range.
3152 result_pos = array;
3153 array = no_reg;
3154
3155
3156 // Check that the separator is a flat ascii string.
3157 __ mov(current_string, separator);
3158 __ test(current_string, Immediate(kSmiTagMask));
3159 __ j(zero, &bailout);
3160 __ mov(scratch, FieldOperand(current_string, HeapObject::kMapOffset));
3161 __ mov_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset));
3162 __ and_(scratch, Immediate(
3163 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask));
3164 __ cmp(scratch, kStringTag | kAsciiStringTag | kSeqStringTag);
3165 __ j(not_equal, &bailout);
3166 // If the separator is the empty string, replace it with NULL.
3167 // The test for NULL is quicker than the empty string test, in a loop.
3168 __ cmp(FieldOperand(current_string, SeqAsciiString::kLengthOffset),
3169 Immediate(0));
3170 Label separator_checked;
3171 __ j(not_zero, &separator_checked);
3172 __ mov(separator, Immediate(0));
3173 __ bind(&separator_checked);
3174
3175 // Check that elements[0] is a flat ascii string, and copy it in new space.
3176 __ mov(scratch, elements);
3177 __ mov(current_string, FieldOperand(scratch, FixedArray::kHeaderSize));
3178 __ test(current_string, Immediate(kSmiTagMask));
3179 __ j(zero, &bailout);
3180 __ mov(scratch, FieldOperand(current_string, HeapObject::kMapOffset));
3181 __ mov_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset));
3182 __ and_(scratch, Immediate(
3183 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask));
3184 __ cmp(scratch, kStringTag | kAsciiStringTag | kSeqStringTag);
3185 __ j(not_equal, &bailout);
3186
3187 // Allocate space to copy it. Round up the size to the alignment granularity.
3188 __ mov(current_string_length,
3189 FieldOperand(current_string, String::kLengthOffset));
3190 __ shr(current_string_length, 1);
3191
3192 // Live registers and stack values:
3193 // current_string_length: length of elements[0].
3194
3195 // New string result in new space = elements[0]
3196 __ AllocateAsciiString(result_pos, current_string_length, scratch_2,
3197 index, no_reg, &bailout);
3198 __ mov(result, result_pos);
3199
3200 // Adjust current_string_length to include padding bytes at end of string.
3201 // Keep track of the number of padding bytes.
3202 __ mov(new_padding_chars, current_string_length);
3203 __ add(Operand(current_string_length), Immediate(kObjectAlignmentMask));
3204 __ and_(Operand(current_string_length), Immediate(~kObjectAlignmentMask));
3205 __ sub(new_padding_chars, Operand(current_string_length));
3206 __ neg(new_padding_chars);
3207 __ mov(padding_chars, new_padding_chars);
3208
3209 Label copy_loop_1_done;
3210 Label copy_loop_1;
3211 __ test(current_string_length, Operand(current_string_length));
3212 __ j(zero, &copy_loop_1_done);
3213 __ bind(&copy_loop_1);
3214 __ sub(Operand(current_string_length), Immediate(kPointerSize));
3215 __ mov(scratch, FieldOperand(current_string, current_string_length,
3216 times_1, SeqAsciiString::kHeaderSize));
3217 __ mov(FieldOperand(result_pos, current_string_length,
3218 times_1, SeqAsciiString::kHeaderSize),
3219 scratch);
3220 __ j(not_zero, &copy_loop_1);
3221 __ bind(&copy_loop_1_done);
3222
3223 __ mov(index, Immediate(1));
3224 // Loop condition: while (index < length).
3225 Label loop;
3226 __ bind(&loop);
3227 __ cmp(index, array_length);
3228 __ j(greater_equal, &done);
3229
3230 // If the separator is the empty string, signalled by NULL, skip it.
3231 Label separator_done;
3232 __ mov(current_string, separator);
3233 __ test(current_string, Operand(current_string));
3234 __ j(zero, &separator_done);
3235
3236 // Append separator to result. It is known to be a flat ascii string.
3237 __ AppendStringToTopOfNewSpace(current_string, current_string_length,
3238 result_pos, scratch, scratch_2, result,
3239 padding_chars, &bailout);
3240 __ bind(&separator_done);
3241
3242 // Add next element of array to the end of the result.
3243 // Get current_string = array[index].
3244 __ mov(scratch, elements);
3245 __ mov(current_string, FieldOperand(scratch, index,
3246 times_pointer_size,
3247 FixedArray::kHeaderSize));
3248 // If current != flat ascii string drop result, return undefined.
3249 __ test(current_string, Immediate(kSmiTagMask));
3250 __ j(zero, &bailout);
3251 __ mov(scratch, FieldOperand(current_string, HeapObject::kMapOffset));
3252 __ mov_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset));
3253 __ and_(scratch, Immediate(
3254 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask));
3255 __ cmp(scratch, kStringTag | kAsciiStringTag | kSeqStringTag);
3256 __ j(not_equal, &bailout);
3257
3258 // Append current to the result.
3259 __ AppendStringToTopOfNewSpace(current_string, current_string_length,
3260 result_pos, scratch, scratch_2, result,
3261 padding_chars, &bailout);
3262 __ add(Operand(index), Immediate(1));
3263 __ jmp(&loop); // End while (index < length).
3264
3265 __ bind(&bailout);
3266 __ mov(result, Factory::undefined_value());
3267 __ bind(&done);
3268 __ mov(eax, result);
3269 // Drop temp values from the stack, and restore context register.
3270 __ add(Operand(esp), Immediate(5 * kPointerSize));
3271
3272 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
3273 context()->Plug(eax);
3274 }
3275
3276
3087 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { 3277 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
3088 Handle<String> name = expr->name(); 3278 Handle<String> name = expr->name();
3089 if (name->length() > 0 && name->Get(0) == '_') { 3279 if (name->length() > 0 && name->Get(0) == '_') {
3090 Comment cmnt(masm_, "[ InlineRuntimeCall"); 3280 Comment cmnt(masm_, "[ InlineRuntimeCall");
3091 EmitInlineRuntimeCall(expr); 3281 EmitInlineRuntimeCall(expr);
3092 return; 3282 return;
3093 } 3283 }
3094 3284
3095 Comment cmnt(masm_, "[ CallRuntime"); 3285 Comment cmnt(masm_, "[ CallRuntime");
3096 ZoneList<Expression*>* args = expr->arguments(); 3286 ZoneList<Expression*>* args = expr->arguments();
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
3758 // And return. 3948 // And return.
3759 __ ret(0); 3949 __ ret(0);
3760 } 3950 }
3761 3951
3762 3952
3763 #undef __ 3953 #undef __
3764 3954
3765 } } // namespace v8::internal 3955 } } // namespace v8::internal
3766 3956
3767 #endif // V8_TARGET_ARCH_IA32 3957 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698