| Index: src/allocation.cc
|
| diff --git a/src/allocation.cc b/src/allocation.cc
|
| index 56eaa1bcbc204a4bbef25bc95472211ef56f1d67..27415c65251f64b0515811bc3344b0c198931fce 100644
|
| --- a/src/allocation.cc
|
| +++ b/src/allocation.cc
|
| @@ -25,9 +25,10 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -#include <stdlib.h>
|
| -
|
| #include "v8.h"
|
| +#include "isolate.h"
|
| +#include "allocation.h"
|
| +
|
| /* TODO(isolates): this is what's included in bleeding_edge
|
| including of v8.h was replaced with these in
|
| http://codereview.chromium.org/5005001/
|
| @@ -42,6 +43,38 @@
|
| namespace v8 {
|
| namespace internal {
|
|
|
| +#ifdef DEBUG
|
| +
|
| +NativeAllocationChecker::NativeAllocationChecker(
|
| + NativeAllocationChecker::NativeAllocationAllowed allowed)
|
| + : allowed_(allowed) {
|
| + if (allowed == DISALLOW) {
|
| + Isolate* isolate = Isolate::Current();
|
| + isolate->set_allocation_disallowed(isolate->allocation_disallowed() + 1);
|
| + }
|
| +}
|
| +
|
| +
|
| +NativeAllocationChecker::~NativeAllocationChecker() {
|
| + Isolate* isolate = Isolate::Current();
|
| + if (allowed_ == DISALLOW) {
|
| + isolate->set_allocation_disallowed(isolate->allocation_disallowed() - 1);
|
| + }
|
| + ASSERT(isolate->allocation_disallowed() >= 0);
|
| +}
|
| +
|
| +
|
| +bool NativeAllocationChecker::allocation_allowed() {
|
| + // TODO(isolates): either find a way to make this work that doesn't
|
| + // require initializing an isolate before we can use malloc or drop
|
| + // it completely.
|
| + return true;
|
| + // return Isolate::Current()->allocation_disallowed() == 0;
|
| +}
|
| +
|
| +#endif // DEBUG
|
| +
|
| +
|
| void* Malloced::New(size_t size) {
|
| ASSERT(NativeAllocationChecker::allocation_allowed());
|
| void* result = malloc(size);
|
|
|