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

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

Issue 10332271: Fix prepareElementsForSort crash bug=117879. This is a back (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.9/
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 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 3173 matching lines...) Expand 10 before | Expand all | Expand 10 after
3184 ZoneList<Expression*>* args = expr->arguments(); 3184 ZoneList<Expression*>* args = expr->arguments();
3185 ASSERT(args->length() == 3); 3185 ASSERT(args->length() == 3);
3186 VisitForStackValue(args->at(0)); 3186 VisitForStackValue(args->at(0));
3187 VisitForStackValue(args->at(1)); 3187 VisitForStackValue(args->at(1));
3188 VisitForStackValue(args->at(2)); 3188 VisitForStackValue(args->at(2));
3189 __ CallStub(&stub); 3189 __ CallStub(&stub);
3190 context()->Plug(rax); 3190 context()->Plug(rax);
3191 } 3191 }
3192 3192
3193 3193
3194 void FullCodeGenerator::EmitSwapElements(CallRuntime* expr) {
3195 ZoneList<Expression*>* args = expr->arguments();
3196 ASSERT(args->length() == 3);
3197 VisitForStackValue(args->at(0));
3198 VisitForStackValue(args->at(1));
3199 VisitForStackValue(args->at(2));
3200 Label done;
3201 Label slow_case;
3202 Register object = rax;
3203 Register index_1 = rbx;
3204 Register index_2 = rcx;
3205 Register elements = rdi;
3206 Register temp = rdx;
3207 __ movq(object, Operand(rsp, 2 * kPointerSize));
3208 // Fetch the map and check if array is in fast case.
3209 // Check that object doesn't require security checks and
3210 // has no indexed interceptor.
3211 __ CmpObjectType(object, JS_ARRAY_TYPE, temp);
3212 __ j(not_equal, &slow_case);
3213 __ testb(FieldOperand(temp, Map::kBitFieldOffset),
3214 Immediate(KeyedLoadIC::kSlowCaseBitFieldMask));
3215 __ j(not_zero, &slow_case);
3216
3217 // Check the object's elements are in fast case and writable.
3218 __ movq(elements, FieldOperand(object, JSObject::kElementsOffset));
3219 __ CompareRoot(FieldOperand(elements, HeapObject::kMapOffset),
3220 Heap::kFixedArrayMapRootIndex);
3221 __ j(not_equal, &slow_case);
3222
3223 // Check that both indices are smis.
3224 __ movq(index_1, Operand(rsp, 1 * kPointerSize));
3225 __ movq(index_2, Operand(rsp, 0 * kPointerSize));
3226 __ JumpIfNotBothSmi(index_1, index_2, &slow_case);
3227
3228 // Check that both indices are valid.
3229 // The JSArray length field is a smi since the array is in fast case mode.
3230 __ movq(temp, FieldOperand(object, JSArray::kLengthOffset));
3231 __ SmiCompare(temp, index_1);
3232 __ j(below_equal, &slow_case);
3233 __ SmiCompare(temp, index_2);
3234 __ j(below_equal, &slow_case);
3235
3236 __ SmiToInteger32(index_1, index_1);
3237 __ SmiToInteger32(index_2, index_2);
3238 // Bring addresses into index1 and index2.
3239 __ lea(index_1, FieldOperand(elements, index_1, times_pointer_size,
3240 FixedArray::kHeaderSize));
3241 __ lea(index_2, FieldOperand(elements, index_2, times_pointer_size,
3242 FixedArray::kHeaderSize));
3243
3244 // Swap elements. Use object and temp as scratch registers.
3245 __ movq(object, Operand(index_1, 0));
3246 __ movq(temp, Operand(index_2, 0));
3247 __ movq(Operand(index_2, 0), object);
3248 __ movq(Operand(index_1, 0), temp);
3249
3250 Label no_remembered_set;
3251 __ CheckPageFlag(elements,
3252 temp,
3253 1 << MemoryChunk::SCAN_ON_SCAVENGE,
3254 not_zero,
3255 &no_remembered_set,
3256 Label::kNear);
3257 // Possible optimization: do a check that both values are Smis
3258 // (or them and test against Smi mask.)
3259
3260 // We are swapping two objects in an array and the incremental marker never
3261 // pauses in the middle of scanning a single object. Therefore the
3262 // incremental marker is not disturbed, so we don't need to call the
3263 // RecordWrite stub that notifies the incremental marker.
3264 __ RememberedSetHelper(elements,
3265 index_1,
3266 temp,
3267 kDontSaveFPRegs,
3268 MacroAssembler::kFallThroughAtEnd);
3269 __ RememberedSetHelper(elements,
3270 index_2,
3271 temp,
3272 kDontSaveFPRegs,
3273 MacroAssembler::kFallThroughAtEnd);
3274
3275 __ bind(&no_remembered_set);
3276
3277 // We are done. Drop elements from the stack, and return undefined.
3278 __ addq(rsp, Immediate(3 * kPointerSize));
3279 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
3280 __ jmp(&done);
3281
3282 __ bind(&slow_case);
3283 __ CallRuntime(Runtime::kSwapElements, 3);
3284
3285 __ bind(&done);
3286 context()->Plug(rax);
3287 }
3288
3289
3290 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { 3194 void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
3291 ZoneList<Expression*>* args = expr->arguments(); 3195 ZoneList<Expression*>* args = expr->arguments();
3292 ASSERT_EQ(2, args->length()); 3196 ASSERT_EQ(2, args->length());
3293 3197
3294 ASSERT_NE(NULL, args->at(0)->AsLiteral()); 3198 ASSERT_NE(NULL, args->at(0)->AsLiteral());
3295 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); 3199 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value();
3296 3200
3297 Handle<FixedArray> jsfunction_result_caches( 3201 Handle<FixedArray> jsfunction_result_caches(
3298 isolate()->global_context()->jsfunction_result_caches()); 3202 isolate()->global_context()->jsfunction_result_caches());
3299 if (jsfunction_result_caches->length() <= cache_id) { 3203 if (jsfunction_result_caches->length() <= cache_id) {
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
4429 *context_length = 0; 4333 *context_length = 0;
4430 return previous_; 4334 return previous_;
4431 } 4335 }
4432 4336
4433 4337
4434 #undef __ 4338 #undef __
4435 4339
4436 } } // namespace v8::internal 4340 } } // namespace v8::internal
4437 4341
4438 #endif // V8_TARGET_ARCH_X64 4342 #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