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

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

Issue 10413030: Fix prepareElementsForSort crash bug=117879 . This is a back (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.8/
Patch Set: Created 8 years, 7 months 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/version.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 3096 matching lines...) Expand 10 before | Expand all | Expand 10 after
3107 ZoneList<Expression*>* args = expr->arguments(); 3107 ZoneList<Expression*>* args = expr->arguments();
3108 ASSERT(args->length() == 3); 3108 ASSERT(args->length() == 3);
3109 VisitForStackValue(args->at(0)); 3109 VisitForStackValue(args->at(0));
3110 VisitForStackValue(args->at(1)); 3110 VisitForStackValue(args->at(1));
3111 VisitForStackValue(args->at(2)); 3111 VisitForStackValue(args->at(2));
3112 __ CallStub(&stub); 3112 __ CallStub(&stub);
3113 context()->Plug(rax); 3113 context()->Plug(rax);
3114 } 3114 }
3115 3115
3116 3116
3117 void FullCodeGenerator::EmitSwapElements(CallRuntime* expr) {
3118 ZoneList<Expression*>* args = expr->arguments();
3119 ASSERT(args->length() == 3);
3120 VisitForStackValue(args->at(0));
3121 VisitForStackValue(args->at(1));
3122 VisitForStackValue(args->at(2));
3123 Label done;
3124 Label slow_case;
3125 Register object = rax;
3126 Register index_1 = rbx;
3127 Register index_2 = rcx;
3128 Register elements = rdi;
3129 Register temp = rdx;
3130 __ movq(object, Operand(rsp, 2 * kPointerSize));
3131 // Fetch the map and check if array is in fast case.
3132 // Check that object doesn't require security checks and
3133 // has no indexed interceptor.
3134 __ CmpObjectType(object, JS_ARRAY_TYPE, temp);
3135 __ j(not_equal, &slow_case);
3136 __ testb(FieldOperand(temp, Map::kBitFieldOffset),
3137 Immediate(KeyedLoadIC::kSlowCaseBitFieldMask));
3138 __ j(not_zero, &slow_case);
3139
3140 // Check the object's elements are in fast case and writable.
3141 __ movq(elements, FieldOperand(object, JSObject::kElementsOffset));
3142 __ CompareRoot(FieldOperand(elements, HeapObject::kMapOffset),
3143 Heap::kFixedArrayMapRootIndex);
3144 __ j(not_equal, &slow_case);
3145
3146 // Check that both indices are smis.
3147 __ movq(index_1, Operand(rsp, 1 * kPointerSize));
3148 __ movq(index_2, Operand(rsp, 0 * kPointerSize));
3149 __ JumpIfNotBothSmi(index_1, index_2, &slow_case);
3150
3151 // Check that both indices are valid.
3152 // The JSArray length field is a smi since the array is in fast case mode.
3153 __ movq(temp, FieldOperand(object, JSArray::kLengthOffset));
3154 __ SmiCompare(temp, index_1);
3155 __ j(below_equal, &slow_case);
3156 __ SmiCompare(temp, index_2);
3157 __ j(below_equal, &slow_case);
3158
3159 __ SmiToInteger32(index_1, index_1);
3160 __ SmiToInteger32(index_2, index_2);
3161 // Bring addresses into index1 and index2.
3162 __ lea(index_1, FieldOperand(elements, index_1, times_pointer_size,
3163 FixedArray::kHeaderSize));
3164 __ lea(index_2, FieldOperand(elements, index_2, times_pointer_size,
3165 FixedArray::kHeaderSize));
3166
3167 // Swap elements. Use object and temp as scratch registers.
3168 __ movq(object, Operand(index_1, 0));
3169 __ movq(temp, Operand(index_2, 0));
3170 __ movq(Operand(index_2, 0), object);
3171 __ movq(Operand(index_1, 0), temp);
3172
3173 Label no_remembered_set;
3174 __ CheckPageFlag(elements,
3175 temp,
3176 1 << MemoryChunk::SCAN_ON_SCAVENGE,
3177 not_zero,
3178 &no_remembered_set,
3179 Label::kNear);
3180 // Possible optimization: do a check that both values are Smis
3181 // (or them and test against Smi mask.)
3182
3183 // We are swapping two objects in an array and the incremental marker never
3184 // pauses in the middle of scanning a single object. Therefore the
3185 // incremental marker is not disturbed, so we don't need to call the
3186 // RecordWrite stub that notifies the incremental marker.
3187 __ RememberedSetHelper(elements,
3188 index_1,
3189 temp,
3190 kDontSaveFPRegs,
3191 MacroAssembler::kFallThroughAtEnd);
3192 __ RememberedSetHelper(elements,
3193 index_2,
3194 temp,
3195 kDontSaveFPRegs,
3196 MacroAssembler::kFallThroughAtEnd);
3197
3198 __ bind(&no_remembered_set);
3199
3200 // We are done. Drop elements from the stack, and return undefined.
3201 __ addq(rsp, Immediate(3 * kPointerSize));
3202 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
3203 __ jmp(&done);
3204
3205 __ bind(&slow_case);
3206 __ CallRuntime(Runtime::kSwapElements, 3);
3207
3208 __ bind(&done);
3209 context()->Plug(rax);
3210 }
3211
3212
3213 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { 3117 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
3214 ZoneList<Expression*>* args = expr->arguments(); 3118 ZoneList<Expression*>* args = expr->arguments();
3215 ASSERT_EQ(2, args->length()); 3119 ASSERT_EQ(2, args->length());
3216 3120
3217 ASSERT_NE(NULL, args->at(0)->AsLiteral()); 3121 ASSERT_NE(NULL, args->at(0)->AsLiteral());
3218 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); 3122 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value();
3219 3123
3220 Handle<FixedArray> jsfunction_result_caches( 3124 Handle<FixedArray> jsfunction_result_caches(
3221 isolate()->global_context()->jsfunction_result_caches()); 3125 isolate()->global_context()->jsfunction_result_caches());
3222 if (jsfunction_result_caches->length() <= cache_id) { 3126 if (jsfunction_result_caches->length() <= cache_id) {
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
4352 *context_length = 0; 4256 *context_length = 0;
4353 return previous_; 4257 return previous_;
4354 } 4258 }
4355 4259
4356 4260
4357 #undef __ 4261 #undef __
4358 4262
4359 } } // namespace v8::internal 4263 } } // namespace v8::internal
4360 4264
4361 #endif // V8_TARGET_ARCH_X64 4265 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/version.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698