| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #ifndef V8_ALLOCATION_INL_H_ | 28 #ifndef V8_ALLOCATION_INL_H_ |
| 29 #define V8_ALLOCATION_INL_H_ | 29 #define V8_ALLOCATION_INL_H_ |
| 30 | 30 |
| 31 #include "allocation.h" | 31 #include "allocation.h" |
| 32 | 32 |
| 33 namespace v8 { | 33 namespace v8 { |
| 34 namespace internal { | 34 namespace internal { |
| 35 | 35 |
| 36 | 36 |
| 37 NativeAllocationChecker::NativeAllocationChecker( | |
| 38 NativeAllocationChecker::NativeAllocationAllowed allowed) | |
| 39 : allowed_(allowed) { | |
| 40 #ifdef DEBUG | |
| 41 if (allowed == DISALLOW) { | |
| 42 Isolate* isolate = Isolate::Current(); | |
| 43 isolate->set_allocation_disallowed(isolate->allocation_disallowed() + 1); | |
| 44 } | |
| 45 #endif | |
| 46 } | |
| 47 | |
| 48 | |
| 49 NativeAllocationChecker::~NativeAllocationChecker() { | |
| 50 #ifdef DEBUG | |
| 51 Isolate* isolate = Isolate::Current(); | |
| 52 if (allowed_ == DISALLOW) { | |
| 53 isolate->set_allocation_disallowed(isolate->allocation_disallowed() - 1); | |
| 54 } | |
| 55 ASSERT(isolate->allocation_disallowed() >= 0); | |
| 56 #endif | |
| 57 } | |
| 58 | |
| 59 | |
| 60 bool NativeAllocationChecker::allocation_allowed() { | |
| 61 #ifdef DEBUG | |
| 62 return Isolate::Current()->allocation_disallowed() == 0; | |
| 63 #else | |
| 64 return true; | |
| 65 #endif // DEBUG | |
| 66 } | |
| 67 | |
| 68 | |
| 69 void* PreallocatedStorage::New(size_t size) { | 37 void* PreallocatedStorage::New(size_t size) { |
| 70 return Isolate::Current()->PreallocatedStorageNew(size); | 38 return Isolate::Current()->PreallocatedStorageNew(size); |
| 71 } | 39 } |
| 72 | 40 |
| 73 | 41 |
| 74 void PreallocatedStorage::Delete(void* p) { | 42 void PreallocatedStorage::Delete(void* p) { |
| 75 return Isolate::Current()->PreallocatedStorageDelete(p); | 43 return Isolate::Current()->PreallocatedStorageDelete(p); |
| 76 } | 44 } |
| 77 | 45 |
| 78 | 46 |
| 79 } } // namespace v8::internal | 47 } } // namespace v8::internal |
| 80 | 48 |
| 81 #endif // V8_ALLOCATION_INL_H_ | 49 #endif // V8_ALLOCATION_INL_H_ |
| OLD | NEW |