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

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

Issue 6689006: Implement %_IsStringWrapperSafeForDefaultValue in full code generators. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 8 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/arm/full-codegen-arm.cc ('k') | src/x64/full-codegen-x64.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 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 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 2451
2452 VisitForAccumulatorValue(args->at(0)); 2452 VisitForAccumulatorValue(args->at(0));
2453 2453
2454 Label materialize_true, materialize_false; 2454 Label materialize_true, materialize_false;
2455 Label* if_true = NULL; 2455 Label* if_true = NULL;
2456 Label* if_false = NULL; 2456 Label* if_false = NULL;
2457 Label* fall_through = NULL; 2457 Label* fall_through = NULL;
2458 context()->PrepareTest(&materialize_true, &materialize_false, 2458 context()->PrepareTest(&materialize_true, &materialize_false,
2459 &if_true, &if_false, &fall_through); 2459 &if_true, &if_false, &fall_through);
2460 2460
2461 // TODO(3110205): Implement this. 2461 if (FLAG_debug_code) __ AbortIfSmi(eax);
2462 // Currently unimplemented. Emit false, a safe choice. 2462
2463 // Check whether this map has already been checked to be safe for default
2464 // valueOf.
2465 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
2466 __ test_b(FieldOperand(ebx, Map::kBitField2Offset),
2467 1 << Map::kStringWrapperSafeForDefaultValueOf);
2468 __ j(not_zero, if_true);
2469
2470 // Check for fast case object. Return false for slow case objects.
2471 __ mov(ecx, FieldOperand(eax, JSObject::kPropertiesOffset));
2472 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset));
2473 __ cmp(ecx, FACTORY->hash_table_map());
2474 __ j(equal, if_false);
2475
2476 // Look for valueOf symbol in the descriptor array, and indicate false if
2477 // found. The type is not checked, so if it is a transition it is a false
2478 // negative.
2479 __ mov(ebx, FieldOperand(ebx, Map::kInstanceDescriptorsOffset));
2480 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset));
2481 // ebx: descriptor array
2482 // ecx: length of descriptor array
2483 // Calculate the end of the descriptor array.
2484 STATIC_ASSERT(kSmiTag == 0);
2485 STATIC_ASSERT(kSmiTagSize == 1);
2486 STATIC_ASSERT(kPointerSize == 4);
2487 __ lea(ecx, Operand(ebx, ecx, times_2, FixedArray::kHeaderSize));
2488 // Calculate location of the first key name.
2489 __ add(Operand(ebx),
2490 Immediate(FixedArray::kHeaderSize +
2491 DescriptorArray::kFirstIndex * kPointerSize));
2492 // Loop through all the keys in the descriptor array. If one of these is the
2493 // symbol valueOf the result is false.
2494 Label entry, loop;
2495 __ jmp(&entry);
2496 __ bind(&loop);
2497 __ mov(edx, FieldOperand(ebx, 0));
2498 __ cmp(edx, FACTORY->value_of_symbol());
2499 __ j(equal, if_false);
2500 __ add(Operand(ebx), Immediate(kPointerSize));
2501 __ bind(&entry);
2502 __ cmp(ebx, Operand(ecx));
2503 __ j(not_equal, &loop);
2504
2505 // Reload map as register ebx was used as temporary above.
2506 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
2507
2508 // If a valueOf property is not found on the object check that it's
2509 // prototype is the un-modified String prototype. If not result is false.
2510 __ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset));
2511 __ test(ecx, Immediate(kSmiTagMask));
2512 __ j(zero, if_false);
2513 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset));
2514 __ mov(edx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)));
2515 __ mov(edx,
2516 FieldOperand(edx, GlobalObject::kGlobalContextOffset));
2517 __ cmp(ecx,
2518 ContextOperand(edx,
2519 Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX));
2520 __ j(not_equal, if_false);
2521 // Set the bit in the map to indicate that it has been checked safe for
2522 // default valueOf and set true result.
2523 __ or_(FieldOperand(ebx, Map::kBitField2Offset),
2524 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf));
2525 __ jmp(if_true);
2526
2463 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); 2527 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2464 __ jmp(if_false);
2465 context()->Plug(if_true, if_false); 2528 context()->Plug(if_true, if_false);
2466 } 2529 }
2467 2530
2468 2531
2469 void FullCodeGenerator::EmitIsFunction(ZoneList<Expression*>* args) { 2532 void FullCodeGenerator::EmitIsFunction(ZoneList<Expression*>* args) {
2470 ASSERT(args->length() == 1); 2533 ASSERT(args->length() == 1);
2471 2534
2472 VisitForAccumulatorValue(args->at(0)); 2535 VisitForAccumulatorValue(args->at(0));
2473 2536
2474 Label materialize_true, materialize_false; 2537 Label materialize_true, materialize_false;
(...skipping 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after
4291 // And return. 4354 // And return.
4292 __ ret(0); 4355 __ ret(0);
4293 } 4356 }
4294 4357
4295 4358
4296 #undef __ 4359 #undef __
4297 4360
4298 } } // namespace v8::internal 4361 } } // namespace v8::internal
4299 4362
4300 #endif // V8_TARGET_ARCH_IA32 4363 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698