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

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

Issue 596122: Some string optimizations: (Closed)
Patch Set: Undo unnecessary optimizations. Created 10 years, 10 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
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 5381 matching lines...) Expand 10 before | Expand all | Expand 10 after
5392 Result temp = allocator()->Allocate(); 5392 Result temp = allocator()->Allocate();
5393 ASSERT(temp.is_valid()); 5393 ASSERT(temp.is_valid());
5394 // Check if the object is a JS array or not. 5394 // Check if the object is a JS array or not.
5395 __ CmpObjectType(value.reg(), JS_ARRAY_TYPE, temp.reg()); 5395 __ CmpObjectType(value.reg(), JS_ARRAY_TYPE, temp.reg());
5396 value.Unuse(); 5396 value.Unuse();
5397 temp.Unuse(); 5397 temp.Unuse();
5398 destination()->Split(equal); 5398 destination()->Split(equal);
5399 } 5399 }
5400 5400
5401 5401
5402 void CodeGenerator::GenerateIsRegExp(ZoneList<Expression*>* args) {
5403 ASSERT(args->length() == 1);
5404 Load(args->at(0));
5405 Result value = frame_->Pop();
5406 value.ToRegister();
5407 ASSERT(value.is_valid());
5408 __ test(value.reg(), Immediate(kSmiTagMask));
5409 destination()->false_target()->Branch(equal);
5410 // It is a heap object - get map.
5411 Result temp = allocator()->Allocate();
5412 ASSERT(temp.is_valid());
5413 // Check if the object is a regexp.
5414 __ CmpObjectType(value.reg(), JS_REGEXP_TYPE, temp.reg());
5415 value.Unuse();
5416 temp.Unuse();
5417 destination()->Split(equal);
5418 }
5419
5420
5402 void CodeGenerator::GenerateIsObject(ZoneList<Expression*>* args) { 5421 void CodeGenerator::GenerateIsObject(ZoneList<Expression*>* args) {
5403 // This generates a fast version of: 5422 // This generates a fast version of:
5404 // (typeof(arg) === 'object' || %_ClassOf(arg) == 'RegExp') 5423 // (typeof(arg) === 'object' || %_ClassOf(arg) == 'RegExp')
5405 ASSERT(args->length() == 1); 5424 ASSERT(args->length() == 1);
5406 Load(args->at(0)); 5425 Load(args->at(0));
5407 Result obj = frame_->Pop(); 5426 Result obj = frame_->Pop();
5408 obj.ToRegister(); 5427 obj.ToRegister();
5409 5428
5410 __ test(obj.reg(), Immediate(kSmiTagMask)); 5429 __ test(obj.reg(), Immediate(kSmiTagMask));
5411 destination()->false_target()->Branch(zero); 5430 destination()->false_target()->Branch(zero);
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
6340 __ test(answer.reg(), Immediate(kSmiTagMask)); 6359 __ test(answer.reg(), Immediate(kSmiTagMask));
6341 destination()->false_target()->Branch(zero); 6360 destination()->false_target()->Branch(zero);
6342 6361
6343 // It can be an undetectable string object. 6362 // It can be an undetectable string object.
6344 Result temp = allocator()->Allocate(); 6363 Result temp = allocator()->Allocate();
6345 ASSERT(temp.is_valid()); 6364 ASSERT(temp.is_valid());
6346 __ mov(temp.reg(), FieldOperand(answer.reg(), HeapObject::kMapOffset)); 6365 __ mov(temp.reg(), FieldOperand(answer.reg(), HeapObject::kMapOffset));
6347 __ movzx_b(temp.reg(), FieldOperand(temp.reg(), Map::kBitFieldOffset)); 6366 __ movzx_b(temp.reg(), FieldOperand(temp.reg(), Map::kBitFieldOffset));
6348 __ test(temp.reg(), Immediate(1 << Map::kIsUndetectable)); 6367 __ test(temp.reg(), Immediate(1 << Map::kIsUndetectable));
6349 destination()->false_target()->Branch(not_zero); 6368 destination()->false_target()->Branch(not_zero);
6350 __ mov(temp.reg(), FieldOperand(answer.reg(), HeapObject::kMapOffset)); 6369 __ CmpObjectType(answer.reg(), FIRST_NONSTRING_TYPE, temp.reg());
6351 __ movzx_b(temp.reg(),
6352 FieldOperand(temp.reg(), Map::kInstanceTypeOffset));
6353 __ cmp(temp.reg(), FIRST_NONSTRING_TYPE);
6354 temp.Unuse(); 6370 temp.Unuse();
6355 answer.Unuse(); 6371 answer.Unuse();
6356 destination()->Split(less); 6372 destination()->Split(below);
6357 6373
6358 } else if (check->Equals(Heap::boolean_symbol())) { 6374 } else if (check->Equals(Heap::boolean_symbol())) {
6359 __ cmp(answer.reg(), Factory::true_value()); 6375 __ cmp(answer.reg(), Factory::true_value());
6360 destination()->true_target()->Branch(equal); 6376 destination()->true_target()->Branch(equal);
6361 __ cmp(answer.reg(), Factory::false_value()); 6377 __ cmp(answer.reg(), Factory::false_value());
6362 answer.Unuse(); 6378 answer.Unuse();
6363 destination()->Split(equal); 6379 destination()->Split(equal);
6364 6380
6365 } else if (check->Equals(Heap::undefined_symbol())) { 6381 } else if (check->Equals(Heap::undefined_symbol())) {
6366 __ cmp(answer.reg(), Factory::undefined_value()); 6382 __ cmp(answer.reg(), Factory::undefined_value());
(...skipping 4369 matching lines...) Expand 10 before | Expand all | Expand 10 after
10736 10752
10737 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 10753 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
10738 // tagged as a small integer. 10754 // tagged as a small integer.
10739 __ bind(&runtime); 10755 __ bind(&runtime);
10740 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1); 10756 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1);
10741 } 10757 }
10742 10758
10743 #undef __ 10759 #undef __
10744 10760
10745 } } // namespace v8::internal 10761 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | src/macros.py » ('j') | src/macros.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698