Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Side by Side Diff: src/IceAssembler.h

Issue 1511653002: Fix problems with sandboxing and the ARM integrated assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Lift pass information into linkTo() and nearLinkTo(). Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===- subzero/src/IceAssembler.h - Integrated assembler --------*- C++ -*-===// 1 //===- subzero/src/IceAssembler.h - Integrated assembler --------*- C++ -*-===//
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 // 5 //
6 // Modified by the Subzero authors. 6 // Modified by the Subzero authors.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // The Subzero Code Generator 10 // The Subzero Code Generator
(...skipping 14 matching lines...) Expand all
25 25
26 #ifndef SUBZERO_SRC_ICEASSEMBLER_H 26 #ifndef SUBZERO_SRC_ICEASSEMBLER_H
27 #define SUBZERO_SRC_ICEASSEMBLER_H 27 #define SUBZERO_SRC_ICEASSEMBLER_H
28 28
29 #include "IceDefs.h" 29 #include "IceDefs.h"
30 #include "IceFixups.h" 30 #include "IceFixups.h"
31 #include "IceUtils.h" 31 #include "IceUtils.h"
32 32
33 namespace Ice { 33 namespace Ice {
34 34
35 class Assembler;
36
35 /// A Label can be in one of three states: 37 /// A Label can be in one of three states:
36 /// - Unused. 38 /// - Unused.
37 /// - Linked, unplaced and tracking the position of branches to the label. 39 /// - Linked, unplaced and tracking the position of branches to the label.
38 /// - Bound, placed and tracking its position. 40 /// - Bound, placed and tracking its position.
39 class Label { 41 class Label {
40 Label(const Label &) = delete; 42 Label(const Label &) = delete;
41 Label &operator=(const Label &) = delete; 43 Label &operator=(const Label &) = delete;
42 44
43 public: 45 public:
44 Label() = default; 46 Label() = default;
(...skipping 30 matching lines...) Expand all
75 bool isLinked() const { return Position > 0; } 77 bool isLinked() const { return Position > 0; }
76 78
77 virtual bool isUnused() const { return Position == 0; } 79 virtual bool isUnused() const { return Position == 0; }
78 80
79 void bindTo(intptr_t position) { 81 void bindTo(intptr_t position) {
80 assert(!isBound()); 82 assert(!isBound());
81 Position = -position - kWordSize; 83 Position = -position - kWordSize;
82 assert(isBound()); 84 assert(isBound());
83 } 85 }
84 86
85 void linkTo(intptr_t position) { 87 inline void linkTo(const Assembler &Asm, intptr_t position);
Jim Stichnoth 2015/12/08 22:20:00 Does the "inline" really help here? Also, we may
Karl 2015/12/08 22:39:32 The "inline" is needed if we don't want the functi
Jim Stichnoth 2015/12/08 23:06:44 No - "const Assembler *Asm" means that the pointed
86 assert(!isBound());
87 Position = position + kWordSize;
88 assert(isLinked());
89 }
90 88
91 protected: 89 protected:
92 intptr_t Position = 0; 90 intptr_t Position = 0;
93 91
94 // TODO(jvoung): why are labels offset by this? 92 // TODO(jvoung): why are labels offset by this?
95 static constexpr uint32_t kWordSize = sizeof(uint32_t); 93 static constexpr uint32_t kWordSize = sizeof(uint32_t);
96 }; 94 };
97 95
98 /// Assembler buffers are used to emit binary code. They grow on demand. 96 /// Assembler buffers are used to emit binary code. They grow on demand.
99 class AssemblerBuffer { 97 class AssemblerBuffer {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 /// Installs a created fixup, after it has been allocated. 345 /// Installs a created fixup, after it has been allocated.
348 void installFixup(AssemblerFixup *F) { Buffer.installFixup(F); } 346 void installFixup(AssemblerFixup *F) { Buffer.installFixup(F); }
349 347
350 protected: 348 protected:
351 // Buffer's constructor uses the Allocator, so it needs to appear after it. 349 // Buffer's constructor uses the Allocator, so it needs to appear after it.
352 // TODO(jpp): dependencies on construction order are a nice way of shooting 350 // TODO(jpp): dependencies on construction order are a nice way of shooting
353 // yourself in the foot. Fix this. 351 // yourself in the foot. Fix this.
354 AssemblerBuffer Buffer; 352 AssemblerBuffer Buffer;
355 }; 353 };
356 354
355 void Label::linkTo(const Assembler &Asm, intptr_t position) {
Jim Stichnoth 2015/12/08 22:20:00 I think this should be moved into the .cpp file.
Karl 2015/12/08 22:39:32 Done.
356 if (Asm.getPreliminary() || Asm.needsTextFixup())
Jim Stichnoth 2015/12/08 22:20:00 I think it's important to leave some documentation
Karl 2015/12/08 22:39:32 Done.
357 return;
358 assert(!isBound());
359 Position = position + kWordSize;
360 assert(isLinked());
361 }
362
357 } // end of namespace Ice 363 } // end of namespace Ice
358 364
359 #endif // SUBZERO_SRC_ICEASSEMBLER_H_ 365 #endif // SUBZERO_SRC_ICEASSEMBLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698