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

Side by Side Diff: src/platform-macos.cc

Issue 2807031: [Isolates] RegExpStack and memory allocation limits (statics #6) (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: -> is different than . Created 10 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-win32.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-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
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 double ceiling(double x) { 80 double ceiling(double x) {
81 // Correct Mac OS X Leopard 'ceil' behavior. 81 // Correct Mac OS X Leopard 'ceil' behavior.
82 if (-1.0 < x && x < 0.0) { 82 if (-1.0 < x && x < 0.0) {
83 return -0.0; 83 return -0.0;
84 } else { 84 } else {
85 return ceil(x); 85 return ceil(x);
86 } 86 }
87 } 87 }
88 88
89 89
90 static Mutex* limit_mutex = NULL;
91
92
90 void OS::Setup() { 93 void OS::Setup() {
91 // Seed the random number generator. 94 // Seed the random number generator.
92 // Convert the current time to a 64-bit integer first, before converting it 95 // Convert the current time to a 64-bit integer first, before converting it
93 // to an unsigned. Going directly will cause an overflow and the seed to be 96 // to an unsigned. Going directly will cause an overflow and the seed to be
94 // set to all ones. The seed will be identical for different instances that 97 // set to all ones. The seed will be identical for different instances that
95 // call this setup code within the same millisecond. 98 // call this setup code within the same millisecond.
96 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); 99 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
97 srandom(static_cast<unsigned int>(seed)); 100 srandom(static_cast<unsigned int>(seed));
101 limit_mutex = CreateMutex();
98 } 102 }
99 103
100 104
101 // We keep the lowest and highest addresses mapped as a quick way of 105 // We keep the lowest and highest addresses mapped as a quick way of
102 // determining that pointers are outside the heap (used mostly in assertions 106 // determining that pointers are outside the heap (used mostly in assertions
103 // and verification). The estimate is conservative, ie, not all addresses in 107 // and verification). The estimate is conservative, ie, not all addresses in
104 // 'allocated' space are actually allocated to our heap. The range is 108 // 'allocated' space are actually allocated to our heap. The range is
105 // [lowest, highest), inclusive on the low and and exclusive on the high end. 109 // [lowest, highest), inclusive on the low and and exclusive on the high end.
106 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); 110 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1);
107 static void* highest_ever_allocated = reinterpret_cast<void*>(0); 111 static void* highest_ever_allocated = reinterpret_cast<void*>(0);
108 112
109 113
110 static void UpdateAllocatedSpaceLimits(void* address, int size) { 114 static void UpdateAllocatedSpaceLimits(void* address, int size) {
115 ASSERT(limit_mutex != NULL);
116 ScopedLock lock(limit_mutex);
117
111 lowest_ever_allocated = Min(lowest_ever_allocated, address); 118 lowest_ever_allocated = Min(lowest_ever_allocated, address);
112 highest_ever_allocated = 119 highest_ever_allocated =
113 Max(highest_ever_allocated, 120 Max(highest_ever_allocated,
114 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); 121 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size));
115 } 122 }
116 123
117 124
118 bool OS::IsOutsideAllocatedSpace(void* address) { 125 bool OS::IsOutsideAllocatedSpace(void* address) {
119 return address < lowest_ever_allocated || address >= highest_ever_allocated; 126 return address < lowest_ever_allocated || address >= highest_ever_allocated;
120 } 127 }
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 663
657 // Deallocate Mach port for thread. 664 // Deallocate Mach port for thread.
658 if (IsProfiling()) { 665 if (IsProfiling()) {
659 mach_port_deallocate(data_->task_self_, data_->profiled_thread_); 666 mach_port_deallocate(data_->task_self_, data_->profiled_thread_);
660 } 667 }
661 } 668 }
662 669
663 #endif // ENABLE_LOGGING_AND_PROFILING 670 #endif // ENABLE_LOGGING_AND_PROFILING
664 671
665 } } // namespace v8::internal 672 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698