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

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

Issue 3836001: Get rid of requested size in RetryAfterGC. (Closed)
Patch Set: Created 10 years, 2 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
« no previous file with comments | « src/objects.cc ('k') | src/runtime.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 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 bool Failure::IsInternalError() const { 837 bool Failure::IsInternalError() const {
838 return type() == INTERNAL_ERROR; 838 return type() == INTERNAL_ERROR;
839 } 839 }
840 840
841 841
842 bool Failure::IsOutOfMemoryException() const { 842 bool Failure::IsOutOfMemoryException() const {
843 return type() == OUT_OF_MEMORY_EXCEPTION; 843 return type() == OUT_OF_MEMORY_EXCEPTION;
844 } 844 }
845 845
846 846
847 int Failure::requested() const {
848 const int kShiftBits =
849 kFailureTypeTagSize + kSpaceTagSize - kObjectAlignmentBits;
850 STATIC_ASSERT(kShiftBits >= 0);
851 ASSERT(type() == RETRY_AFTER_GC);
852 return static_cast<int>(value() >> kShiftBits);
853 }
854
855
856 AllocationSpace Failure::allocation_space() const { 847 AllocationSpace Failure::allocation_space() const {
857 ASSERT_EQ(RETRY_AFTER_GC, type()); 848 ASSERT_EQ(RETRY_AFTER_GC, type());
858 return static_cast<AllocationSpace>((value() >> kFailureTypeTagSize) 849 return static_cast<AllocationSpace>((value() >> kFailureTypeTagSize)
859 & kSpaceTagMask); 850 & kSpaceTagMask);
860 } 851 }
861 852
862 853
863 Failure* Failure::InternalError() { 854 Failure* Failure::InternalError() {
864 return Construct(INTERNAL_ERROR); 855 return Construct(INTERNAL_ERROR);
865 } 856 }
866 857
867 858
868 Failure* Failure::Exception() { 859 Failure* Failure::Exception() {
869 return Construct(EXCEPTION); 860 return Construct(EXCEPTION);
870 } 861 }
871 862
872 863
873 Failure* Failure::OutOfMemoryException() { 864 Failure* Failure::OutOfMemoryException() {
874 return Construct(OUT_OF_MEMORY_EXCEPTION); 865 return Construct(OUT_OF_MEMORY_EXCEPTION);
875 } 866 }
876 867
877 868
878 intptr_t Failure::value() const { 869 intptr_t Failure::value() const {
879 return static_cast<intptr_t>( 870 return static_cast<intptr_t>(
880 reinterpret_cast<uintptr_t>(this) >> kFailureTagSize); 871 reinterpret_cast<uintptr_t>(this) >> kFailureTagSize);
881 } 872 }
882 873
883 874
884 Failure* Failure::RetryAfterGC(int requested_bytes) { 875 Failure* Failure::RetryAfterGC() {
885 // Assert that the space encoding fits in the three bytes allotted for it. 876 return RetryAfterGC(NEW_SPACE);
886 ASSERT((LAST_SPACE & ~kSpaceTagMask) == 0);
887 uintptr_t requested =
888 static_cast<uintptr_t>(requested_bytes >> kObjectAlignmentBits);
889 int tag_bits = kSpaceTagSize + kFailureTypeTagSize + kFailureTagSize;
890 if (((requested << tag_bits) >> tag_bits) != requested) {
891 // No room for entire requested size in the bits. Round down to
892 // maximally representable size.
893 requested = static_cast<intptr_t>(
894 (~static_cast<uintptr_t>(0)) >> (tag_bits + 1));
895 }
896 int value = static_cast<int>(requested << kSpaceTagSize) | NEW_SPACE;
897 return Construct(RETRY_AFTER_GC, value);
898 } 877 }
899 878
900 879
880 Failure* Failure::RetryAfterGC(AllocationSpace space) {
881 ASSERT((space & ~kSpaceTagMask) == 0);
882 return Construct(RETRY_AFTER_GC, space);
883 }
884
885
901 Failure* Failure::Construct(Type type, intptr_t value) { 886 Failure* Failure::Construct(Type type, intptr_t value) {
902 uintptr_t info = 887 uintptr_t info =
903 (static_cast<uintptr_t>(value) << kFailureTypeTagSize) | type; 888 (static_cast<uintptr_t>(value) << kFailureTypeTagSize) | type;
904 ASSERT(((info << kFailureTagSize) >> kFailureTagSize) == info); 889 ASSERT(((info << kFailureTagSize) >> kFailureTagSize) == info);
905 return reinterpret_cast<Failure*>((info << kFailureTagSize) | kFailureTag); 890 return reinterpret_cast<Failure*>((info << kFailureTagSize) | kFailureTag);
906 } 891 }
907 892
908 893
909 bool Smi::IsValid(intptr_t value) { 894 bool Smi::IsValid(intptr_t value) {
910 #ifdef DEBUG 895 #ifdef DEBUG
(...skipping 2639 matching lines...) Expand 10 before | Expand all | Expand 10 after
3550 #undef WRITE_INT_FIELD 3535 #undef WRITE_INT_FIELD
3551 #undef READ_SHORT_FIELD 3536 #undef READ_SHORT_FIELD
3552 #undef WRITE_SHORT_FIELD 3537 #undef WRITE_SHORT_FIELD
3553 #undef READ_BYTE_FIELD 3538 #undef READ_BYTE_FIELD
3554 #undef WRITE_BYTE_FIELD 3539 #undef WRITE_BYTE_FIELD
3555 3540
3556 3541
3557 } } // namespace v8::internal 3542 } } // namespace v8::internal
3558 3543
3559 #endif // V8_OBJECTS_INL_H_ 3544 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698