Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
6fa74e09
Commit
6fa74e09
authored
Dec 19, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
portability bug
cant assign to closed array R=r OCL=21634 CL=21634
parent
cd40cd24
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
30 deletions
+39
-30
src/cmd/6g/align.c
src/cmd/6g/align.c
+6
-1
src/cmd/6g/cgen.c
src/cmd/6g/cgen.c
+11
-11
src/cmd/6g/gg.h
src/cmd/6g/gg.h
+16
-0
src/cmd/6g/gsubr.c
src/cmd/6g/gsubr.c
+4
-4
src/cmd/gc/go.h
src/cmd/gc/go.h
+0
-14
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+2
-0
No files found.
src/cmd/6g/align.c
View file @
6fa74e09
...
...
@@ -151,7 +151,7 @@ dowidth(Type *t)
if
(
t
->
type
==
T
)
break
;
dowidth
(
t
->
type
);
w
=
sizeof
(
Array
)
;
w
=
sizeof
_Array
;
if
(
t
->
bound
>=
0
)
w
=
t
->
bound
*
t
->
type
->
width
;
break
;
...
...
@@ -259,5 +259,10 @@ belexinit(int lextype)
symstringo
=
lookup
(
".stringo"
);
// strings
Array_array
=
rnd
(
0
,
types
[
tptr
]
->
width
);
Array_nel
=
rnd
(
Array_array
+
types
[
tptr
]
->
width
,
types
[
TUINT32
]
->
width
);
Array_cap
=
rnd
(
Array_nel
+
types
[
TUINT32
]
->
width
,
types
[
TUINT32
]
->
width
);
sizeof_Array
=
rnd
(
Array_cap
+
types
[
TUINT32
]
->
width
,
maxround
);
listinit
();
}
src/cmd/6g/cgen.c
View file @
6fa74e09
...
...
@@ -189,14 +189,14 @@ cgen(Node *n, Node *res)
// convert dynamic array to static array
n2
=
n1
;
n2
.
op
=
OINDREG
;
n2
.
xoffset
=
offsetof
(
Array
,
array
)
;
n2
.
xoffset
=
Array_array
;
n2
.
type
=
types
[
tptr
];
gins
(
AMOVQ
,
&
n2
,
&
n1
);
}
if
(
isptrdarray
(
n
->
type
)
&&
isptrsarray
(
nl
->
type
))
{
// conver static array to dynamic array
// it is assumed that the dope is just before the array
nodconst
(
&
n2
,
types
[
tptr
],
sizeof
(
Array
)
);
nodconst
(
&
n2
,
types
[
tptr
],
sizeof
_Array
);
gins
(
ASUBQ
,
&
n2
,
&
n1
);
}
gmove
(
&
n1
,
res
);
...
...
@@ -247,7 +247,7 @@ cgen(Node *n, Node *res)
cgen
(
nl
,
&
n1
);
n1
.
op
=
OINDREG
;
n1
.
type
=
types
[
TUINT32
];
n1
.
xoffset
=
offsetof
(
Array
,
nel
)
;
n1
.
xoffset
=
Array_nel
;
gmove
(
&
n1
,
res
);
regfree
(
&
n1
);
break
;
...
...
@@ -257,7 +257,7 @@ cgen(Node *n, Node *res)
agen
(
nl
,
&
n1
);
n1
.
op
=
OINDREG
;
n1
.
type
=
types
[
TUINT32
];
n1
.
xoffset
=
offsetof
(
Array
,
nel
)
;
n1
.
xoffset
=
Array_nel
;
gmove
(
&
n1
,
res
);
regfree
(
&
n1
);
break
;
...
...
@@ -271,7 +271,7 @@ cgen(Node *n, Node *res)
cgen
(
nl
,
&
n1
);
n1
.
op
=
OINDREG
;
n1
.
type
=
types
[
TUINT32
];
n1
.
xoffset
=
offsetof
(
Array
,
cap
)
;
n1
.
xoffset
=
Array_cap
;
gmove
(
&
n1
,
res
);
regfree
(
&
n1
);
break
;
...
...
@@ -281,7 +281,7 @@ cgen(Node *n, Node *res)
agen
(
nl
,
&
n1
);
n1
.
op
=
OINDREG
;
n1
.
type
=
types
[
TUINT32
];
n1
.
xoffset
=
offsetof
(
Array
,
cap
)
;
n1
.
xoffset
=
Array_cap
;
gmove
(
&
n1
,
res
);
regfree
(
&
n1
);
break
;
...
...
@@ -491,7 +491,7 @@ agen(Node *n, Node *res)
n1
=
n3
;
n1
.
op
=
OINDREG
;
n1
.
type
=
types
[
tptr
];
n1
.
xoffset
=
offsetof
(
Array
,
nel
)
;
n1
.
xoffset
=
Array_nel
;
nodconst
(
&
n2
,
types
[
TUINT64
],
v
);
gins
(
optoas
(
OCMP
,
types
[
TUINT32
]),
&
n1
,
&
n2
);
p1
=
gbranch
(
optoas
(
OGT
,
types
[
TUINT32
]),
T
);
...
...
@@ -502,7 +502,7 @@ agen(Node *n, Node *res)
n1
=
n3
;
n1
.
op
=
OINDREG
;
n1
.
type
=
types
[
tptr
];
n1
.
xoffset
=
offsetof
(
Array
,
array
)
;
n1
.
xoffset
=
Array_array
;
gmove
(
&
n1
,
&
n3
);
}
else
if
(
!
debug
[
'B'
])
{
...
...
@@ -540,7 +540,7 @@ agen(Node *n, Node *res)
n1
=
n3
;
n1
.
op
=
OINDREG
;
n1
.
type
=
types
[
tptr
];
n1
.
xoffset
=
offsetof
(
Array
,
nel
)
;
n1
.
xoffset
=
Array_nel
;
}
else
{
nodconst
(
&
n1
,
types
[
TUINT64
],
nl
->
type
->
bound
);
if
(
isptrsarray
(
nl
->
type
))
...
...
@@ -556,7 +556,7 @@ agen(Node *n, Node *res)
n1
=
n3
;
n1
.
op
=
OINDREG
;
n1
.
type
=
types
[
tptr
];
n1
.
xoffset
=
offsetof
(
Array
,
array
)
;
n1
.
xoffset
=
Array_array
;
gmove
(
&
n1
,
&
n3
);
}
...
...
@@ -756,7 +756,7 @@ bgen(Node *n, int true, Prog *to)
agen
(
nl
,
&
n1
);
n2
=
n1
;
n2
.
op
=
OINDREG
;
n2
.
xoffset
=
offsetof
(
Array
,
array
)
;
n2
.
xoffset
=
Array_array
;
nodconst
(
&
tmp
,
types
[
tptr
],
0
);
gins
(
optoas
(
OCMP
,
types
[
tptr
]),
&
n2
,
&
tmp
);
patch
(
gbranch
(
a
,
types
[
tptr
]),
to
);
...
...
src/cmd/6g/gg.h
View file @
6fa74e09
...
...
@@ -119,6 +119,22 @@ EXTERN Node* newproc;
EXTERN
Node
*
throwindex
;
EXTERN
Node
*
throwreturn
;
/*
* note this is the runtime representation
* of the compilers arrays.
*
* typedef struct
* { // must not move anything
* uchar array[8]; // pointer to data
* uchar nel[4]; // number of elements
* uchar cap[4]; // allocated number of elements
* } Array;
*/
EXTERN
int
Array_array
;
// runtime offsetof(Array,array)
EXTERN
int
Array_nel
;
// runtime offsetof(Array,nel)
EXTERN
int
Array_cap
;
// runtime offsetof(Array,cap)
EXTERN
int
sizeof_Array
;
// runtime sizeof(Array)
/*
* gen.c
*/
...
...
src/cmd/6g/gsubr.c
View file @
6fa74e09
...
...
@@ -1965,7 +1965,7 @@ oindex:
n2
=
*
reg
;
n2
.
op
=
OINDREG
;
n2
.
type
=
types
[
tptr
];
n2
.
xoffset
=
offsetof
(
Array
,
nel
)
;
n2
.
xoffset
=
Array_nel
;
}
else
{
nodconst
(
&
n2
,
types
[
TUINT64
],
l
->
type
->
bound
);
if
(
o
&
OPtrto
)
...
...
@@ -1981,7 +1981,7 @@ oindex:
n2
=
*
reg
;
n2
.
op
=
OINDREG
;
n2
.
type
=
types
[
tptr
];
n2
.
xoffset
=
offsetof
(
Array
,
array
)
;
n2
.
xoffset
=
Array_array
;
gmove
(
&
n2
,
reg
);
}
...
...
@@ -2011,7 +2011,7 @@ oindex_const:
n1
=
*
reg
;
n1
.
op
=
OINDREG
;
n1
.
type
=
types
[
tptr
];
n1
.
xoffset
=
offsetof
(
Array
,
nel
)
;
n1
.
xoffset
=
Array_nel
;
nodconst
(
&
n2
,
types
[
TUINT64
],
v
);
gins
(
optoas
(
OCMP
,
types
[
TUINT32
]),
&
n1
,
&
n2
);
p1
=
gbranch
(
optoas
(
OGT
,
types
[
TUINT32
]),
T
);
...
...
@@ -2022,7 +2022,7 @@ oindex_const:
n1
=
*
reg
;
n1
.
op
=
OINDREG
;
n1
.
type
=
types
[
tptr
];
n1
.
xoffset
=
offsetof
(
Array
,
array
)
;
n1
.
xoffset
=
Array_array
;
gmove
(
&
n1
,
reg
);
}
else
...
...
src/cmd/gc/go.h
View file @
6fa74e09
...
...
@@ -61,20 +61,6 @@ struct String
char
s
[
3
];
// variable
};
/*
* note this is the runtime representation
* of the compilers arrays. it is probably
* insafe to use it this way, but it puts
* all the changes in one place.
*/
typedef
struct
Array
Array
;
struct
Array
{
// must not move anything
uchar
array
[
8
];
// pointer to data
uchar
nel
[
4
];
// number of elements
uchar
cap
[
4
];
// allocated number of elements
};
/*
* note this is the runtime representation
* of hashmap iterator. it is probably
...
...
src/cmd/gc/walk.c
View file @
6fa74e09
...
...
@@ -1873,6 +1873,8 @@ ascompat(Type *t1, Type *t2)
// if(eqtype(t2, nilptr, 0))
// return 1;
if
(
issarray
(
t1
))
return
0
;
if
(
isnilinter
(
t1
))
return
1
;
if
(
isinter
(
t1
))
{
...
...
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