Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
90c17993
Commit
90c17993
authored
Mar 05, 2026
by
Matt Mastracci
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experiment: Wrap JsValue in Arc
parent
49e83f5d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
624 additions
and
473 deletions
+624
-473
builtin.rs
...opack/crates/turbopack-ecmascript/src/analyzer/builtin.rs
+325
-208
graph.rs
turbopack/crates/turbopack-ecmascript/src/analyzer/graph.rs
+52
-52
imports.rs
...opack/crates/turbopack-ecmascript/src/analyzer/imports.rs
+3
-3
linker.rs
turbopack/crates/turbopack-ecmascript/src/analyzer/linker.rs
+11
-8
mod.rs
turbopack/crates/turbopack-ecmascript/src/analyzer/mod.rs
+85
-86
well_known.rs
...ck/crates/turbopack-ecmascript/src/analyzer/well_known.rs
+99
-78
mod.rs
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
+49
-38
No files found.
turbopack/crates/turbopack-ecmascript/src/analyzer/builtin.rs
View file @
90c17993
This diff is collapsed.
Click to expand it.
turbopack/crates/turbopack-ecmascript/src/analyzer/graph.rs
View file @
90c17993
This diff is collapsed.
Click to expand it.
turbopack/crates/turbopack-ecmascript/src/analyzer/imports.rs
View file @
90c17993
use
std
::{
borrow
::
Cow
,
collections
::
BTreeMap
,
fmt
::
Display
};
use
std
::{
borrow
::
Cow
,
collections
::
BTreeMap
,
fmt
::
Display
,
sync
::
Arc
};
use
once_cell
::
sync
::
Lazy
;
use
once_cell
::
sync
::
Lazy
;
use
rustc_hash
::{
FxHashMap
,
FxHashSet
};
use
rustc_hash
::{
FxHashMap
,
FxHashSet
};
...
@@ -380,11 +380,11 @@ impl ImportMap {
...
@@ -380,11 +380,11 @@ impl ImportMap {
if
let
Some
((
i
,
i_sym
))
=
self
.imports
.get
(
id
)
{
if
let
Some
((
i
,
i_sym
))
=
self
.imports
.get
(
id
)
{
let
r
=
&
self
.references
[
*
i
];
let
r
=
&
self
.references
[
*
i
];
return
Some
(
JsValue
::
member
(
return
Some
(
JsValue
::
member
(
Box
::
new
(
JsValue
::
Module
(
ModuleValue
{
Arc
::
new
(
JsValue
::
Module
(
ModuleValue
{
module
:
r
.module_path
.clone
(),
module
:
r
.module_path
.clone
(),
annotations
:
r
.annotations
.clone
(),
annotations
:
r
.annotations
.clone
(),
})),
})),
Box
::
new
(
i_sym
.clone
()
.into
()),
Arc
::
new
(
i_sym
.clone
()
.into
()),
));
));
}
}
if
let
Some
(
i
)
=
self
.namespace_imports
.get
(
id
)
{
if
let
Some
(
i
)
=
self
.namespace_imports
.get
(
id
)
{
...
...
turbopack/crates/turbopack-ecmascript/src/analyzer/linker.rs
View file @
90c17993
use
std
::{
collections
::
hash_map
::
Entry
,
fmt
::
Display
,
future
::
Future
,
mem
::
take
};
use
std
::{
collections
::
hash_map
::
Entry
,
fmt
::
Display
,
future
::
Future
,
mem
::
take
,
sync
::
Arc
};
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
parking_lot
::
Mutex
;
use
parking_lot
::
Mutex
;
...
@@ -178,11 +178,14 @@ where
...
@@ -178,11 +178,14 @@ where
// Visit a function call
// Visit a function call
// This need special handling, since we want to replace the function call and process
// This need special handling, since we want to replace the function call and process
// the function return value after that.
// the function return value after that.
Step
::
Visit
(
JsValue
::
Call
(
Step
::
Visit
(
JsValue
::
Call
(
_
,
callee
,
args
))
_
,
if
matches!
(
callee
.as_ref
(),
JsValue
::
Function
(
..
))
=>
box
JsValue
::
Function
(
function_nodes
,
func_ident
,
return_value
),
{
args
,
let
JsValue
::
Function
(
function_nodes
,
func_ident
,
return_value
)
=
))
=>
{
Arc
::
unwrap_or_clone
(
callee
)
else
{
unreachable!
()
};
total_nodes
-
=
2
;
// Call + Function
total_nodes
-
=
2
;
// Call + Function
if
let
Entry
::
Vacant
(
entry
)
=
fun_args_values
.lock
()
.entry
(
func_ident
)
{
if
let
Entry
::
Vacant
(
entry
)
=
fun_args_values
.lock
()
.entry
(
func_ident
)
{
// Return value will stay in total_nodes
// Return value will stay in total_nodes
...
@@ -192,7 +195,7 @@ where
...
@@ -192,7 +195,7 @@ where
entry
.insert
(
args
);
entry
.insert
(
args
);
fun_args_depth
+=
1
;
fun_args_depth
+=
1
;
work_queue_stack
.push
(
Step
::
LeaveCall
(
func_ident
));
work_queue_stack
.push
(
Step
::
LeaveCall
(
func_ident
));
work_queue_stack
.push
(
Step
::
Enter
(
*
return_value
));
work_queue_stack
.push
(
Step
::
Enter
(
Arc
::
unwrap_or_clone
(
return_value
)
));
}
else
{
}
else
{
total_nodes
-
=
return_value
.total_nodes
();
total_nodes
-
=
return_value
.total_nodes
();
for
arg
in
args
.iter
()
{
for
arg
in
args
.iter
()
{
...
@@ -201,7 +204,7 @@ where
...
@@ -201,7 +204,7 @@ where
total_nodes
+=
1
;
total_nodes
+=
1
;
done
.push
(
JsValue
::
unknown
(
done
.push
(
JsValue
::
unknown
(
JsValue
::
call
(
JsValue
::
call
(
Box
::
new
(
JsValue
::
Function
(
function_nodes
,
func_ident
,
return_value
)),
Arc
::
new
(
JsValue
::
Function
(
function_nodes
,
func_ident
,
return_value
)),
args
,
args
,
),
),
true
,
true
,
...
...
turbopack/crates/turbopack-ecmascript/src/analyzer/mod.rs
View file @
90c17993
This diff is collapsed.
Click to expand it.
turbopack/crates/turbopack-ecmascript/src/analyzer/well_known.rs
View file @
90c17993
This diff is collapsed.
Click to expand it.
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
View file @
90c17993
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment