/* * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
StackMapTable::StackMapTable(StackMapReader* reader, StackMapFrame* init_frame,
u2 max_locals, u2 max_stack, char* code_data, int code_len, TRAPS) {
_code_length = code_len;
_frame_count = reader->get_frame_count(); if (_frame_count > 0) {
_frame_array = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD,
StackMapFrame*, _frame_count);
StackMapFrame* pre_frame = init_frame; for (int32_t i = 0; i < _frame_count; i++) {
StackMapFrame* frame = reader->next(
pre_frame, i == 0, max_locals, max_stack,
CHECK_VERIFY(pre_frame->verifier()));
_frame_array[i] = frame; int offset = frame->offset(); if (offset >= code_len || code_data[offset] == 0) {
frame->verifier()->verify_error(
ErrorContext::bad_stackmap(i, frame), "StackMapTable error: bad offset"); return;
}
pre_frame = frame;
}
}
reader->check_end(CHECK);
}
// This method is only called by method in StackMapTable. int StackMapTable::get_index_from_offset(int32_t offset) const { int i = 0; for (; i < _frame_count; i++) { if (_frame_array[i]->offset() == offset) { return i;
}
} return i; // frame with offset doesn't exist in the array
}
// Match and/or update current_frame to the frame in stackmap table with // specified offset and frame index. Return true if the two frames match. // // The values of match and update are: _match__update // // checking a branch target: true false // checking an exception handler: true false // linear bytecode verification following an // unconditional branch: false true // linear bytecode verification not following an // unconditional branch: true true bool StackMapTable::match_stackmap(
StackMapFrame* frame, int32_t target, int32_t frame_index, bool match, bool update, ErrorContext* ctx, TRAPS) const { if (frame_index < 0 || frame_index >= _frame_count) {
*ctx = ErrorContext::missing_stackmap(frame->offset());
frame->verifier()->verify_error(
*ctx, "Expecting a stackmap frame at branch target %d", target); returnfalse;
}
StackMapFrame *stackmap_frame = _frame_array[frame_index]; bool result = true; if (match) { // Has direct control flow from last instruction, need to match the two // frames.
result = frame->is_assignable_to(stackmap_frame,
ctx, CHECK_VERIFY_(frame->verifier(), result));
} if (update) { // Use the frame in stackmap table as current frame int lsize = stackmap_frame->locals_size(); int ssize = stackmap_frame->stack_size(); if (frame->locals_size() > lsize || frame->stack_size() > ssize) { // Make sure unused type array items are all _bogus_type.
frame->reset();
}
frame->set_locals_size(lsize);
frame->copy_locals(stackmap_frame);
frame->set_stack_size(ssize);
frame->copy_stack(stackmap_frame);
frame->set_flags(stackmap_frame->flags());
} return result;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.