Compute static scope extents at compile-time and store them in JSScript

RESOLVED FIXED in mozilla28

Status

()

Core
JavaScript Engine
RESOLVED FIXED
5 years ago
4 years ago

People

(Reporter: wingo, Assigned: wingo)

Tracking

unspecified
mozilla28
x86_64
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [qa-])

Attachments

(3 attachments, 1 obsolete attachment)

(Assignee)

Description

5 years ago
The bytecode emitter should record the extent of block scopes at compile-time and store that in the script object.

This will allow computation of the block chain corresponding to a PC solely based on the PC, without abstract interpretation of the bytecode.  In the case of lexical blocks with unaliased locals, this will remove the need for ENTERBLOCK / LEAVEBLOCK instructions.  It also removes the need for SRC_HIDDEN annotations for nonlocal block exits -- the last use of SRC_HIDDEN after bug 932180.
(Assignee)

Comment 1

5 years ago
Created attachment 823984 [details] [diff] [review]
Reserve space in JSScript for an optional block scope array (1/3)
(Assignee)

Updated

5 years ago
Assignee: nobody → wingo
(Assignee)

Updated

5 years ago
Depends on: 932216
(Assignee)

Comment 2

5 years ago
Created attachment 823986 [details] [diff] [review]
Bytecode emitter records static scope extents (2/3)
(Assignee)

Comment 3

5 years ago
Created attachment 823987 [details] [diff] [review]
Reimplement GetBlockChainAtPC using JSScript::blockScopes() (3/3)
(Assignee)

Updated

5 years ago
Attachment #823984 - Flags: review?(jorendorff)
(Assignee)

Updated

5 years ago
Attachment #823986 - Flags: review?(jorendorff)
(Assignee)

Updated

5 years ago
Attachment #823987 - Flags: review?(jorendorff)
(Assignee)

Updated

5 years ago
Blocks: 932312
Attachment #823984 - Flags: review?(jorendorff) → review+
Comment on attachment 823986 [details] [diff] [review]
Bytecode emitter records static scope extents (2/3)

Review of attachment 823986 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/frontend/BytecodeEmitter.cpp
@@ +786,5 @@
>  
>  static bool
> +EmitInternedObjectOp(ExclusiveContext *cx, uint32_t index, JSOp op, BytecodeEmitter *bce)
> +{
> +    JS_ASSERT(JOF_OPTYPE(op) == JOF_OBJECT);

Can this also assert that index is in range?

@@ +1087,5 @@
> +    JS_ASSERT(stmt->isBlockScope);
> +    JS_ASSERT(stmt->blockScopeIndex == bce->blockScopeList.length() - 1);
> +    JS_ASSERT(bce->blockScopeList.list[stmt->blockScopeIndex].length == 0);
> +    uint32_t scopeObjectIndex = bce->blockScopeList.list[stmt->blockScopeIndex].index;
> +    JS_ASSERT(scopeObjectIndex == bce->objectList.length - 1);

These assertions seem to explain the timing of EmitEnterBlock relative to the initialization of all these other bits of the script, which is nice. Can we also assert that pn->pn_objbox and scopeObjectIndex refer to the same thing?
Attachment #823986 - Flags: review?(jorendorff) → review+
Attachment #823987 - Flags: review?(jorendorff) → review+
(Assignee)

Comment 5

5 years ago
Created attachment 830704 [details] [diff] [review]
Reimplement GetBlockChainAtPC using JSScript::blockScopes() (3/3) v2
(Assignee)

Updated

5 years ago
Attachment #823987 - Attachment is obsolete: true
(Assignee)

Comment 6

5 years ago
Comment on attachment 830704 [details] [diff] [review]
Reimplement GetBlockChainAtPC using JSScript::blockScopes() (3/3) v2

Thanks for the review, nits addressed.
Attachment #830704 - Attachment description: Reimplement GetBlockChainAtPC using JSScript::blockScopes() (3/3) → Reimplement GetBlockChainAtPC using JSScript::blockScopes() (3/3) v2
Attachment #830704 - Flags: review+
(Assignee)

Updated

5 years ago
Keywords: checkin-needed

Updated

4 years ago
Whiteboard: [qa-]
You need to log in before you can comment on or make changes to this bug.