Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
5a90acf5
Commit
5a90acf5
authored
Jun 12, 2018
by
Jacek Caban
Committed by
Alexandre Julliard
Jun 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Use global accumulator for storing function call results.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
4b72060f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
20 deletions
+41
-20
compile.c
dlls/jscript/compile.c
+2
-2
engine.c
dlls/jscript/engine.c
+14
-17
engine.h
dlls/jscript/engine.h
+1
-1
jscript.c
dlls/jscript/jscript.c
+2
-0
jscript.h
dlls/jscript/jscript.h
+1
-0
lang.js
dlls/jscript/tests/lang.js
+21
-0
No files found.
dlls/jscript/compile.c
View file @
5a90acf5
...
@@ -609,7 +609,7 @@ static HRESULT compile_new_expression(compiler_ctx_t *ctx, call_expression_t *ex
...
@@ -609,7 +609,7 @@ static HRESULT compile_new_expression(compiler_ctx_t *ctx, call_expression_t *ex
if
(
FAILED
(
hres
))
if
(
FAILED
(
hres
))
return
hres
;
return
hres
;
return
push_instr
(
ctx
,
OP_push_
ret
)
?
S_OK
:
E_OUTOFMEMORY
;
return
push_instr
(
ctx
,
OP_push_
acc
)
?
S_OK
:
E_OUTOFMEMORY
;
}
}
static
HRESULT
compile_call_expression
(
compiler_ctx_t
*
ctx
,
call_expression_t
*
expr
,
BOOL
emit_ret
)
static
HRESULT
compile_call_expression
(
compiler_ctx_t
*
ctx
,
call_expression_t
*
expr
,
BOOL
emit_ret
)
...
@@ -651,7 +651,7 @@ static HRESULT compile_call_expression(compiler_ctx_t *ctx, call_expression_t *e
...
@@ -651,7 +651,7 @@ static HRESULT compile_call_expression(compiler_ctx_t *ctx, call_expression_t *e
if
(
FAILED
(
hres
))
if
(
FAILED
(
hres
))
return
hres
;
return
hres
;
return
!
emit_ret
||
push_instr
(
ctx
,
OP_push_
ret
)
?
S_OK
:
E_OUTOFMEMORY
;
return
!
emit_ret
||
push_instr
(
ctx
,
OP_push_
acc
)
?
S_OK
:
E_OUTOFMEMORY
;
}
}
static
HRESULT
compile_delete_expression
(
compiler_ctx_t
*
ctx
,
unary_expression_t
*
expr
)
static
HRESULT
compile_delete_expression
(
compiler_ctx_t
*
ctx
,
unary_expression_t
*
expr
)
...
...
dlls/jscript/engine.c
View file @
5a90acf5
...
@@ -385,9 +385,10 @@ static inline jsval_t steal_ret(call_frame_t *frame)
...
@@ -385,9 +385,10 @@ static inline jsval_t steal_ret(call_frame_t *frame)
return
r
;
return
r
;
}
}
static
inline
void
clear_
ret
(
call_frame_t
*
frame
)
static
inline
void
clear_
acc
(
script_ctx_t
*
ctx
)
{
{
jsval_release
(
steal_ret
(
frame
));
jsval_release
(
ctx
->
acc
);
ctx
->
acc
=
jsval_undefined
();
}
}
static
HRESULT
scope_push
(
scope_chain_t
*
scope
,
jsdisp_t
*
jsobj
,
IDispatch
*
obj
,
scope_chain_t
**
ret
)
static
HRESULT
scope_push
(
scope_chain_t
*
scope
,
jsdisp_t
*
jsobj
,
IDispatch
*
obj
,
scope_chain_t
**
ret
)
...
@@ -1155,7 +1156,6 @@ static HRESULT interp_refval(script_ctx_t *ctx)
...
@@ -1155,7 +1156,6 @@ static HRESULT interp_refval(script_ctx_t *ctx)
static
HRESULT
interp_new
(
script_ctx_t
*
ctx
)
static
HRESULT
interp_new
(
script_ctx_t
*
ctx
)
{
{
const
unsigned
argc
=
get_op_uint
(
ctx
,
0
);
const
unsigned
argc
=
get_op_uint
(
ctx
,
0
);
call_frame_t
*
frame
=
ctx
->
call_ctx
;
jsval_t
constr
;
jsval_t
constr
;
TRACE
(
"%d
\n
"
,
argc
);
TRACE
(
"%d
\n
"
,
argc
);
...
@@ -1171,9 +1171,9 @@ static HRESULT interp_new(script_ctx_t *ctx)
...
@@ -1171,9 +1171,9 @@ static HRESULT interp_new(script_ctx_t *ctx)
else
if
(
!
get_object
(
constr
))
else
if
(
!
get_object
(
constr
))
return
throw_type_error
(
ctx
,
JS_E_INVALID_PROPERTY
,
NULL
);
return
throw_type_error
(
ctx
,
JS_E_INVALID_PROPERTY
,
NULL
);
clear_
ret
(
frame
);
clear_
acc
(
ctx
);
return
disp_call_value
(
ctx
,
get_object
(
constr
),
NULL
,
DISPATCH_CONSTRUCT
|
DISPATCH_JSCRIPT_CALLEREXECSSOURCE
,
return
disp_call_value
(
ctx
,
get_object
(
constr
),
NULL
,
DISPATCH_CONSTRUCT
|
DISPATCH_JSCRIPT_CALLEREXECSSOURCE
,
argc
,
stack_args
(
ctx
,
argc
),
&
frame
->
ret
);
argc
,
stack_args
(
ctx
,
argc
),
&
ctx
->
acc
);
}
}
/* ECMA-262 3rd Edition 11.2.3 */
/* ECMA-262 3rd Edition 11.2.3 */
...
@@ -1181,7 +1181,6 @@ static HRESULT interp_call(script_ctx_t *ctx)
...
@@ -1181,7 +1181,6 @@ static HRESULT interp_call(script_ctx_t *ctx)
{
{
const
unsigned
argn
=
get_op_uint
(
ctx
,
0
);
const
unsigned
argn
=
get_op_uint
(
ctx
,
0
);
const
int
do_ret
=
get_op_int
(
ctx
,
1
);
const
int
do_ret
=
get_op_int
(
ctx
,
1
);
call_frame_t
*
frame
=
ctx
->
call_ctx
;
jsval_t
obj
;
jsval_t
obj
;
TRACE
(
"%d %d
\n
"
,
argn
,
do_ret
);
TRACE
(
"%d %d
\n
"
,
argn
,
do_ret
);
...
@@ -1190,9 +1189,9 @@ static HRESULT interp_call(script_ctx_t *ctx)
...
@@ -1190,9 +1189,9 @@ static HRESULT interp_call(script_ctx_t *ctx)
if
(
!
is_object_instance
(
obj
))
if
(
!
is_object_instance
(
obj
))
return
throw_type_error
(
ctx
,
JS_E_INVALID_PROPERTY
,
NULL
);
return
throw_type_error
(
ctx
,
JS_E_INVALID_PROPERTY
,
NULL
);
clear_
ret
(
frame
);
clear_
acc
(
ctx
);
return
disp_call_value
(
ctx
,
get_object
(
obj
),
NULL
,
DISPATCH_METHOD
|
DISPATCH_JSCRIPT_CALLEREXECSSOURCE
,
return
disp_call_value
(
ctx
,
get_object
(
obj
),
NULL
,
DISPATCH_METHOD
|
DISPATCH_JSCRIPT_CALLEREXECSSOURCE
,
argn
,
stack_args
(
ctx
,
argn
),
do_ret
?
&
frame
->
ret
:
NULL
);
argn
,
stack_args
(
ctx
,
argn
),
do_ret
?
&
ctx
->
acc
:
NULL
);
}
}
/* ECMA-262 3rd Edition 11.2.3 */
/* ECMA-262 3rd Edition 11.2.3 */
...
@@ -1200,7 +1199,6 @@ static HRESULT interp_call_member(script_ctx_t *ctx)
...
@@ -1200,7 +1199,6 @@ static HRESULT interp_call_member(script_ctx_t *ctx)
{
{
const
unsigned
argn
=
get_op_uint
(
ctx
,
0
);
const
unsigned
argn
=
get_op_uint
(
ctx
,
0
);
const
int
do_ret
=
get_op_int
(
ctx
,
1
);
const
int
do_ret
=
get_op_int
(
ctx
,
1
);
call_frame_t
*
frame
=
ctx
->
call_ctx
;
exprval_t
ref
;
exprval_t
ref
;
TRACE
(
"%d %d
\n
"
,
argn
,
do_ret
);
TRACE
(
"%d %d
\n
"
,
argn
,
do_ret
);
...
@@ -1208,9 +1206,9 @@ static HRESULT interp_call_member(script_ctx_t *ctx)
...
@@ -1208,9 +1206,9 @@ static HRESULT interp_call_member(script_ctx_t *ctx)
if
(
!
stack_topn_exprval
(
ctx
,
argn
,
&
ref
))
if
(
!
stack_topn_exprval
(
ctx
,
argn
,
&
ref
))
return
throw_type_error
(
ctx
,
ref
.
u
.
hres
,
NULL
);
return
throw_type_error
(
ctx
,
ref
.
u
.
hres
,
NULL
);
clear_
ret
(
frame
);
clear_
acc
(
ctx
);
return
exprval_call
(
ctx
,
&
ref
,
DISPATCH_METHOD
|
DISPATCH_JSCRIPT_CALLEREXECSSOURCE
,
return
exprval_call
(
ctx
,
&
ref
,
DISPATCH_METHOD
|
DISPATCH_JSCRIPT_CALLEREXECSSOURCE
,
argn
,
stack_args
(
ctx
,
argn
),
do_ret
?
&
frame
->
ret
:
NULL
);
argn
,
stack_args
(
ctx
,
argn
),
do_ret
?
&
ctx
->
acc
:
NULL
);
}
}
/* ECMA-262 3rd Edition 11.1.1 */
/* ECMA-262 3rd Edition 11.1.1 */
...
@@ -2600,16 +2598,15 @@ static HRESULT interp_setret(script_ctx_t *ctx)
...
@@ -2600,16 +2598,15 @@ static HRESULT interp_setret(script_ctx_t *ctx)
return
S_OK
;
return
S_OK
;
}
}
static
HRESULT
interp_push_
ret
(
script_ctx_t
*
ctx
)
static
HRESULT
interp_push_
acc
(
script_ctx_t
*
ctx
)
{
{
call_frame_t
*
frame
=
ctx
->
call_ctx
;
HRESULT
hres
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
TRACE
(
"
\n
"
);
hres
=
stack_push
(
ctx
,
frame
->
ret
);
hres
=
stack_push
(
ctx
,
ctx
->
acc
);
if
(
SUCCEEDED
(
hres
))
if
(
SUCCEEDED
(
hres
))
frame
->
ret
=
jsval_undefined
();
ctx
->
acc
=
jsval_undefined
();
return
hres
;
return
hres
;
}
}
...
@@ -2796,8 +2793,8 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, jsval_t *r)
...
@@ -2796,8 +2793,8 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, jsval_t *r)
assert
(
frame
->
scope
==
frame
->
base_scope
);
assert
(
frame
->
scope
==
frame
->
base_scope
);
if
(
return_to_interp
)
{
if
(
return_to_interp
)
{
clear_ret
(
frame
->
prev_frame
);
jsval_release
(
ctx
->
acc
);
frame
->
prev_frame
->
ret
=
steal_ret
(
frame
);
ctx
->
acc
=
steal_ret
(
frame
);
}
else
if
(
r
)
{
}
else
if
(
r
)
{
*
r
=
steal_ret
(
frame
);
*
r
=
steal_ret
(
frame
);
}
}
...
...
dlls/jscript/engine.h
View file @
5a90acf5
...
@@ -73,8 +73,8 @@
...
@@ -73,8 +73,8 @@
X(pop_scope, 1, 0,0) \
X(pop_scope, 1, 0,0) \
X(postinc, 1, ARG_INT, 0) \
X(postinc, 1, ARG_INT, 0) \
X(preinc, 1, ARG_INT, 0) \
X(preinc, 1, ARG_INT, 0) \
X(push_acc, 1, 0,0) \
X(push_except,1, ARG_ADDR, ARG_UINT) \
X(push_except,1, ARG_ADDR, ARG_UINT) \
X(push_ret, 1, 0,0) \
X(push_scope, 1, 0,0) \
X(push_scope, 1, 0,0) \
X(regexp, 1, ARG_STR, ARG_UINT) \
X(regexp, 1, ARG_STR, ARG_UINT) \
X(rshift, 1, 0,0) \
X(rshift, 1, 0,0) \
...
...
dlls/jscript/jscript.c
View file @
5a90acf5
...
@@ -69,6 +69,7 @@ void script_release(script_ctx_t *ctx)
...
@@ -69,6 +69,7 @@ void script_release(script_ctx_t *ctx)
if
(
--
ctx
->
ref
)
if
(
--
ctx
->
ref
)
return
;
return
;
jsval_release
(
ctx
->
acc
);
clear_ei
(
ctx
);
clear_ei
(
ctx
);
if
(
ctx
->
cc
)
if
(
ctx
->
cc
)
release_cc
(
ctx
->
cc
);
release_cc
(
ctx
->
cc
);
...
@@ -715,6 +716,7 @@ static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface)
...
@@ -715,6 +716,7 @@ static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface)
ctx
->
version
=
This
->
version
;
ctx
->
version
=
This
->
version
;
ctx
->
html_mode
=
This
->
html_mode
;
ctx
->
html_mode
=
This
->
html_mode
;
ctx
->
ei
.
val
=
jsval_undefined
();
ctx
->
ei
.
val
=
jsval_undefined
();
ctx
->
acc
=
jsval_undefined
();
heap_pool_init
(
&
ctx
->
tmp_heap
);
heap_pool_init
(
&
ctx
->
tmp_heap
);
hres
=
create_jscaller
(
ctx
);
hres
=
create_jscaller
(
ctx
);
...
...
dlls/jscript/jscript.h
View file @
5a90acf5
...
@@ -424,6 +424,7 @@ struct _script_ctx_t {
...
@@ -424,6 +424,7 @@ struct _script_ctx_t {
jsval_t
*
stack
;
jsval_t
*
stack
;
unsigned
stack_size
;
unsigned
stack_size
;
unsigned
stack_top
;
unsigned
stack_top
;
jsval_t
acc
;
jsstr_t
*
last_match
;
jsstr_t
*
last_match
;
match_result_t
match_parens
[
9
];
match_result_t
match_parens
[
9
];
...
...
dlls/jscript/tests/lang.js
View file @
5a90acf5
...
@@ -1146,6 +1146,27 @@ case 3:
...
@@ -1146,6 +1146,27 @@ case 3:
})();
})();
expect
(
ret
,
"ret"
);
expect
(
ret
,
"ret"
);
expect
(
x
,
"try,try2,finally2,finally,ret"
);
expect
(
x
,
"try,try2,finally2,finally,ret"
);
ret
=
(
function
()
{
try
{
return
"try"
;
unreachable
();
}
catch
(
e
)
{
unreachable
();
}
finally
{
new
Object
();
var
tmp
=
(
function
()
{
var
s
=
new
String
();
try
{
s
.
length
;
}
finally
{
return
1
;
}
})();
}
unreachable
();
})();
expect
(
ret
,
"try"
);
})();
})();
tmp
=
eval
(
"1"
);
tmp
=
eval
(
"1"
);
...
...
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