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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/allocation.h ('k') | src/allocation-inl.h » ('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 2008 the V8 project authors. All rights reserved. 1 // Copyright 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include "v8.h"
29 #include "isolate.h"
30 #include "allocation.h"
29 31
30 #include "v8.h"
31 /* TODO(isolates): this is what's included in bleeding_edge 32 /* TODO(isolates): this is what's included in bleeding_edge
32 including of v8.h was replaced with these in 33 including of v8.h was replaced with these in
33 http://codereview.chromium.org/5005001/ 34 http://codereview.chromium.org/5005001/
34 we need Isolate and Isolate needs a lot more so I'm including v8.h back. 35 we need Isolate and Isolate needs a lot more so I'm including v8.h back.
35 #include "../include/v8stdint.h" 36 #include "../include/v8stdint.h"
36 #include "globals.h" 37 #include "globals.h"
37 #include "checks.h" 38 #include "checks.h"
38 #include "allocation.h" 39 #include "allocation.h"
39 #include "utils.h" 40 #include "utils.h"
40 */ 41 */
41 42
42 namespace v8 { 43 namespace v8 {
43 namespace internal { 44 namespace internal {
44 45
46 #ifdef DEBUG
47
48 NativeAllocationChecker::NativeAllocationChecker(
49 NativeAllocationChecker::NativeAllocationAllowed allowed)
50 : allowed_(allowed) {
51 if (allowed == DISALLOW) {
52 Isolate* isolate = Isolate::Current();
53 isolate->set_allocation_disallowed(isolate->allocation_disallowed() + 1);
54 }
55 }
56
57
58 NativeAllocationChecker::~NativeAllocationChecker() {
59 Isolate* isolate = Isolate::Current();
60 if (allowed_ == DISALLOW) {
61 isolate->set_allocation_disallowed(isolate->allocation_disallowed() - 1);
62 }
63 ASSERT(isolate->allocation_disallowed() >= 0);
64 }
65
66
67 bool NativeAllocationChecker::allocation_allowed() {
68 // TODO(isolates): either find a way to make this work that doesn't
69 // require initializing an isolate before we can use malloc or drop
70 // it completely.
71 return true;
72 // return Isolate::Current()->allocation_disallowed() == 0;
73 }
74
75 #endif // DEBUG
76
77
45 void* Malloced::New(size_t size) { 78 void* Malloced::New(size_t size) {
46 ASSERT(NativeAllocationChecker::allocation_allowed()); 79 ASSERT(NativeAllocationChecker::allocation_allowed());
47 void* result = malloc(size); 80 void* result = malloc(size);
48 if (result == NULL) { 81 if (result == NULL) {
49 v8::internal::FatalProcessOutOfMemory("Malloced operator new"); 82 v8::internal::FatalProcessOutOfMemory("Malloced operator new");
50 } 83 }
51 return result; 84 return result;
52 } 85 }
53 86
54 87
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 previous_->next_ = next_; 226 previous_->next_ = next_;
194 } 227 }
195 228
196 229
197 PreallocatedStorage::PreallocatedStorage(size_t size) 230 PreallocatedStorage::PreallocatedStorage(size_t size)
198 : size_(size) { 231 : size_(size) {
199 previous_ = next_ = this; 232 previous_ = next_ = this;
200 } 233 }
201 234
202 } } // namespace v8::internal 235 } } // namespace v8::internal
OLDNEW
« 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