Bug 27051 - Use fastMalloc when neither MMAP nor VIRTUALALLOC are enabled
Summary: Use fastMalloc when neither MMAP nor VIRTUALALLOC are enabled
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: S60 Hardware S60 3rd edition
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 27065
  Show dependency treegraph
 
Reported: 2009-07-07 18:39 PDT by Norbert Leser
Modified: 2009-09-02 02:49 PDT (History)
5 users (show)

See Also:


Attachments
Code patch for Registerfile ccp and h (2.14 KB, patch)
2009-07-07 18:39 PDT, Norbert Leser
eric: review-
Details | Formatted Diff | Diff
Update of patch file for bug #27051 (2.60 KB, patch)
2009-08-26 12:48 PDT, Norbert Leser
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Norbert Leser 2009-07-07 18:39:02 PDT
Created attachment 32410 [details]
Code patch for Registerfile ccp and h

RegisterFile constructor currently throws #error when both MMAP and VIRTUALALLOC conditions fail.
On any platform that does not provide these features (for instance, Symbian), the fallback should be regular malloc (or fastMalloc).
Memory allocation with fastMalloc functionally equivalent in this case, even though it may have certain drawbacks such as lack of dynamic pre-allocation.

This should be the general, preferred way of fixing the issue, as opposed to introducing conditional code block for platform Symbian.
Comment 1 Maciej Stachowiak 2009-07-09 20:13:09 PDT
Comment on attachment 32410 [details]
Code patch for Registerfile ccp and h

I'll have to check into whether this works - I don't remember whether there are special alignment or lazy commit requirements.

But I also noticed that PLATFORM(SYMBIAN) uses fastMalloc in place of VM allocation inside Collector.cpp. That's definitely bugus - the GC counts on the guaranteed alignment provided by vm_map, VirtualAlloc and posix_memalign. Failing to meet the alignment requirements will lead to random crashes. If Symbian has no way to get aligned memory chunks, it needs to do a trick to fix up the alignment, like the mmap() code path.
Comment 2 Norbert Leser 2009-08-05 11:18:02 PDT
(In reply to comment #1)
> (From update of attachment 32410 [details])
> I'll have to check into whether this works - I don't remember whether there are
> special alignment or lazy commit requirements.
> 
> But I also noticed that PLATFORM(SYMBIAN) uses fastMalloc in place of VM
> allocation inside Collector.cpp. That's definitely bugus - the GC counts on the
> guaranteed alignment provided by vm_map, VirtualAlloc and posix_memalign.
> Failing to meet the alignment requirements will lead to random crashes. If
> Symbian has no way to get aligned memory chunks, it needs to do a trick to fix
> up the alignment, like the mmap() code path.

Maciej, did you have a chance, in the meantime, to verify whether there are special requirements for alignment, etc? I could not find any just by looking at the code, and we are running my patch here for a while already without seeing any impact. 

It would be great if we can resolve this issue soon.
If you can point me to alignment issues, I could easily submit my initial code that mimics alignment via fastMalloc() but otherwise it would certainly be cleaner to leave that overhead out and just implement my patch as is.
Comment 3 Geoffrey Garen 2009-08-12 10:57:45 PDT
(In reply to comment #1)
> (From update of attachment 32410 [details])
> I'll have to check into whether this works - I don't remember whether there are
> special alignment or lazy commit requirements.

The code depends on lazy commit to avoid wasting memory, but not for correctness.
Comment 4 Eric Seidel (no email) 2009-08-17 18:28:51 PDT
Comment on attachment 32410 [details]
Code patch for Registerfile ccp and h

I think this needs a comment in the code indicating that this is not the preferred method.  That platforms should provide instead an allocator which provides lazy commit.

I'm assuming for the moment that there are no alignment requirements.  If there are, this patch is invalid for other reasons.

Please track down othermaciej or ggaren over irc for the alignment requirements.  I'm ready to r+ a change with an added comment about how fastMalloc does not lazy commit and that platforms should instead provide a better allocator.
Comment 5 Geoffrey Garen 2009-08-25 11:06:20 PDT
> I'm assuming for the moment that there are no alignment requirements.  If there
> are, this patch is invalid for other reasons.

The only alignment requirement I know of is that the buffer must be aligned to sizeof(Register).
Comment 6 Norbert Leser 2009-08-26 12:48:33 PDT
Created attachment 38633 [details]
Update of patch file for bug #27051

Added comment in code about drawbacks of this alternate branch, as suggested by Eric.

Confirmed in the meantime with Maciej and Geoffrey that there are no specific alignment requirements.
Comment 7 Eric Seidel (no email) 2009-09-02 02:35:52 PDT
Comment on attachment 38633 [details]
Update of patch file for bug #27051

Seems OK to me.  No one else has voiced further objections so r+.
Comment 8 Eric Seidel (no email) 2009-09-02 02:49:41 PDT
Comment on attachment 38633 [details]
Update of patch file for bug #27051

Clearing flags on attachment: 38633

Committed r47959: <http://trac.webkit.org/changeset/47959>
Comment 9 Eric Seidel (no email) 2009-09-02 02:49:50 PDT
All reviewed patches have been landed.  Closing bug.