| OLD | NEW |
| 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 23 matching lines...) Expand all Loading... |
| 34 #include "platform.h" | 34 #include "platform.h" |
| 35 | 35 |
| 36 namespace v8 { | 36 namespace v8 { |
| 37 namespace internal { | 37 namespace internal { |
| 38 | 38 |
| 39 | 39 |
| 40 // Used to implement the write barrier by collecting addresses of pointers | 40 // Used to implement the write barrier by collecting addresses of pointers |
| 41 // between spaces. | 41 // between spaces. |
| 42 class WriteBuffer : public AllStatic { | 42 class WriteBuffer : public AllStatic { |
| 43 public: | 43 public: |
| 44 static Address TopAddress() { return reinterpret_cast<Address>(&top_); } | 44 static inline Address TopAddress(); |
| 45 | 45 |
| 46 static void Setup(); | 46 static void Setup(); |
| 47 static void TearDown(); | 47 static void TearDown(); |
| 48 | 48 |
| 49 static inline void Mark(Address addr) { | 49 static inline void Mark(Address addr); |
| 50 *top_++ = addr; | |
| 51 if ((reinterpret_cast<uintptr_t>(top_) & kWriteBufferOverflowBit) != 0) { | |
| 52 ASSERT(top_ == limit_); | |
| 53 Compact(); | |
| 54 } else { | |
| 55 ASSERT(top_ < limit_); | |
| 56 } | |
| 57 } | |
| 58 | 50 |
| 59 static const int kWriteBufferOverflowBit = 1 << 16; | 51 static const int kWriteBufferOverflowBit = 1 << 16; |
| 60 static const int kWriteBufferSize = kWriteBufferOverflowBit; | 52 static const int kWriteBufferSize = kWriteBufferOverflowBit; |
| 61 static const int kHashMapLengthLog2 = 12; | 53 static const int kHashMapLengthLog2 = 12; |
| 62 static const int kHashMapLength = 1 << kHashMapLengthLog2; | 54 static const int kHashMapLength = 1 << kHashMapLengthLog2; |
| 63 | 55 |
| 64 static void Compact(); | 56 static void Compact(); |
| 65 | 57 |
| 66 private: | 58 private: |
| 67 static Address* top_; | |
| 68 static Address* start_; | 59 static Address* start_; |
| 69 static Address* limit_; | 60 static Address* limit_; |
| 70 static VirtualMemory* virtual_memory_; | 61 static VirtualMemory* virtual_memory_; |
| 71 static uintptr_t* hash_map_1_; | 62 static uintptr_t* hash_map_1_; |
| 72 static uintptr_t* hash_map_2_; | 63 static uintptr_t* hash_map_2_; |
| 73 }; | 64 }; |
| 74 | 65 |
| 75 } } // namespace v8::internal | 66 } } // namespace v8::internal |
| 76 | 67 |
| 77 #endif // V8_WRITE_BARRIER_H_ | 68 #endif // V8_WRITE_BARRIER_H_ |
| OLD | NEW |