Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(171)

Side by Side Diff: src/pkg/runtime/runtime.h

Issue 5453043: code review 5453043: runtime: prep for type-specific algorithms (Closed)
Patch Set: diff -r adff3701bfc7 https://go.googlecode.com/hg/ Created 13 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/runtime/iface.c ('k') | src/pkg/runtime/runtime.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 /* 5 /*
6 * basic types 6 * basic types
7 */ 7 */
8 typedef signed char int8; 8 typedef signed char int8;
9 typedef unsigned char uint8; 9 typedef unsigned char uint8;
10 typedef signed short int16; 10 typedef signed short int16;
(...skipping 25 matching lines...) Expand all
36 #define int XXint / / / 36 #define int XXint / / /
37 #define long XXlong / / / 37 #define long XXlong / / /
38 #define float XXfloat / / / 38 #define float XXfloat / / /
39 #define double XXdouble / / / 39 #define double XXdouble / / /
40 40
41 /* 41 /*
42 * defined types 42 * defined types
43 */ 43 */
44 typedef uint8 bool; 44 typedef uint8 bool;
45 typedef uint8 byte; 45 typedef uint8 byte;
46 typedef struct Alg Alg;
47 typedef struct Func Func; 46 typedef struct Func Func;
48 typedef struct G G; 47 typedef struct G G;
49 typedef struct Gobuf Gobuf; 48 typedef struct Gobuf Gobuf;
50 typedef union Lock Lock; 49 typedef union Lock Lock;
51 typedef struct M M; 50 typedef struct M M;
52 typedef struct Mem Mem; 51 typedef struct Mem Mem;
53 typedef union Note Note; 52 typedef union Note Note;
54 typedef struct Slice Slice; 53 typedef struct Slice Slice;
55 typedef struct Stktop Stktop; 54 typedef struct Stktop Stktop;
56 typedef struct String String; 55 typedef struct String String;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // The offsets of these fields are known to (hard-coded in) libmach. 252 // The offsets of these fields are known to (hard-coded in) libmach.
254 uint8* stackguard; 253 uint8* stackguard;
255 uint8* stackbase; 254 uint8* stackbase;
256 Gobuf gobuf; 255 Gobuf gobuf;
257 uint32 argsize; 256 uint32 argsize;
258 257
259 uint8* argp; // pointer to arguments in old frame 258 uint8* argp; // pointer to arguments in old frame
260 uintptr free; // if free>0, call stackfree using free as size 259 uintptr free; // if free>0, call stackfree using free as size
261 bool panic; // is this frame the top of a panic? 260 bool panic; // is this frame the top of a panic?
262 }; 261 };
263 struct Alg
264 {
265 uintptr (*hash)(uint32, void*);
266 uint32 (*equal)(uint32, void*, void*);
267 void (*print)(uint32, void*);
268 void (*copy)(uint32, void*, void*);
269 };
270 struct SigTab 262 struct SigTab
271 { 263 {
272 int32 flags; 264 int32 flags;
273 int8 *name; 265 int8 *name;
274 }; 266 };
275 enum 267 enum
276 { 268 {
277 SigCatch = 1<<0, 269 SigCatch = 1<<0,
278 SigIgnore = 1<<1, 270 SigIgnore = 1<<1,
279 SigRestart = 1<<2, 271 SigRestart = 1<<2,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 * you need super-gopher-guru privilege 341 * you need super-gopher-guru privilege
350 * to add this list. 342 * to add this list.
351 */ 343 */
352 #define nelem(x) (sizeof(x)/sizeof((x)[0])) 344 #define nelem(x) (sizeof(x)/sizeof((x)[0]))
353 #define nil ((void*)0) 345 #define nil ((void*)0)
354 #define offsetof(s,m) (uint32)(&(((s*)0)->m)) 346 #define offsetof(s,m) (uint32)(&(((s*)0)->m))
355 347
356 /* 348 /*
357 * known to compiler 349 * known to compiler
358 */ 350 */
351 enum {
352 Structrnd = sizeof(uintptr)
353 };
354
355 /*
356 * type algorithms - known to compiler
357 */
359 enum 358 enum
360 { 359 {
361 AMEM, 360 AMEM,
362 ANOEQ, 361 ANOEQ,
363 ASTRING, 362 ASTRING,
364 AINTER, 363 AINTER,
365 ANILINTER, 364 ANILINTER,
366 ASLICE, 365 ASLICE,
367 AMEM8, 366 AMEM8,
368 AMEM16, 367 AMEM16,
369 AMEM32, 368 AMEM32,
370 AMEM64, 369 AMEM64,
371 AMEM128, 370 AMEM128,
372 ANOEQ8, 371 ANOEQ8,
373 ANOEQ16, 372 ANOEQ16,
374 ANOEQ32, 373 ANOEQ32,
375 ANOEQ64, 374 ANOEQ64,
376 ANOEQ128, 375 ANOEQ128,
377 Amax 376 Amax
378 }; 377 };
378 typedef struct Alg Alg;
379 struct Alg
380 {
381 void (*hash)(uintptr*, uintptr, void*);
382 void (*equal)(bool*, uintptr, void*, void*);
383 void (*print)(uintptr, void*);
384 void (*copy)(uintptr, void*, void*);
385 };
379 386
387 extern Alg runtime·algarray[Amax];
380 388
381 enum { 389 void» runtime·memhash(uintptr*, uintptr, void*);
382 » Structrnd = sizeof(uintptr) 390 void» runtime·nohash(uintptr*, uintptr, void*);
383 }; 391 void» runtime·strhash(uintptr*, uintptr, void*);
392 void» runtime·interhash(uintptr*, uintptr, void*);
393 void» runtime·nilinterhash(uintptr*, uintptr, void*);
394
395 void» runtime·memequal(bool*, uintptr, void*, void*);
396 void» runtime·noequal(bool*, uintptr, void*, void*);
397 void» runtime·strequal(bool*, uintptr, void*, void*);
398 void» runtime·interequal(bool*, uintptr, void*, void*);
399 void» runtime·nilinterequal(bool*, uintptr, void*, void*);
400
401 void» runtime·memprint(uintptr, void*);
402 void» runtime·strprint(uintptr, void*);
403 void» runtime·interprint(uintptr, void*);
404 void» runtime·nilinterprint(uintptr, void*);
405
406 void» runtime·memcopy(uintptr, void*, void*);
407 void» runtime·memcopy8(uintptr, void*, void*);
408 void» runtime·memcopy16(uintptr, void*, void*);
409 void» runtime·memcopy32(uintptr, void*, void*);
410 void» runtime·memcopy64(uintptr, void*, void*);
411 void» runtime·memcopy128(uintptr, void*, void*);
412 void» runtime·memcopy(uintptr, void*, void*);
413 void» runtime·strcopy(uintptr, void*, void*);
414 void» runtime·algslicecopy(uintptr, void*, void*);
415 void» runtime·intercopy(uintptr, void*, void*);
416 void» runtime·nilintercopy(uintptr, void*, void*);
384 417
385 /* 418 /*
386 * deferred subroutine calls 419 * deferred subroutine calls
387 */ 420 */
388 struct Defer 421 struct Defer
389 { 422 {
390 int32 siz; 423 int32 siz;
391 bool nofree; 424 bool nofree;
392 byte* argp; // where args were copied from 425 byte* argp; // where args were copied from
393 byte* pc; 426 byte* pc;
394 byte* fn; 427 byte* fn;
395 Defer* link; 428 Defer* link;
396 byte args[8]; // padded to actual size 429 byte args[8]; // padded to actual size
397 }; 430 };
398 431
399 /* 432 /*
400 * panics 433 * panics
401 */ 434 */
402 struct Panic 435 struct Panic
403 { 436 {
404 Eface arg; // argument to panic 437 Eface arg; // argument to panic
405 byte* stackbase; // g->stackbase in panic 438 byte* stackbase; // g->stackbase in panic
406 Panic* link; // link to earlier panic 439 Panic* link; // link to earlier panic
407 bool recovered; // whether this panic is over 440 bool recovered; // whether this panic is over
408 }; 441 };
409 442
410 /* 443 /*
411 * external data 444 * external data
412 */ 445 */
413 extern Alg runtime·algarray[Amax];
414 extern String runtime·emptystring; 446 extern String runtime·emptystring;
415 G* runtime·allg; 447 G* runtime·allg;
416 G* runtime·lastg; 448 G* runtime·lastg;
417 M* runtime·allm; 449 M* runtime·allm;
418 extern int32 runtime·gomaxprocs; 450 extern int32 runtime·gomaxprocs;
419 extern bool runtime·singleproc; 451 extern bool runtime·singleproc;
420 extern uint32 runtime·panicking; 452 extern uint32 runtime·panicking;
421 extern int32 runtime·gcwaiting; // gc is waiting to run 453 extern int32 runtime·gcwaiting; // gc is waiting to run
422 int8* runtime·goos; 454 int8* runtime·goos;
423 int32 runtime·ncpu; 455 int32 runtime·ncpu;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 Func* runtime·findfunc(uintptr); 523 Func* runtime·findfunc(uintptr);
492 int32 runtime·funcline(Func*, uintptr); 524 int32 runtime·funcline(Func*, uintptr);
493 void* runtime·stackalloc(uint32); 525 void* runtime·stackalloc(uint32);
494 void runtime·stackfree(void*, uintptr); 526 void runtime·stackfree(void*, uintptr);
495 MCache* runtime·allocmcache(void); 527 MCache* runtime·allocmcache(void);
496 void runtime·mallocinit(void); 528 void runtime·mallocinit(void);
497 bool runtime·ifaceeq_c(Iface, Iface); 529 bool runtime·ifaceeq_c(Iface, Iface);
498 bool runtime·efaceeq_c(Eface, Eface); 530 bool runtime·efaceeq_c(Eface, Eface);
499 uintptr runtime·ifacehash(Iface); 531 uintptr runtime·ifacehash(Iface);
500 uintptr runtime·efacehash(Eface); 532 uintptr runtime·efacehash(Eface);
501 uintptr runtime·nohash(uint32, void*);
502 uint32 runtime·noequal(uint32, void*, void*);
503 void* runtime·malloc(uintptr size); 533 void* runtime·malloc(uintptr size);
504 void runtime·free(void *v); 534 void runtime·free(void *v);
505 bool runtime·addfinalizer(void*, void(*fn)(void*), int32); 535 bool runtime·addfinalizer(void*, void(*fn)(void*), int32);
506 void runtime·runpanic(Panic*); 536 void runtime·runpanic(Panic*);
507 void* runtime·getcallersp(void*); 537 void* runtime·getcallersp(void*);
508 int32 runtime·mcount(void); 538 int32 runtime·mcount(void);
509 void runtime·mcall(void(*)(G*)); 539 void runtime·mcall(void(*)(G*));
510 uint32 runtime·fastrand1(void); 540 uint32 runtime·fastrand1(void);
511 541
512 void runtime·exit(int32); 542 void runtime·exit(int32);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 710
681 Hchan* runtime·makechan_c(ChanType*, int64); 711 Hchan* runtime·makechan_c(ChanType*, int64);
682 void runtime·chansend(ChanType*, Hchan*, byte*, bool*); 712 void runtime·chansend(ChanType*, Hchan*, byte*, bool*);
683 void runtime·chanrecv(ChanType*, Hchan*, byte*, bool*, bool*); 713 void runtime·chanrecv(ChanType*, Hchan*, byte*, bool*, bool*);
684 int32 runtime·chanlen(Hchan*); 714 int32 runtime·chanlen(Hchan*);
685 int32 runtime·chancap(Hchan*); 715 int32 runtime·chancap(Hchan*);
686 bool runtime·showframe(Func*); 716 bool runtime·showframe(Func*);
687 717
688 void runtime·ifaceE2I(struct InterfaceType*, Eface, Iface*); 718 void runtime·ifaceE2I(struct InterfaceType*, Eface, Iface*);
689 719
OLDNEW
« no previous file with comments | « src/pkg/runtime/iface.c ('k') | src/pkg/runtime/runtime.c » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b