Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
be885e28
Commit
be885e28
authored
Oct 11, 2012
by
Jacek Caban
Committed by
Alexandre Julliard
Oct 11, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Use jsstr_t for compiler constant strings.
parent
31828522
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
40 deletions
+55
-40
compile.c
dlls/jscript/compile.c
+40
-18
engine.c
dlls/jscript/engine.c
+10
-21
engine.h
dlls/jscript/engine.h
+5
-1
No files found.
dlls/jscript/compile.c
View file @
be885e28
...
...
@@ -75,7 +75,7 @@ static void dump_instr_arg(instr_arg_type_t type, instr_arg_t *arg)
{
switch
(
type
)
{
case
ARG_STR
:
TRACE_
(
jscript_disas
)(
"
\t
%s"
,
debugstr_
w
(
arg
->
str
));
TRACE_
(
jscript_disas
)(
"
\t
%s"
,
debugstr_
jsstr
(
arg
->
str
));
break
;
case
ARG_BSTR
:
TRACE_
(
jscript_disas
)(
"
\t
%s"
,
debugstr_wn
(
arg
->
bstr
,
SysStringLen
(
arg
->
bstr
)));
...
...
@@ -119,16 +119,37 @@ static inline void *compiler_alloc(bytecode_t *code, size_t size)
return
jsheap_alloc
(
&
code
->
heap
,
size
);
}
static
WCHAR
*
compiler_alloc_string
(
bytecode_t
*
code
,
const
WCHAR
*
str
)
static
jsstr_t
*
compiler_alloc_string_len
(
compiler_ctx_t
*
ctx
,
const
WCHAR
*
str
,
unsigned
len
)
{
size_t
size
;
WCHAR
*
ret
;
jsstr_t
*
new_str
;
size
=
(
strlenW
(
str
)
+
1
)
*
sizeof
(
WCHAR
);
ret
=
compiler_alloc
(
code
,
size
);
if
(
ret
)
memcpy
(
ret
,
str
,
size
);
return
ret
;
if
(
!
ctx
->
code
->
str_pool_size
)
{
ctx
->
code
->
str_pool
=
heap_alloc
(
8
*
sizeof
(
jsstr_t
*
));
if
(
!
ctx
->
code
->
str_pool
)
return
NULL
;
ctx
->
code
->
str_pool_size
=
8
;
}
else
if
(
ctx
->
code
->
str_pool_size
==
ctx
->
code
->
str_cnt
)
{
jsstr_t
**
new_pool
;
new_pool
=
heap_realloc
(
ctx
->
code
->
str_pool
,
ctx
->
code
->
str_pool_size
*
2
*
sizeof
(
jsstr_t
*
));
if
(
!
new_pool
)
return
NULL
;
ctx
->
code
->
str_pool
=
new_pool
;
ctx
->
code
->
str_pool_size
*=
2
;
}
new_str
=
jsstr_alloc_len
(
str
,
len
);
if
(
!
new_str
)
return
NULL
;
ctx
->
code
->
str_pool
[
ctx
->
code
->
str_cnt
++
]
=
new_str
;
return
new_str
;
}
static
jsstr_t
*
compiler_alloc_string
(
compiler_ctx_t
*
ctx
,
const
WCHAR
*
str
)
{
return
compiler_alloc_string_len
(
ctx
,
str
,
strlenW
(
str
));
}
static
BOOL
ensure_bstr_slot
(
compiler_ctx_t
*
ctx
)
...
...
@@ -216,9 +237,9 @@ static HRESULT push_instr_int(compiler_ctx_t *ctx, jsop_t op, LONG arg)
static
HRESULT
push_instr_str
(
compiler_ctx_t
*
ctx
,
jsop_t
op
,
const
WCHAR
*
arg
)
{
unsigned
instr
;
WCHAR
*
str
;
jsstr_t
*
str
;
str
=
compiler_alloc_string
(
ctx
->
code
,
arg
);
str
=
compiler_alloc_string
(
ctx
,
arg
);
if
(
!
str
)
return
E_OUTOFMEMORY
;
...
...
@@ -268,9 +289,9 @@ static HRESULT push_instr_bstr_uint(compiler_ctx_t *ctx, jsop_t op, const WCHAR
static
HRESULT
push_instr_uint_str
(
compiler_ctx_t
*
ctx
,
jsop_t
op
,
unsigned
arg1
,
const
WCHAR
*
arg2
)
{
unsigned
instr
;
WCHAR
*
str
;
jsstr_t
*
str
;
str
=
compiler_alloc_string
(
ctx
->
code
,
arg2
);
str
=
compiler_alloc_string
(
ctx
,
arg2
);
if
(
!
str
)
return
E_OUTOFMEMORY
;
...
...
@@ -711,7 +732,7 @@ static HRESULT compile_typeof_expression(compiler_ctx_t *ctx, unary_expression_t
if
(
is_memberid_expr
(
expr
->
expression
->
type
))
{
if
(
expr
->
expression
->
type
==
EXPR_IDENT
)
return
push_instr_str
(
ctx
,
OP_typeofident
,
((
identifier_expression_t
*
)
expr
->
expression
)
->
identifier
);
return
push_instr_
b
str
(
ctx
,
OP_typeofident
,
((
identifier_expression_t
*
)
expr
->
expression
)
->
identifier
);
op
=
OP_typeofid
;
hres
=
compile_memberid_expression
(
ctx
,
expr
->
expression
,
0
);
...
...
@@ -738,13 +759,11 @@ static HRESULT compile_literal(compiler_ctx_t *ctx, literal_t *literal)
return
push_instr_str
(
ctx
,
OP_str
,
literal
->
u
.
wstr
);
case
LT_REGEXP
:
{
unsigned
instr
;
WCHAR
*
str
;
jsstr_t
*
str
;
str
=
compiler_alloc
(
ctx
->
code
,
(
literal
->
u
.
regexp
.
str_len
+
1
)
*
sizeof
(
WCHAR
)
);
str
=
compiler_alloc
_string_len
(
ctx
,
literal
->
u
.
regexp
.
str
,
literal
->
u
.
regexp
.
str_len
);
if
(
!
str
)
return
E_OUTOFMEMORY
;
memcpy
(
str
,
literal
->
u
.
regexp
.
str
,
literal
->
u
.
regexp
.
str_len
*
sizeof
(
WCHAR
));
str
[
literal
->
u
.
regexp
.
str_len
]
=
0
;
instr
=
push_instr
(
ctx
,
OP_regexp
);
if
(
!
instr
)
...
...
@@ -1796,10 +1815,13 @@ void release_bytecode(bytecode_t *code)
for
(
i
=
0
;
i
<
code
->
bstr_cnt
;
i
++
)
SysFreeString
(
code
->
bstr_pool
[
i
]);
for
(
i
=
0
;
i
<
code
->
str_cnt
;
i
++
)
jsstr_release
(
code
->
str_pool
[
i
]);
heap_free
(
code
->
source
);
jsheap_free
(
&
code
->
heap
);
heap_free
(
code
->
bstr_pool
);
heap_free
(
code
->
str_pool
);
heap_free
(
code
->
instrs
);
heap_free
(
code
);
}
...
...
dlls/jscript/engine.c
View file @
be885e28
...
...
@@ -549,7 +549,7 @@ static inline unsigned get_op_int(exec_ctx_t *ctx, int i){
return
ctx
->
code
->
instrs
[
ctx
->
ip
].
u
.
arg
[
i
].
lng
;
}
static
inline
const
WCHAR
*
get_op_str
(
exec_ctx_t
*
ctx
,
int
i
){
static
inline
jsstr_t
*
get_op_str
(
exec_ctx_t
*
ctx
,
int
i
){
return
ctx
->
code
->
instrs
[
ctx
->
ip
].
u
.
arg
[
i
].
str
;
}
...
...
@@ -718,11 +718,11 @@ static HRESULT interp_throw_ref(exec_ctx_t *ctx)
static
HRESULT
interp_throw_type
(
exec_ctx_t
*
ctx
)
{
const
HRESULT
hres
=
get_op_uint
(
ctx
,
0
);
const
WCHAR
*
str
=
get_op_str
(
ctx
,
1
);
jsstr_t
*
str
=
get_op_str
(
ctx
,
1
);
TRACE
(
"%08x %s
\n
"
,
hres
,
debugstr_
w
(
str
));
TRACE
(
"%08x %s
\n
"
,
hres
,
debugstr_
jsstr
(
str
));
return
throw_type_error
(
ctx
->
script
,
hres
,
str
);
return
throw_type_error
(
ctx
->
script
,
hres
,
str
->
str
);
}
/* ECMA-262 3rd Edition 12.14 */
...
...
@@ -1134,35 +1134,24 @@ static HRESULT interp_double(exec_ctx_t *ctx)
/* ECMA-262 3rd Edition 7.8.4 */
static
HRESULT
interp_str
(
exec_ctx_t
*
ctx
)
{
const
WCHAR
*
arg
=
get_op_str
(
ctx
,
0
);
jsstr_t
*
str
;
TRACE
(
"%s
\n
"
,
debugstr_w
(
arg
));
jsstr_t
*
str
=
get_op_str
(
ctx
,
0
);
str
=
jsstr_alloc
(
arg
);
if
(
!
str
)
return
E_OUTOFMEMORY
;
TRACE
(
"%s
\n
"
,
debugstr_jsstr
(
str
));
return
stack_push
(
ctx
,
jsval_string
(
str
));
return
stack_push
(
ctx
,
jsval_string
(
jsstr_addref
(
str
)
));
}
/* ECMA-262 3rd Edition 7.8 */
static
HRESULT
interp_regexp
(
exec_ctx_t
*
ctx
)
{
const
WCHAR
*
source
=
get_op_str
(
ctx
,
0
);
jsstr_t
*
source
=
get_op_str
(
ctx
,
0
);
const
unsigned
flags
=
get_op_uint
(
ctx
,
1
);
jsdisp_t
*
regexp
;
jsstr_t
*
src
;
HRESULT
hres
;
TRACE
(
"%s %x
\n
"
,
debugstr_w
(
source
),
flags
);
src
=
jsstr_alloc
(
source
);
if
(
!
src
)
return
E_OUTOFMEMORY
;
TRACE
(
"%s %x
\n
"
,
debugstr_jsstr
(
source
),
flags
);
hres
=
create_regexp
(
ctx
->
script
,
src
,
flags
,
&
regexp
);
jsstr_release
(
src
);
hres
=
create_regexp
(
ctx
->
script
,
source
,
flags
,
&
regexp
);
if
(
FAILED
(
hres
))
return
hres
;
...
...
dlls/jscript/engine.h
View file @
be885e28
...
...
@@ -121,7 +121,7 @@ OP_LIST
typedef
union
{
BSTR
bstr
;
LONG
lng
;
WCHAR
*
str
;
jsstr_t
*
str
;
unsigned
uint
;
}
instr_arg_t
;
...
...
@@ -175,6 +175,10 @@ typedef struct _bytecode_t {
unsigned
bstr_pool_size
;
unsigned
bstr_cnt
;
jsstr_t
**
str_pool
;
unsigned
str_pool_size
;
unsigned
str_cnt
;
struct
_bytecode_t
*
next
;
}
bytecode_t
;
...
...
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