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

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

Issue 15743006: Improve SeqStringSetChar implementation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: small fix Created 7 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/ia32/codegen-ia32.cc ('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 3355 matching lines...) Expand 10 before | Expand all | Expand 10 after
3366 __ jmp(&done); 3366 __ jmp(&done);
3367 } 3367 }
3368 3368
3369 __ bind(&not_date_object); 3369 __ bind(&not_date_object);
3370 __ CallRuntime(Runtime::kThrowNotDateError, 0); 3370 __ CallRuntime(Runtime::kThrowNotDateError, 0);
3371 __ bind(&done); 3371 __ bind(&done);
3372 context()->Plug(result); 3372 context()->Plug(result);
3373 } 3373 }
3374 3374
3375 3375
3376 void FullCodeGenerator::EmitSeqStringSetCharCheck(Register string,
3377 Register index,
3378 Register value,
3379 uint32_t encoding_mask) {
3380 __ test(index, Immediate(kSmiTagMask));
3381 __ Check(zero, "Non-smi index");
3382 __ test(value, Immediate(kSmiTagMask));
3383 __ Check(zero, "Non-smi value");
3384
3385 __ cmp(index, FieldOperand(string, String::kLengthOffset));
3386 __ Check(less, "Index is too large");
3387
3388 __ cmp(index, Immediate(Smi::FromInt(0)));
3389 __ Check(greater_equal, "Index is negative");
3390
3391 __ push(value);
3392 __ mov(value, FieldOperand(string, HeapObject::kMapOffset));
3393 __ movzx_b(value, FieldOperand(value, Map::kInstanceTypeOffset));
3394
3395 __ and_(value, Immediate(kStringRepresentationMask | kStringEncodingMask));
3396 __ cmp(value, Immediate(encoding_mask));
3397 __ Check(equal, "Unexpected string type");
3398 __ pop(value);
3399 }
3400
3401
3376 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { 3402 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) {
3377 ZoneList<Expression*>* args = expr->arguments(); 3403 ZoneList<Expression*>* args = expr->arguments();
3378 ASSERT_EQ(3, args->length()); 3404 ASSERT_EQ(3, args->length());
3379 3405
3406 Register string = eax;
3407 Register index = ebx;
3408 Register value = ecx;
3409
3380 VisitForStackValue(args->at(1)); // index 3410 VisitForStackValue(args->at(1)); // index
3381 VisitForStackValue(args->at(2)); // value 3411 VisitForStackValue(args->at(2)); // value
3382 __ pop(ecx); 3412 __ pop(value);
3383 __ pop(ebx); 3413 __ pop(index);
3384 VisitForAccumulatorValue(args->at(0)); // string 3414 VisitForAccumulatorValue(args->at(0)); // string
3385 3415
3386 static const String::Encoding encoding = String::ONE_BYTE_ENCODING; 3416
3387 SeqStringSetCharGenerator::Generate(masm_, encoding, eax, ebx, ecx); 3417 if (FLAG_debug_code) {
3388 context()->Plug(eax); 3418 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag;
3419 EmitSeqStringSetCharCheck(string, index, value, one_byte_seq_type);
3420 }
3421
3422 __ SmiUntag(value);
3423 __ SmiUntag(index);
3424 __ mov_b(FieldOperand(string, index, times_1, SeqOneByteString::kHeaderSize),
3425 value);
3426 context()->Plug(string);
3389 } 3427 }
3390 3428
3391 3429
3392 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { 3430 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) {
3393 ZoneList<Expression*>* args = expr->arguments(); 3431 ZoneList<Expression*>* args = expr->arguments();
3394 ASSERT_EQ(3, args->length()); 3432 ASSERT_EQ(3, args->length());
3395 3433
3434 Register string = eax;
3435 Register index = ebx;
3436 Register value = ecx;
3437
3396 VisitForStackValue(args->at(1)); // index 3438 VisitForStackValue(args->at(1)); // index
3397 VisitForStackValue(args->at(2)); // value 3439 VisitForStackValue(args->at(2)); // value
3398 __ pop(ecx); 3440 __ pop(value);
3399 __ pop(ebx); 3441 __ pop(index);
3400 VisitForAccumulatorValue(args->at(0)); // string 3442 VisitForAccumulatorValue(args->at(0)); // string
3401 3443
3402 static const String::Encoding encoding = String::TWO_BYTE_ENCODING; 3444 if (FLAG_debug_code) {
3403 SeqStringSetCharGenerator::Generate(masm_, encoding, eax, ebx, ecx); 3445 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag;
3404 context()->Plug(eax); 3446 EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type);
3447 }
3448
3449 __ SmiUntag(value);
3450 // No need to untag a smi for two-byte addressing.
3451 __ mov_w(FieldOperand(string, index, times_1, SeqTwoByteString::kHeaderSize),
3452 value);
3453 context()->Plug(string);
3405 } 3454 }
3406 3455
3407 3456
3408 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { 3457 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) {
3409 // Load the arguments on the stack and call the runtime function. 3458 // Load the arguments on the stack and call the runtime function.
3410 ZoneList<Expression*>* args = expr->arguments(); 3459 ZoneList<Expression*>* args = expr->arguments();
3411 ASSERT(args->length() == 2); 3460 ASSERT(args->length() == 2);
3412 VisitForStackValue(args->at(0)); 3461 VisitForStackValue(args->at(0));
3413 VisitForStackValue(args->at(1)); 3462 VisitForStackValue(args->at(1));
3414 3463
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
4822 *stack_depth = 0; 4871 *stack_depth = 0;
4823 *context_length = 0; 4872 *context_length = 0;
4824 return previous_; 4873 return previous_;
4825 } 4874 }
4826 4875
4827 #undef __ 4876 #undef __
4828 4877
4829 } } // namespace v8::internal 4878 } } // namespace v8::internal
4830 4879
4831 #endif // V8_TARGET_ARCH_IA32 4880 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698