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

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

Issue 6597029: [Isolates] Merge r 6300:6500 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-nullos.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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 asm("int $3"); 196 asm("int $3");
197 } 197 }
198 198
199 199
200 class PosixMemoryMappedFile : public OS::MemoryMappedFile { 200 class PosixMemoryMappedFile : public OS::MemoryMappedFile {
201 public: 201 public:
202 PosixMemoryMappedFile(FILE* file, void* memory, int size) 202 PosixMemoryMappedFile(FILE* file, void* memory, int size)
203 : file_(file), memory_(memory), size_(size) { } 203 : file_(file), memory_(memory), size_(size) { }
204 virtual ~PosixMemoryMappedFile(); 204 virtual ~PosixMemoryMappedFile();
205 virtual void* memory() { return memory_; } 205 virtual void* memory() { return memory_; }
206 virtual int size() { return size_; }
206 private: 207 private:
207 FILE* file_; 208 FILE* file_;
208 void* memory_; 209 void* memory_;
209 int size_; 210 int size_;
210 }; 211 };
211 212
212 213
214 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
215 FILE* file = fopen(name, "w+");
216 if (file == NULL) return NULL;
217
218 fseek(file, 0, SEEK_END);
219 int size = ftell(file);
220
221 void* memory =
222 mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0);
223 return new PosixMemoryMappedFile(file, memory, size);
224 }
225
226
213 OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size, 227 OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size,
214 void* initial) { 228 void* initial) {
215 FILE* file = fopen(name, "w+"); 229 FILE* file = fopen(name, "w+");
216 if (file == NULL) return NULL; 230 if (file == NULL) return NULL;
217 int result = fwrite(initial, size, 1, file); 231 int result = fwrite(initial, size, 1, file);
218 if (result < 1) { 232 if (result < 1) {
219 fclose(file); 233 fclose(file);
220 return NULL; 234 return NULL;
221 } 235 }
222 void* memory = 236 void* memory =
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 774
761 void Sampler::Stop() { 775 void Sampler::Stop() {
762 ASSERT(IsActive()); 776 ASSERT(IsActive());
763 SamplerThread::RemoveActiveSampler(this); 777 SamplerThread::RemoveActiveSampler(this);
764 SetActive(false); 778 SetActive(false);
765 } 779 }
766 780
767 #endif // ENABLE_LOGGING_AND_PROFILING 781 #endif // ENABLE_LOGGING_AND_PROFILING
768 782
769 } } // namespace v8::internal 783 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-nullos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698