Thank you.
So according to your answer.
There are two prerequisites relate to memory before running v8.
1. the memory should be executable
2. the memory should have page boundaries of 4k.
Is that so ?






On Jun 23, 7:11 pm, Dean McNamee <[email protected]> wrote:
> You need to be able to control the permission bits on the pages, for
> example to mark them executable.  This is not something you could do
> allocating off the heap.  Also, VirtualAlloc allocates full pages on
> page boundaries (4k).
>
> Why would you want to change it?
>
>
>
> On Tue, Jun 23, 2009 at 12:55 PM, AOF<[email protected]> wrote:
>
> > Hello.
> > I have a question.
> > Can i replace the function "VirtualAlloc" to the function
> > "HeapAlloc"in the following code from v8?
> > If not, why?
>
> > void* OS::Allocate(const size_t requested,
> >                   size_t* allocated,
> >                   bool executable) {
> >  // VirtualAlloc rounds allocated size to page size automatically.
> >  size_t msize = RoundUp(requested, GetPageSize());
>
> >  // Windows XP SP2 allows Data Excution Prevention (DEP).
> >  int prot = executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
> >  LPVOID mbase = VirtualAlloc(NULL, msize, MEM_COMMIT | MEM_RESERVE,
> > prot);
> >  if (mbase == NULL) {
> >    LOG(StringEvent("OS::Allocate", "VirtualAlloc failed"));
> >    return NULL;
> >  }
>
> >  ASSERT(IsAligned(reinterpret_cast<size_t>(mbase),
> > OS::AllocateAlignment()));
>
> >  *allocated = msize;
> >  UpdateAllocatedSpaceLimits(mbase, msize);
> >  return mbase;
> > }
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to