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

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

Issue 72813004: Fixed crashes exposed though fuzzing. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix nits Created 7 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/hydrogen-instructions.h ('k') | src/ia32/lithium-codegen-ia32.cc » ('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 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 3422 matching lines...) Expand 10 before | Expand all | Expand 10 after
3433 __ jmp(&done); 3433 __ jmp(&done);
3434 } 3434 }
3435 3435
3436 __ bind(&not_date_object); 3436 __ bind(&not_date_object);
3437 __ CallRuntime(Runtime::kThrowNotDateError, 0); 3437 __ CallRuntime(Runtime::kThrowNotDateError, 0);
3438 __ bind(&done); 3438 __ bind(&done);
3439 context()->Plug(result); 3439 context()->Plug(result);
3440 } 3440 }
3441 3441
3442 3442
3443 void FullCodeGenerator::EmitSeqStringSetCharCheck(Register string,
3444 Register index,
3445 Register value,
3446 uint32_t encoding_mask) {
3447 __ test(index, Immediate(kSmiTagMask));
3448 __ Check(zero, kNonSmiIndex);
3449 __ test(value, Immediate(kSmiTagMask));
3450 __ Check(zero, kNonSmiValue);
3451
3452 __ cmp(index, FieldOperand(string, String::kLengthOffset));
3453 __ Check(less, kIndexIsTooLarge);
3454
3455 __ cmp(index, Immediate(Smi::FromInt(0)));
3456 __ Check(greater_equal, kIndexIsNegative);
3457
3458 __ push(value);
3459 __ mov(value, FieldOperand(string, HeapObject::kMapOffset));
3460 __ movzx_b(value, FieldOperand(value, Map::kInstanceTypeOffset));
3461
3462 __ and_(value, Immediate(kStringRepresentationMask | kStringEncodingMask));
3463 __ cmp(value, Immediate(encoding_mask));
3464 __ Check(equal, kUnexpectedStringType);
3465 __ pop(value);
3466 }
3467
3468
3469 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { 3443 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) {
3470 ZoneList<Expression*>* args = expr->arguments(); 3444 ZoneList<Expression*>* args = expr->arguments();
3471 ASSERT_EQ(3, args->length()); 3445 ASSERT_EQ(3, args->length());
3472 3446
3473 Register string = eax; 3447 Register string = eax;
3474 Register index = ebx; 3448 Register index = ebx;
3475 Register value = ecx; 3449 Register value = ecx;
3476 3450
3477 VisitForStackValue(args->at(1)); // index 3451 VisitForStackValue(args->at(1)); // index
3478 VisitForStackValue(args->at(2)); // value 3452 VisitForStackValue(args->at(2)); // value
3479 __ pop(value); 3453 __ pop(value);
3480 __ pop(index); 3454 __ pop(index);
3481 VisitForAccumulatorValue(args->at(0)); // string 3455 VisitForAccumulatorValue(args->at(0)); // string
3482 3456
3483
3484 if (FLAG_debug_code) { 3457 if (FLAG_debug_code) {
3485 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; 3458 __ test(value, Immediate(kSmiTagMask));
3486 EmitSeqStringSetCharCheck(string, index, value, one_byte_seq_type); 3459 __ ThrowIf(not_zero, kNonSmiValue);
3460 __ test(index, Immediate(kSmiTagMask));
3461 __ ThrowIf(not_zero, kNonSmiValue);
3487 } 3462 }
3488 3463
3489 __ SmiUntag(value); 3464 __ SmiUntag(value);
3490 __ SmiUntag(index); 3465 __ SmiUntag(index);
3466
3467 if (FLAG_debug_code) {
3468 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag;
3469 __ EmitSeqStringSetCharCheck(string, index, value, one_byte_seq_type);
3470 }
3471
3491 __ mov_b(FieldOperand(string, index, times_1, SeqOneByteString::kHeaderSize), 3472 __ mov_b(FieldOperand(string, index, times_1, SeqOneByteString::kHeaderSize),
3492 value); 3473 value);
3493 context()->Plug(string); 3474 context()->Plug(string);
3494 } 3475 }
3495 3476
3496 3477
3497 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { 3478 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) {
3498 ZoneList<Expression*>* args = expr->arguments(); 3479 ZoneList<Expression*>* args = expr->arguments();
3499 ASSERT_EQ(3, args->length()); 3480 ASSERT_EQ(3, args->length());
3500 3481
3501 Register string = eax; 3482 Register string = eax;
3502 Register index = ebx; 3483 Register index = ebx;
3503 Register value = ecx; 3484 Register value = ecx;
3504 3485
3505 VisitForStackValue(args->at(1)); // index 3486 VisitForStackValue(args->at(1)); // index
3506 VisitForStackValue(args->at(2)); // value 3487 VisitForStackValue(args->at(2)); // value
3507 __ pop(value); 3488 __ pop(value);
3508 __ pop(index); 3489 __ pop(index);
3509 VisitForAccumulatorValue(args->at(0)); // string 3490 VisitForAccumulatorValue(args->at(0)); // string
3510 3491
3511 if (FLAG_debug_code) { 3492 if (FLAG_debug_code) {
3493 __ test(value, Immediate(kSmiTagMask));
3494 __ ThrowIf(not_zero, kNonSmiValue);
3495 __ test(index, Immediate(kSmiTagMask));
3496 __ ThrowIf(not_zero, kNonSmiValue);
3497 __ SmiUntag(index);
3512 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; 3498 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag;
3513 EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type); 3499 __ EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type);
3500 __ SmiTag(index);
3514 } 3501 }
3515 3502
3516 __ SmiUntag(value); 3503 __ SmiUntag(value);
3517 // No need to untag a smi for two-byte addressing. 3504 // No need to untag a smi for two-byte addressing.
3518 __ mov_w(FieldOperand(string, index, times_1, SeqTwoByteString::kHeaderSize), 3505 __ mov_w(FieldOperand(string, index, times_1, SeqTwoByteString::kHeaderSize),
3519 value); 3506 value);
3520 context()->Plug(string); 3507 context()->Plug(string);
3521 } 3508 }
3522 3509
3523 3510
(...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after
4968 4955
4969 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4956 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4970 Assembler::target_address_at(call_target_address)); 4957 Assembler::target_address_at(call_target_address));
4971 return OSR_AFTER_STACK_CHECK; 4958 return OSR_AFTER_STACK_CHECK;
4972 } 4959 }
4973 4960
4974 4961
4975 } } // namespace v8::internal 4962 } } // namespace v8::internal
4976 4963
4977 #endif // V8_TARGET_ARCH_IA32 4964 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698