Closed Bug 784303 Opened 13 years ago Closed 13 years ago

self-hosting: support running initialization code on global-creation

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: till, Unassigned)

References

Details

Attachments

(1 file)

In order to enable self-initialization of self-hosted code and full setup of self-hosted builtins from JS, it should be possible to run JS initialization functions when creating a new global object. Simply running one specific function would be trivial, but also very restrictive: it would force authors of new JS builtins to change a central location for what should be a local change to their builtin code. Instead, it might be a good idea to add a macro that allows for registering callbacks to be invoked upon initialization. This could look like the following: %_RegisterInitializer(myInitializer); Internally, this would then add `myInitializer` to a list of functions to be run on global creation.
Attached patch for posteritySplinter Review
Luke and Ms2Ger have convinced me that executing JS code on every global creation isn't a good idea after all. Hence, this'll probably be WONTFIX'd. The added patch is what I came up with before the change of mind; I'm posting it just in case it should ever be useful in any way.
We can always reopen if we decide we want this after all.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → WONTFIX
What are the arguments against doing this? I was really looking forward to setting up objects of the ECMAScript Internationalization API from JavaScript rather than from C++...
(In reply to Norbert Lindenberg from comment #3) > What are the arguments against doing this? > > I was really looking forward to setting up objects of the ECMAScript > Internationalization API from JavaScript rather than from C++... You'll still be able to do that, once at least bug 784400 and bug 784293 are fixed. The difference is that the setup code will be run once after initial compilation of the self-hosted code instead of on each global creation. The argument against the latter is that it'd make global creation quite a bit more expensive and would force eager cloning of all objects used by initialization code.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: