Closed Bug 504219 Opened 15 years ago Closed 15 years ago

TM: Inline malloc counting function

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: gal, Assigned: gal)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

About 3% speedup on non-empty object allocation, i.e. while (true) ([1]).
Attached patch patch (obsolete) — Splinter Review
Assignee: general → gal
Attachment #388600 - Flags: review?(jwalden+bmo)
(In reply to comment #0)
> About 3% speedup on non-empty object allocation, i.e. while (true) ([1]).

BTW, won't we at some point notice that the value is unused and (now that there's no observable effect like calling a hijacked Array implied here, as was the case with ECMA-262 Edition 3) the expression has no side effects, and optimize away the allocation altogether? Better if the loop has a counter and limit ;-), but I am really fishing for a bug on file.

/be
Comment on attachment 388600 [details] [diff] [review]
patch

>diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h

>+    /* Call this after succesful malloc of memory for GC-related things. */
>+    inline void
>+    updateMallocCounter(size_t nbytes)

inline here, inside the class declaration with a method definition in-place which already implies inline, is redundant as far as I understand, would prefer it removed.


>+    {
>+        uint32 *pbytes, bytes;
>+
>+#ifdef JS_THREADSAFE
>+        pbytes = &thread->gcMallocBytes;
>+#else
>+        pbytes = &runtime->gcMallocBytes;
>+#endif
>+        bytes = *pbytes;
>+        *pbytes = ((uint32)-1 - bytes <= nbytes) ? (uint32)-1 : bytes + nbytes;

I thought we had a macro like CACHE_LOCUS(cx) that hid the thread/runtime distinction, but I can't find it on a quick search, no matter.  Please convert the C-style (uint32)-1 casts to C++-style uint32(-1) casts while you're here.
Attachment #388600 - Flags: review?(jwalden+bmo) → review+
Attached patch patchSplinter Review
Attachment #388600 - Attachment is obsolete: true
Attachment #388609 - Attachment is patch: true
Attachment #388609 - Attachment mime type: application/octet-stream → text/plain
Attachment #388609 - Flags: review?(jwalden+bmo)
Attachment #388609 - Flags: review?(jwalden+bmo) → review+
Comment on attachment 388609 [details] [diff] [review]
patch

Looks cool, although it occurs to me that we should add SIZE_MAX and friends to our stdint.h replacement for more standards-stylistic code, sometime.  I filed bug 504233 to do this.
http://hg.mozilla.org/tracemonkey/rev/85875bc69317
Whiteboard: fixed-in-tracemonkey
http://hg.mozilla.org/mozilla-central/rev/85875bc69317
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: