OLD | NEW |
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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 virtual void* memory() { return memory_; } | 320 virtual void* memory() { return memory_; } |
321 virtual int size() { return size_; } | 321 virtual int size() { return size_; } |
322 private: | 322 private: |
323 FILE* file_; | 323 FILE* file_; |
324 void* memory_; | 324 void* memory_; |
325 int size_; | 325 int size_; |
326 }; | 326 }; |
327 | 327 |
328 | 328 |
329 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { | 329 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { |
330 FILE* file = fopen(name, "w+"); | 330 FILE* file = fopen(name, "r+"); |
331 if (file == NULL) return NULL; | 331 if (file == NULL) return NULL; |
332 | 332 |
333 fseek(file, 0, SEEK_END); | 333 fseek(file, 0, SEEK_END); |
334 int size = ftell(file); | 334 int size = ftell(file); |
335 | 335 |
336 void* memory = | 336 void* memory = |
337 mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); | 337 mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); |
338 return new PosixMemoryMappedFile(file, memory, size); | 338 return new PosixMemoryMappedFile(file, memory, size); |
339 } | 339 } |
340 | 340 |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 } | 972 } |
973 | 973 |
974 // This sampler is no longer the active sampler. | 974 // This sampler is no longer the active sampler. |
975 active_sampler_ = NULL; | 975 active_sampler_ = NULL; |
976 } | 976 } |
977 | 977 |
978 | 978 |
979 #endif // ENABLE_LOGGING_AND_PROFILING | 979 #endif // ENABLE_LOGGING_AND_PROFILING |
980 | 980 |
981 } } // namespace v8::internal | 981 } } // namespace v8::internal |
OLD | NEW |