src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.asm/src/org/graalvm/compiler/asm/Label.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
23 |
23 |
24 |
24 |
25 package org.graalvm.compiler.asm; |
25 package org.graalvm.compiler.asm; |
26 |
26 |
27 import java.util.ArrayList; |
27 import java.util.ArrayList; |
|
28 |
|
29 import org.graalvm.compiler.debug.GraalError; |
28 |
30 |
29 /** |
31 /** |
30 * This class represents a label within assembly code. |
32 * This class represents a label within assembly code. |
31 */ |
33 */ |
32 public final class Label { |
34 public final class Label { |
69 /** |
71 /** |
70 * Binds the label to {@code pos} and patches all instructions added by |
72 * Binds the label to {@code pos} and patches all instructions added by |
71 * {@link #addPatchAt(int, Assembler)}. |
73 * {@link #addPatchAt(int, Assembler)}. |
72 */ |
74 */ |
73 protected void bind(int pos, Assembler asm) { |
75 protected void bind(int pos, Assembler asm) { |
74 assert pos >= 0; |
76 if (pos < 0) { |
|
77 throw new GraalError("Cannot bind label to negative position %d", pos); |
|
78 } |
75 this.position = pos; |
79 this.position = pos; |
76 if (patchPositions != null) { |
80 if (patchPositions != null) { |
77 for (int i = 0; i < patchPositions.size(); ++i) { |
81 for (int i = 0; i < patchPositions.size(); ++i) { |
78 asm.patchJumpTarget(patchPositions.get(i), position); |
82 asm.patchJumpTarget(patchPositions.get(i), position); |
79 } |
83 } |