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

Side by Side Diff: src/code-stubs.cc

Issue 12957004: ES6 symbols: turn symbols into a proper primitive type (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 9 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/code-stubs.h ('k') | src/contexts.h » ('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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 503
504 504
505 void ToBooleanStub::Types::Print(StringStream* stream) const { 505 void ToBooleanStub::Types::Print(StringStream* stream) const {
506 if (IsEmpty()) stream->Add("None"); 506 if (IsEmpty()) stream->Add("None");
507 if (Contains(UNDEFINED)) stream->Add("Undefined"); 507 if (Contains(UNDEFINED)) stream->Add("Undefined");
508 if (Contains(BOOLEAN)) stream->Add("Bool"); 508 if (Contains(BOOLEAN)) stream->Add("Bool");
509 if (Contains(NULL_TYPE)) stream->Add("Null"); 509 if (Contains(NULL_TYPE)) stream->Add("Null");
510 if (Contains(SMI)) stream->Add("Smi"); 510 if (Contains(SMI)) stream->Add("Smi");
511 if (Contains(SPEC_OBJECT)) stream->Add("SpecObject"); 511 if (Contains(SPEC_OBJECT)) stream->Add("SpecObject");
512 if (Contains(STRING)) stream->Add("String"); 512 if (Contains(STRING)) stream->Add("String");
513 if (Contains(SYMBOL)) stream->Add("Symbol");
513 if (Contains(HEAP_NUMBER)) stream->Add("HeapNumber"); 514 if (Contains(HEAP_NUMBER)) stream->Add("HeapNumber");
514 } 515 }
515 516
516 517
517 void ToBooleanStub::Types::TraceTransition(Types to) const { 518 void ToBooleanStub::Types::TraceTransition(Types to) const {
518 if (!FLAG_trace_ic) return; 519 if (!FLAG_trace_ic) return;
519 char buffer[100]; 520 char buffer[100];
520 NoAllocationStringAllocator allocator(buffer, 521 NoAllocationStringAllocator allocator(buffer,
521 static_cast<unsigned>(sizeof(buffer))); 522 static_cast<unsigned>(sizeof(buffer)));
522 StringStream stream(&allocator); 523 StringStream stream(&allocator);
(...skipping 19 matching lines...) Expand all
542 } else if (object->IsSmi()) { 543 } else if (object->IsSmi()) {
543 Add(SMI); 544 Add(SMI);
544 return Smi::cast(*object)->value() != 0; 545 return Smi::cast(*object)->value() != 0;
545 } else if (object->IsSpecObject()) { 546 } else if (object->IsSpecObject()) {
546 Add(SPEC_OBJECT); 547 Add(SPEC_OBJECT);
547 return !object->IsUndetectableObject(); 548 return !object->IsUndetectableObject();
548 } else if (object->IsString()) { 549 } else if (object->IsString()) {
549 Add(STRING); 550 Add(STRING);
550 return !object->IsUndetectableObject() && 551 return !object->IsUndetectableObject() &&
551 String::cast(*object)->length() != 0; 552 String::cast(*object)->length() != 0;
553 } else if (object->IsSymbol()) {
554 Add(SYMBOL);
555 return true;
552 } else if (object->IsHeapNumber()) { 556 } else if (object->IsHeapNumber()) {
553 ASSERT(!object->IsUndetectableObject()); 557 ASSERT(!object->IsUndetectableObject());
554 Add(HEAP_NUMBER); 558 Add(HEAP_NUMBER);
555 double value = HeapNumber::cast(*object)->value(); 559 double value = HeapNumber::cast(*object)->value();
556 return value != 0 && !isnan(value); 560 return value != 0 && !isnan(value);
557 } else { 561 } else {
558 // We should never see an internal object at runtime here! 562 // We should never see an internal object at runtime here!
559 UNREACHABLE(); 563 UNREACHABLE();
560 return true; 564 return true;
561 } 565 }
562 } 566 }
563 567
564 568
565 bool ToBooleanStub::Types::NeedsMap() const { 569 bool ToBooleanStub::Types::NeedsMap() const {
566 return Contains(ToBooleanStub::SPEC_OBJECT) 570 return Contains(ToBooleanStub::SPEC_OBJECT)
567 || Contains(ToBooleanStub::STRING) 571 || Contains(ToBooleanStub::STRING)
572 || Contains(ToBooleanStub::SYMBOL)
568 || Contains(ToBooleanStub::HEAP_NUMBER); 573 || Contains(ToBooleanStub::HEAP_NUMBER);
569 } 574 }
570 575
571 576
572 bool ToBooleanStub::Types::CanBeUndetectable() const { 577 bool ToBooleanStub::Types::CanBeUndetectable() const {
573 return Contains(ToBooleanStub::SPEC_OBJECT) 578 return Contains(ToBooleanStub::SPEC_OBJECT)
574 || Contains(ToBooleanStub::STRING); 579 || Contains(ToBooleanStub::STRING);
575 } 580 }
576 581
577 582
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 // already active, as the hooks won't stack. 641 // already active, as the hooks won't stack.
637 if (entry_hook != 0 && entry_hook_ != 0) 642 if (entry_hook != 0 && entry_hook_ != 0)
638 return false; 643 return false;
639 644
640 entry_hook_ = entry_hook; 645 entry_hook_ = entry_hook;
641 return true; 646 return true;
642 } 647 }
643 648
644 649
645 } } // namespace v8::internal 650 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698