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

Unified Diff: src/allocation.cc

Issue 6529055: [Isolates] Merge crankshaft (r5922 from bleeding_edge). (Closed)
Patch Set: Win32 port Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/allocation.h ('k') | src/allocation-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/allocation.h ('k') | src/allocation-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698