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

Side by Side Diff: src/objects-inl.h

Issue 3031005: [Isolates] Avoid dereferencing Isolate::Current() to check oddball identities... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 10 years, 4 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/objects-debug.cc ('k') | src/prettyprinter.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 } 515 }
516 516
517 517
518 bool Object::IsProxy() { 518 bool Object::IsProxy() {
519 return Object::IsHeapObject() 519 return Object::IsHeapObject()
520 && HeapObject::cast(this)->map()->instance_type() == PROXY_TYPE; 520 && HeapObject::cast(this)->map()->instance_type() == PROXY_TYPE;
521 } 521 }
522 522
523 523
524 bool Object::IsBoolean() { 524 bool Object::IsBoolean() {
525 return IsTrue() || IsFalse(); 525 return IsOddball() &&
526 ((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0);
526 } 527 }
527 528
528 529
529 bool Object::IsJSArray() { 530 bool Object::IsJSArray() {
530 return Object::IsHeapObject() 531 return Object::IsHeapObject()
531 && HeapObject::cast(this)->map()->instance_type() == JS_ARRAY_TYPE; 532 && HeapObject::cast(this)->map()->instance_type() == JS_ARRAY_TYPE;
532 } 533 }
533 534
534 535
535 bool Object::IsJSRegExp() { 536 bool Object::IsJSRegExp() {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 #define MAKE_STRUCT_PREDICATE(NAME, Name, name) \ 654 #define MAKE_STRUCT_PREDICATE(NAME, Name, name) \
654 bool Object::Is##Name() { \ 655 bool Object::Is##Name() { \
655 return Object::IsHeapObject() \ 656 return Object::IsHeapObject() \
656 && HeapObject::cast(this)->map()->instance_type() == NAME##_TYPE; \ 657 && HeapObject::cast(this)->map()->instance_type() == NAME##_TYPE; \
657 } 658 }
658 STRUCT_LIST(MAKE_STRUCT_PREDICATE) 659 STRUCT_LIST(MAKE_STRUCT_PREDICATE)
659 #undef MAKE_STRUCT_PREDICATE 660 #undef MAKE_STRUCT_PREDICATE
660 661
661 662
662 bool Object::IsUndefined() { 663 bool Object::IsUndefined() {
663 return this == HEAP->undefined_value(); 664 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kUndefined;
664 } 665 }
665 666
666 667
667 bool Object::IsTheHole() { 668 bool Object::IsTheHole() {
668 return this == HEAP->the_hole_value(); 669 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kTheHole;
669 } 670 }
670 671
671 672
672 bool Object::IsNull() { 673 bool Object::IsNull() {
673 return this == HEAP->null_value(); 674 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kNull;
674 } 675 }
675 676
676 677
677 bool Object::IsTrue() { 678 bool Object::IsTrue() {
678 return this == HEAP->true_value(); 679 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kTrue;
679 } 680 }
680 681
681 682
682 bool Object::IsFalse() { 683 bool Object::IsFalse() {
683 return this == HEAP->false_value(); 684 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kFalse;
684 } 685 }
685 686
686 687
687 double Object::Number() { 688 double Object::Number() {
688 ASSERT(IsNumber()); 689 ASSERT(IsNumber());
689 return IsSmi() 690 return IsSmi()
690 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value()) 691 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value())
691 : reinterpret_cast<HeapNumber*>(this)->value(); 692 : reinterpret_cast<HeapNumber*>(this)->value();
692 } 693 }
693 694
694 695
695
696 Object* Object::ToSmi() { 696 Object* Object::ToSmi() {
697 if (IsSmi()) return this; 697 if (IsSmi()) return this;
698 if (IsHeapNumber()) { 698 if (IsHeapNumber()) {
699 double value = HeapNumber::cast(this)->value(); 699 double value = HeapNumber::cast(this)->value();
700 int int_value = FastD2I(value); 700 int int_value = FastD2I(value);
701 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { 701 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) {
702 return Smi::FromInt(int_value); 702 return Smi::FromInt(int_value);
703 } 703 }
704 } 704 }
705 return Failure::Exception(); 705 return Failure::Exception();
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 set_map(Map::cast(obj)); 1196 set_map(Map::cast(obj));
1197 initialize_elements(); 1197 initialize_elements();
1198 return this; 1198 return this;
1199 } 1199 }
1200 1200
1201 1201
1202 ACCESSORS(Oddball, to_string, String, kToStringOffset) 1202 ACCESSORS(Oddball, to_string, String, kToStringOffset)
1203 ACCESSORS(Oddball, to_number, Object, kToNumberOffset) 1203 ACCESSORS(Oddball, to_number, Object, kToNumberOffset)
1204 1204
1205 1205
1206 byte Oddball::kind() {
1207 return READ_BYTE_FIELD(this, kKindOffset);
1208 }
1209
1210
1211 void Oddball::set_kind(byte value) {
1212 WRITE_BYTE_FIELD(this, kKindOffset, value);
1213 }
1214
1215
1206 Object* JSGlobalPropertyCell::value() { 1216 Object* JSGlobalPropertyCell::value() {
1207 return READ_FIELD(this, kValueOffset); 1217 return READ_FIELD(this, kValueOffset);
1208 } 1218 }
1209 1219
1210 1220
1211 void JSGlobalPropertyCell::set_value(Object* val, WriteBarrierMode ignored) { 1221 void JSGlobalPropertyCell::set_value(Object* val, WriteBarrierMode ignored) {
1212 // The write barrier is not used for global property cells. 1222 // The write barrier is not used for global property cells.
1213 ASSERT(!val->IsJSGlobalPropertyCell()); 1223 ASSERT(!val->IsJSGlobalPropertyCell());
1214 WRITE_FIELD(this, kValueOffset, val); 1224 WRITE_FIELD(this, kValueOffset, val);
1215 } 1225 }
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
2708 return Context::cast(READ_FIELD(this, kContextOffset)); 2718 return Context::cast(READ_FIELD(this, kContextOffset));
2709 } 2719 }
2710 2720
2711 2721
2712 Object* JSFunction::unchecked_context() { 2722 Object* JSFunction::unchecked_context() {
2713 return READ_FIELD(this, kContextOffset); 2723 return READ_FIELD(this, kContextOffset);
2714 } 2724 }
2715 2725
2716 2726
2717 void JSFunction::set_context(Object* value) { 2727 void JSFunction::set_context(Object* value) {
2718 ASSERT(value == HEAP->undefined_value() || value->IsContext()); 2728 ASSERT(value->IsUndefined() || value->IsContext());
2719 WRITE_FIELD(this, kContextOffset, value); 2729 WRITE_FIELD(this, kContextOffset, value);
2720 WRITE_BARRIER(this, kContextOffset); 2730 WRITE_BARRIER(this, kContextOffset);
2721 } 2731 }
2722 2732
2723 ACCESSORS(JSFunction, prototype_or_initial_map, Object, 2733 ACCESSORS(JSFunction, prototype_or_initial_map, Object,
2724 kPrototypeOrInitialMapOffset) 2734 kPrototypeOrInitialMapOffset)
2725 2735
2726 2736
2727 Map* JSFunction::initial_map() { 2737 Map* JSFunction::initial_map() {
2728 return Map::cast(prototype_or_initial_map()); 2738 return Map::cast(prototype_or_initial_map());
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
3339 #undef WRITE_INT_FIELD 3349 #undef WRITE_INT_FIELD
3340 #undef READ_SHORT_FIELD 3350 #undef READ_SHORT_FIELD
3341 #undef WRITE_SHORT_FIELD 3351 #undef WRITE_SHORT_FIELD
3342 #undef READ_BYTE_FIELD 3352 #undef READ_BYTE_FIELD
3343 #undef WRITE_BYTE_FIELD 3353 #undef WRITE_BYTE_FIELD
3344 3354
3345 3355
3346 } } // namespace v8::internal 3356 } } // namespace v8::internal
3347 3357
3348 #endif // V8_OBJECTS_INL_H_ 3358 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/prettyprinter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698