Reviewers: Kevin Millikin, Description: Merge r8780, r8803 from the bleeding edge 3.4 branch.
Mark optimized modulo and memcpy code pages -w after writing them. Check phi uses of the arguments object after redundant phies elimination. This allows to handle code like: var a = arguments; while (smth) a[i]; without bailout. Please review this at http://codereview.chromium.org/7563006/ SVN Base: http://v8.googlecode.com/svn/branches/3.4/ Affected files: M src/hydrogen.cc M src/ia32/codegen-ia32.cc M src/platform-posix.cc M src/platform-win32.cc M src/platform.h M src/version.cc M src/x64/codegen-x64.cc Index: src/hydrogen.cc =================================================================== --- src/hydrogen.cc (revision 8804) +++ src/hydrogen.cc (working copy) @@ -2304,11 +2304,11 @@ graph()->OrderBlocks(); graph()->AssignDominators(); + graph()->EliminateRedundantPhis(); if (!graph()->CheckPhis()) { Bailout("Unsupported phi use of arguments object"); return NULL; } - graph()->EliminateRedundantPhis(); if (FLAG_eliminate_dead_phis) graph()->EliminateUnreachablePhis(); if (!graph()->CollectPhis()) { Bailout("Unsupported phi use of uninitialized constant"); Index: src/ia32/codegen-ia32.cc =================================================================== --- src/ia32/codegen-ia32.cc (revision 8804) +++ src/ia32/codegen-ia32.cc (working copy) @@ -255,6 +255,7 @@ ASSERT(desc.reloc_size == 0); CPU::FlushICache(buffer, actual_size); + OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST<OS::MemCopyFunction>(buffer); } Index: src/platform-posix.cc =================================================================== --- src/platform-posix.cc (revision 8804) +++ src/platform-posix.cc (working copy) @@ -70,6 +70,12 @@ } +// Get rid of writable permission on code allocations. +void OS::ProtectCode(void* address, const size_t size) { + mprotect(address, size, PROT_READ | PROT_EXEC); +} + + // Create guard pages. void OS::Guard(void* address, const size_t size) { mprotect(address, size, PROT_NONE); Index: src/platform-win32.cc =================================================================== --- src/platform-win32.cc (revision 8804) +++ src/platform-win32.cc (working copy) @@ -957,6 +957,12 @@ } +void OS::ProtectCode(void* address, const size_t size) { + DWORD old_protect; + VirtualProtect(address, size, PAGE_EXECUTE_READ, &old_protect); +} + + void OS::Guard(void* address, const size_t size) { DWORD oldprotect; VirtualProtect(address, size, PAGE_READONLY | PAGE_GUARD, &oldprotect); Index: src/platform.h =================================================================== --- src/platform.h (revision 8804) +++ src/platform.h (working copy) @@ -207,6 +207,9 @@ bool is_executable); static void Free(void* address, const size_t size); + // Mark code segments non-writable. + static void ProtectCode(void* address, const size_t size); + // Assign memory as a guard page so that access will cause an exception. static void Guard(void* address, const size_t size); Index: src/version.cc =================================================================== --- src/version.cc (revision 8804) +++ src/version.cc (working copy) @@ -35,7 +35,7 @@ #define MAJOR_VERSION 3 #define MINOR_VERSION 4 #define BUILD_NUMBER 14 -#define PATCH_LEVEL 5 +#define PATCH_LEVEL 6 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) #define IS_CANDIDATE_VERSION 0 Index: src/x64/codegen-x64.cc =================================================================== --- src/x64/codegen-x64.cc (revision 8804) +++ src/x64/codegen-x64.cc (working copy) @@ -132,6 +132,7 @@ CodeDesc desc; masm.GetCode(&desc); + OS::ProtectCode(buffer, actual_size); // Call the function from C++ through this pointer. return FUNCTION_CAST<ModuloFunction>(buffer); } -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
