LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 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 // The racewalk pass modifies the code tree for the function as follows: | 5 // The racewalk pass modifies the code tree for the function as follows: |
6 // | 6 // |
7 // 1. It inserts a call to racefuncenter at the beginning of each function. | 7 // 1. It inserts a call to racefuncenter at the beginning of each function. |
8 // 2. It inserts a call to racefuncexit at the end of each function. | 8 // 2. It inserts a call to racefuncexit at the end of each function. |
9 // 3. It inserts a call to raceread before each memory read. | 9 // 3. It inserts a call to raceread before each memory read. |
10 // 4. It inserts a call to racewrite before each memory write. | 10 // 4. It inserts a call to racewrite before each memory write. |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 // the heap or not is impossible to know at compile time | 468 // the heap or not is impossible to know at compile time |
469 if((class&PHEAP) || class == PPARAMREF || class == PEXTERN | 469 if((class&PHEAP) || class == PPARAMREF || class == PEXTERN |
470 || b->type->etype == TARRAY || b->op == ODOTPTR || b->op == OIND
|| b->op == OXDOT) { | 470 || b->type->etype == TARRAY || b->op == ODOTPTR || b->op == OIND
|| b->op == OXDOT) { |
471 hascalls = 0; | 471 hascalls = 0; |
472 foreach(n, hascallspred, &hascalls); | 472 foreach(n, hascallspred, &hascalls); |
473 if(hascalls) { | 473 if(hascalls) { |
474 n = detachexpr(n, init); | 474 n = detachexpr(n, init); |
475 *np = n; | 475 *np = n; |
476 } | 476 } |
477 n = treecopy(n); | 477 n = treecopy(n); |
478 » » f = mkcall(wr ? "racewrite" : "raceread", T, nil, uintptraddr(n)
); | 478 » » f = mkcall(wr ? "racewrite" : "raceread", T, init, uintptraddr(n
)); |
479 » » //typecheck(&f, Etop); | |
480 *init = list(*init, f); | 479 *init = list(*init, f); |
481 return 1; | 480 return 1; |
482 } | 481 } |
483 return 0; | 482 return 0; |
484 } | 483 } |
485 | 484 |
486 static Node* | 485 static Node* |
487 uintptraddr(Node *n) | 486 uintptraddr(Node *n) |
488 { | 487 { |
489 Node *r; | 488 Node *r; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 hascallspred(Node *n, void *c) | 559 hascallspred(Node *n, void *c) |
561 { | 560 { |
562 switch(n->op) { | 561 switch(n->op) { |
563 case OCALL: | 562 case OCALL: |
564 case OCALLFUNC: | 563 case OCALLFUNC: |
565 case OCALLMETH: | 564 case OCALLMETH: |
566 case OCALLINTER: | 565 case OCALLINTER: |
567 (*(int*)c)++; | 566 (*(int*)c)++; |
568 } | 567 } |
569 } | 568 } |
LEFT | RIGHT |