repo_name
stringclasses 6
values | pr_number
int64 512
78.9k
| pr_title
stringlengths 3
144
| pr_description
stringlengths 0
30.3k
| author
stringlengths 2
21
| date_created
timestamp[ns, tz=UTC] | date_merged
timestamp[ns, tz=UTC] | previous_commit
stringlengths 40
40
| pr_commit
stringlengths 40
40
| query
stringlengths 17
30.4k
| filepath
stringlengths 9
210
| before_content
stringlengths 0
112M
| after_content
stringlengths 0
112M
| label
int64 -1
1
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/riscv/Lapply_reg_state.c | #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gapply_reg_state.c"
#endif
| #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gapply_reg_state.c"
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/dwarf/Gparser.c | /* libunwind - a platform-independent unwind library
Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P.
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "dwarf_i.h"
#include "libunwind_i.h"
#include <stddef.h>
#include <limits.h>
#define alloc_reg_state() (mempool_alloc (&dwarf_reg_state_pool))
#define free_reg_state(rs) (mempool_free (&dwarf_reg_state_pool, rs))
#define DWARF_UNW_CACHE_SIZE(log_size) (1 << log_size)
#define DWARF_UNW_HASH_SIZE(log_size) (1 << (log_size + 1))
static inline int
read_regnum (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
unw_word_t *valp, void *arg)
{
int ret;
if ((ret = dwarf_read_uleb128 (as, a, addr, valp, arg)) < 0)
return ret;
if (*valp >= DWARF_NUM_PRESERVED_REGS)
{
Debug (1, "Invalid register number %u\n", (unsigned int) *valp);
return -UNW_EBADREG;
}
return 0;
}
static inline void
set_reg (dwarf_state_record_t *sr, unw_word_t regnum, dwarf_where_t where,
unw_word_t val)
{
sr->rs_current.reg.where[regnum] = where;
sr->rs_current.reg.val[regnum] = val;
}
static inline int
push_rstate_stack(dwarf_stackable_reg_state_t **rs_stack)
{
dwarf_stackable_reg_state_t *old_rs = *rs_stack;
if (NULL == (*rs_stack = alloc_reg_state ()))
{
*rs_stack = old_rs;
return -1;
}
(*rs_stack)->next = old_rs;
return 0;
}
static inline void
pop_rstate_stack(dwarf_stackable_reg_state_t **rs_stack)
{
dwarf_stackable_reg_state_t *old_rs = *rs_stack;
*rs_stack = old_rs->next;
free_reg_state (old_rs);
}
static inline void
empty_rstate_stack(dwarf_stackable_reg_state_t **rs_stack)
{
while (*rs_stack)
pop_rstate_stack(rs_stack);
}
/* Run a CFI program to update the register state. */
static int
run_cfi_program (struct dwarf_cursor *c, dwarf_state_record_t *sr,
unw_word_t *ip, unw_word_t end_ip,
unw_word_t *addr, unw_word_t end_addr,
dwarf_stackable_reg_state_t **rs_stack,
struct dwarf_cie_info *dci)
{
unw_addr_space_t as;
void *arg;
if (c->pi.flags & UNW_PI_FLAG_DEBUG_FRAME)
{
/* .debug_frame CFI is stored in local address space. */
as = unw_local_addr_space;
arg = NULL;
}
else
{
as = c->as;
arg = c->as_arg;
}
unw_accessors_t *a = unw_get_accessors_int (as);
int ret = 0;
while (*ip <= end_ip && *addr < end_addr && ret >= 0)
{
unw_word_t operand = 0, regnum, val, len;
uint8_t u8, op;
uint16_t u16;
uint32_t u32;
if ((ret = dwarf_readu8 (as, a, addr, &op, arg)) < 0)
break;
if (op & DWARF_CFA_OPCODE_MASK)
{
operand = op & DWARF_CFA_OPERAND_MASK;
op &= ~DWARF_CFA_OPERAND_MASK;
}
switch ((dwarf_cfa_t) op)
{
case DW_CFA_advance_loc:
*ip += operand * dci->code_align;
Debug (15, "CFA_advance_loc to 0x%lx\n", (long) *ip);
break;
case DW_CFA_advance_loc1:
if ((ret = dwarf_readu8 (as, a, addr, &u8, arg)) < 0)
break;
*ip += u8 * dci->code_align;
Debug (15, "CFA_advance_loc1 to 0x%lx\n", (long) *ip);
break;
case DW_CFA_advance_loc2:
if ((ret = dwarf_readu16 (as, a, addr, &u16, arg)) < 0)
break;
*ip += u16 * dci->code_align;
Debug (15, "CFA_advance_loc2 to 0x%lx\n", (long) *ip);
break;
case DW_CFA_advance_loc4:
if ((ret = dwarf_readu32 (as, a, addr, &u32, arg)) < 0)
break;
*ip += u32 * dci->code_align;
Debug (15, "CFA_advance_loc4 to 0x%lx\n", (long) *ip);
break;
case DW_CFA_MIPS_advance_loc8:
#ifdef UNW_TARGET_MIPS
{
uint64_t u64 = 0;
if ((ret = dwarf_readu64 (as, a, addr, &u64, arg)) < 0)
break;
*ip += u64 * dci->code_align;
Debug (15, "CFA_MIPS_advance_loc8\n");
break;
}
#else
Debug (1, "DW_CFA_MIPS_advance_loc8 on non-MIPS target\n");
ret = -UNW_EINVAL;
break;
#endif
case DW_CFA_offset:
regnum = operand;
if (regnum >= DWARF_NUM_PRESERVED_REGS)
{
Debug (1, "Invalid register number %u in DW_cfa_OFFSET\n",
(unsigned int) regnum);
ret = -UNW_EBADREG;
break;
}
if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0)
break;
set_reg (sr, regnum, DWARF_WHERE_CFAREL, val * dci->data_align);
Debug (15, "CFA_offset r%lu at cfa+0x%lx\n",
(long) regnum, (long) (val * dci->data_align));
break;
case DW_CFA_offset_extended:
if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
|| ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0))
break;
set_reg (sr, regnum, DWARF_WHERE_CFAREL, val * dci->data_align);
Debug (15, "CFA_offset_extended r%lu at cf+0x%lx\n",
(long) regnum, (long) (val * dci->data_align));
break;
case DW_CFA_offset_extended_sf:
if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
|| ((ret = dwarf_read_sleb128 (as, a, addr, &val, arg)) < 0))
break;
set_reg (sr, regnum, DWARF_WHERE_CFAREL, val * dci->data_align);
Debug (15, "CFA_offset_extended_sf r%lu at cf+0x%lx\n",
(long) regnum, (long) (val * dci->data_align));
break;
case DW_CFA_restore:
regnum = operand;
if (regnum >= DWARF_NUM_PRESERVED_REGS)
{
Debug (1, "Invalid register number %u in DW_CFA_restore\n",
(unsigned int) regnum);
ret = -UNW_EINVAL;
break;
}
sr->rs_current.reg.where[regnum] = sr->rs_initial.reg.where[regnum];
sr->rs_current.reg.val[regnum] = sr->rs_initial.reg.val[regnum];
Debug (15, "CFA_restore r%lu\n", (long) regnum);
break;
case DW_CFA_restore_extended:
if ((ret = dwarf_read_uleb128 (as, a, addr, ®num, arg)) < 0)
break;
if (regnum >= DWARF_NUM_PRESERVED_REGS)
{
Debug (1, "Invalid register number %u in "
"DW_CFA_restore_extended\n", (unsigned int) regnum);
ret = -UNW_EINVAL;
break;
}
sr->rs_current.reg.where[regnum] = sr->rs_initial.reg.where[regnum];
sr->rs_current.reg.val[regnum] = sr->rs_initial.reg.val[regnum];
Debug (15, "CFA_restore_extended r%lu\n", (long) regnum);
break;
case DW_CFA_nop:
break;
case DW_CFA_set_loc:
if ((ret = dwarf_read_encoded_pointer (as, a, addr, dci->fde_encoding,
&c->pi, ip,
arg)) < 0)
break;
Debug (15, "CFA_set_loc to 0x%lx\n", (long) *ip);
break;
case DW_CFA_undefined:
if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
break;
set_reg (sr, regnum, DWARF_WHERE_UNDEF, 0);
Debug (15, "CFA_undefined r%lu\n", (long) regnum);
break;
case DW_CFA_same_value:
if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
break;
set_reg (sr, regnum, DWARF_WHERE_SAME, 0);
Debug (15, "CFA_same_value r%lu\n", (long) regnum);
break;
case DW_CFA_register:
if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
|| ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0))
break;
set_reg (sr, regnum, DWARF_WHERE_REG, val);
Debug (15, "CFA_register r%lu to r%lu\n", (long) regnum, (long) val);
break;
case DW_CFA_remember_state:
if (push_rstate_stack(rs_stack) < 0)
{
Debug (1, "Out of memory in DW_CFA_remember_state\n");
ret = -UNW_ENOMEM;
break;
}
(*rs_stack)->state = sr->rs_current;
Debug (15, "CFA_remember_state\n");
break;
case DW_CFA_restore_state:
if (!*rs_stack)
{
Debug (1, "register-state stack underflow\n");
ret = -UNW_EINVAL;
break;
}
sr->rs_current = (*rs_stack)->state;
pop_rstate_stack(rs_stack);
Debug (15, "CFA_restore_state\n");
break;
case DW_CFA_def_cfa:
if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
|| ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0))
break;
set_reg (sr, DWARF_CFA_REG_COLUMN, DWARF_WHERE_REG, regnum);
set_reg (sr, DWARF_CFA_OFF_COLUMN, 0, val); /* NOT factored! */
Debug (15, "CFA_def_cfa r%lu+0x%lx\n", (long) regnum, (long) val);
break;
case DW_CFA_def_cfa_sf:
if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
|| ((ret = dwarf_read_sleb128 (as, a, addr, &val, arg)) < 0))
break;
set_reg (sr, DWARF_CFA_REG_COLUMN, DWARF_WHERE_REG, regnum);
set_reg (sr, DWARF_CFA_OFF_COLUMN, 0,
val * dci->data_align); /* factored! */
Debug (15, "CFA_def_cfa_sf r%lu+0x%lx\n",
(long) regnum, (long) (val * dci->data_align));
break;
case DW_CFA_def_cfa_register:
if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
break;
set_reg (sr, DWARF_CFA_REG_COLUMN, DWARF_WHERE_REG, regnum);
Debug (15, "CFA_def_cfa_register r%lu\n", (long) regnum);
break;
case DW_CFA_def_cfa_offset:
if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0)
break;
set_reg (sr, DWARF_CFA_OFF_COLUMN, 0, val); /* NOT factored! */
Debug (15, "CFA_def_cfa_offset 0x%lx\n", (long) val);
break;
case DW_CFA_def_cfa_offset_sf:
if ((ret = dwarf_read_sleb128 (as, a, addr, &val, arg)) < 0)
break;
set_reg (sr, DWARF_CFA_OFF_COLUMN, 0,
val * dci->data_align); /* factored! */
Debug (15, "CFA_def_cfa_offset_sf 0x%lx\n",
(long) (val * dci->data_align));
break;
case DW_CFA_def_cfa_expression:
/* Save the address of the DW_FORM_block for later evaluation. */
set_reg (sr, DWARF_CFA_REG_COLUMN, DWARF_WHERE_EXPR, *addr);
if ((ret = dwarf_read_uleb128 (as, a, addr, &len, arg)) < 0)
break;
Debug (15, "CFA_def_cfa_expr @ 0x%lx [%lu bytes]\n",
(long) *addr, (long) len);
*addr += len;
break;
case DW_CFA_expression:
if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
break;
/* Save the address of the DW_FORM_block for later evaluation. */
set_reg (sr, regnum, DWARF_WHERE_EXPR, *addr);
if ((ret = dwarf_read_uleb128 (as, a, addr, &len, arg)) < 0)
break;
Debug (15, "CFA_expression r%lu @ 0x%lx [%lu bytes]\n",
(long) regnum, (long) addr, (long) len);
*addr += len;
break;
case DW_CFA_val_expression:
if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
break;
/* Save the address of the DW_FORM_block for later evaluation. */
set_reg (sr, regnum, DWARF_WHERE_VAL_EXPR, *addr);
if ((ret = dwarf_read_uleb128 (as, a, addr, &len, arg)) < 0)
break;
Debug (15, "CFA_val_expression r%lu @ 0x%lx [%lu bytes]\n",
(long) regnum, (long) addr, (long) len);
*addr += len;
break;
case DW_CFA_GNU_args_size:
if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0)
break;
sr->args_size = val;
Debug (15, "CFA_GNU_args_size %lu\n", (long) val);
break;
case DW_CFA_GNU_negative_offset_extended:
/* A comment in GCC says that this is obsoleted by
DW_CFA_offset_extended_sf, but that it's used by older
PowerPC code. */
if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
|| ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0))
break;
set_reg (sr, regnum, DWARF_WHERE_CFAREL, -(val * dci->data_align));
Debug (15, "CFA_GNU_negative_offset_extended cfa+0x%lx\n",
(long) -(val * dci->data_align));
break;
case DW_CFA_GNU_window_save:
#ifdef UNW_TARGET_SPARC
/* This is a special CFA to handle all 16 windowed registers
on SPARC. */
for (regnum = 16; regnum < 32; ++regnum)
set_reg (sr, regnum, DWARF_WHERE_CFAREL,
(regnum - 16) * sizeof (unw_word_t));
Debug (15, "CFA_GNU_window_save\n");
break;
#else
/* FALL THROUGH */
#endif
case DW_CFA_lo_user:
case DW_CFA_hi_user:
Debug (1, "Unexpected CFA opcode 0x%x\n", op);
ret = -UNW_EINVAL;
break;
}
}
if (ret > 0)
ret = 0;
return ret;
}
static int
fetch_proc_info (struct dwarf_cursor *c, unw_word_t ip)
{
int ret, dynamic = 1;
/* The 'ip' can point either to the previous or next instruction
depending on what type of frame we have: normal call or a place
to resume execution (e.g. after signal frame).
For a normal call frame we need to back up so we point within the
call itself; this is important because a) the call might be the
very last instruction of the function and the edge of the FDE,
and b) so that run_cfi_program() runs locations up to the call
but not more.
For signal frame, we need to do the exact opposite and look
up using the current 'ip' value. That is where execution will
continue, and it's important we get this right, as 'ip' could be
right at the function entry and hence FDE edge, or at instruction
that manipulates CFA (push/pop). */
if (c->use_prev_instr)
{
#if defined(__arm__)
/* On arm, the least bit denotes thumb/arm mode, clear it. */
ip &= ~(unw_word_t)0x1;
#endif
--ip;
}
memset (&c->pi, 0, sizeof (c->pi));
/* check dynamic info first --- it overrides everything else */
ret = unwi_find_dynamic_proc_info (c->as, ip, &c->pi, 1,
c->as_arg);
if (ret == -UNW_ENOINFO)
{
dynamic = 0;
if ((ret = tdep_find_proc_info (c, ip, 1)) < 0)
return ret;
}
if (c->pi.format != UNW_INFO_FORMAT_DYNAMIC
&& c->pi.format != UNW_INFO_FORMAT_TABLE
&& c->pi.format != UNW_INFO_FORMAT_REMOTE_TABLE)
return -UNW_ENOINFO;
c->pi_valid = 1;
c->pi_is_dynamic = dynamic;
/* Let system/machine-dependent code determine frame-specific attributes. */
if (ret >= 0)
tdep_fetch_frame (c, ip, 1);
return ret;
}
static int
parse_dynamic (struct dwarf_cursor *c, unw_word_t ip, dwarf_state_record_t *sr)
{
Debug (1, "Not yet implemented\n");
return -UNW_ENOINFO;
}
static inline void
put_unwind_info (struct dwarf_cursor *c, unw_proc_info_t *pi)
{
if (c->pi_is_dynamic)
unwi_put_dynamic_unwind_info (c->as, pi, c->as_arg);
else if (pi->unwind_info && pi->format == UNW_INFO_FORMAT_TABLE)
{
mempool_free (&dwarf_cie_info_pool, pi->unwind_info);
pi->unwind_info = NULL;
}
c->pi_valid = 0;
}
static inline int
setup_fde (struct dwarf_cursor *c, dwarf_state_record_t *sr)
{
int i, ret;
assert (c->pi_valid);
memset (sr, 0, sizeof (*sr));
for (i = 0; i < DWARF_NUM_PRESERVED_REGS + 2; ++i)
set_reg (sr, i, DWARF_WHERE_SAME, 0);
struct dwarf_cie_info *dci = c->pi.unwind_info;
sr->rs_current.ret_addr_column = dci->ret_addr_column;
unw_word_t addr = dci->cie_instr_start;
unw_word_t curr_ip = 0;
dwarf_stackable_reg_state_t *rs_stack = NULL;
ret = run_cfi_program (c, sr, &curr_ip, ~(unw_word_t) 0, &addr,
dci->cie_instr_end,
&rs_stack, dci);
empty_rstate_stack(&rs_stack);
if (ret < 0)
return ret;
memcpy (&sr->rs_initial, &sr->rs_current, sizeof (sr->rs_initial));
return 0;
}
static inline int
parse_fde (struct dwarf_cursor *c, unw_word_t ip, dwarf_state_record_t *sr)
{
int ret;
struct dwarf_cie_info *dci = c->pi.unwind_info;
unw_word_t addr = dci->fde_instr_start;
unw_word_t curr_ip = c->pi.start_ip;
dwarf_stackable_reg_state_t *rs_stack = NULL;
/* Process up to current `ip` for signal frame and `ip - 1` for normal call frame
See `c->use_prev_instr` use in `fetch_proc_info` for details. */
ret = run_cfi_program (c, sr, &curr_ip, ip - c->use_prev_instr, &addr, dci->fde_instr_end,
&rs_stack, dci);
empty_rstate_stack(&rs_stack);
if (ret < 0)
return ret;
return 0;
}
HIDDEN int
dwarf_flush_rs_cache (struct dwarf_rs_cache *cache)
{
int i;
if (cache->log_size == DWARF_DEFAULT_LOG_UNW_CACHE_SIZE
|| !cache->hash) {
cache->hash = cache->default_hash;
cache->buckets = cache->default_buckets;
cache->links = cache->default_links;
cache->log_size = DWARF_DEFAULT_LOG_UNW_CACHE_SIZE;
} else {
if (cache->hash && cache->hash != cache->default_hash)
munmap(cache->hash, DWARF_UNW_HASH_SIZE(cache->prev_log_size)
* sizeof (cache->hash[0]));
if (cache->buckets && cache->buckets != cache->default_buckets)
munmap(cache->buckets, DWARF_UNW_CACHE_SIZE(cache->prev_log_size)
* sizeof (cache->buckets[0]));
if (cache->links && cache->links != cache->default_links)
munmap(cache->links, DWARF_UNW_CACHE_SIZE(cache->prev_log_size)
* sizeof (cache->links[0]));
GET_MEMORY(cache->hash, DWARF_UNW_HASH_SIZE(cache->log_size)
* sizeof (cache->hash[0]));
GET_MEMORY(cache->buckets, DWARF_UNW_CACHE_SIZE(cache->log_size)
* sizeof (cache->buckets[0]));
GET_MEMORY(cache->links, DWARF_UNW_CACHE_SIZE(cache->log_size)
* sizeof (cache->links[0]));
if (!cache->hash || !cache->buckets || !cache->links)
{
Debug (1, "Unable to allocate cache memory");
return -UNW_ENOMEM;
}
cache->prev_log_size = cache->log_size;
}
cache->rr_head = 0;
for (i = 0; i < DWARF_UNW_CACHE_SIZE(cache->log_size); ++i)
{
cache->links[i].coll_chain = -1;
cache->links[i].ip = 0;
cache->links[i].valid = 0;
}
for (i = 0; i< DWARF_UNW_HASH_SIZE(cache->log_size); ++i)
cache->hash[i] = -1;
return 0;
}
static inline struct dwarf_rs_cache *
get_rs_cache (unw_addr_space_t as, intrmask_t *saved_maskp)
{
struct dwarf_rs_cache *cache = &as->global_cache;
unw_caching_policy_t caching = as->caching_policy;
if (caching == UNW_CACHE_NONE)
return NULL;
#if defined(HAVE___CACHE_PER_THREAD) && HAVE___CACHE_PER_THREAD
if (likely (caching == UNW_CACHE_PER_THREAD))
{
static _Thread_local struct dwarf_rs_cache tls_cache __attribute__((tls_model("initial-exec")));
Debug (16, "using TLS cache\n");
cache = &tls_cache;
}
else
#else
if (likely (caching == UNW_CACHE_GLOBAL))
#endif
{
Debug (16, "acquiring lock\n");
lock_acquire (&cache->lock, *saved_maskp);
}
if ((atomic_load (&as->cache_generation) != atomic_load (&cache->generation))
|| !cache->hash)
{
/* cache_size is only set in the global_cache, copy it over before flushing */
cache->log_size = as->global_cache.log_size;
if (dwarf_flush_rs_cache (cache) < 0)
return NULL;
atomic_store (&cache->generation, atomic_load (&as->cache_generation));
}
return cache;
}
static inline void
put_rs_cache (unw_addr_space_t as, struct dwarf_rs_cache *cache,
intrmask_t *saved_maskp)
{
assert (as->caching_policy != UNW_CACHE_NONE);
Debug (16, "unmasking signals/interrupts and releasing lock\n");
if (likely (as->caching_policy == UNW_CACHE_GLOBAL))
lock_release (&cache->lock, *saved_maskp);
}
static inline unw_hash_index_t CONST_ATTR
hash (unw_word_t ip, unsigned short log_size)
{
/* based on (sqrt(5)/2-1)*2^64 */
# define magic ((unw_word_t) 0x9e3779b97f4a7c16ULL)
return ip * magic >> ((sizeof(unw_word_t) * 8) - (log_size + 1));
}
static inline long
cache_match (struct dwarf_rs_cache *cache, unsigned short index, unw_word_t ip)
{
return (cache->links[index].valid && (ip == cache->links[index].ip));
}
static dwarf_reg_state_t *
rs_lookup (struct dwarf_rs_cache *cache, struct dwarf_cursor *c)
{
unsigned short index;
unw_word_t ip = c->ip;
if (c->hint > 0)
{
index = c->hint - 1;
if (cache_match (cache, index, ip))
return &cache->buckets[index];
}
for (index = cache->hash[hash (ip, cache->log_size)];
index < DWARF_UNW_CACHE_SIZE(cache->log_size);
index = cache->links[index].coll_chain)
{
if (cache_match (cache, index, ip))
return &cache->buckets[index];
}
return NULL;
}
static inline dwarf_reg_state_t *
rs_new (struct dwarf_rs_cache *cache, struct dwarf_cursor * c)
{
unw_hash_index_t index;
unsigned short head;
head = cache->rr_head;
cache->rr_head = (head + 1) & (DWARF_UNW_CACHE_SIZE(cache->log_size) - 1);
/* remove the old rs from the hash table (if it's there): */
if (cache->links[head].ip)
{
unsigned short *pindex;
for (pindex = &cache->hash[hash (cache->links[head].ip, cache->log_size)];
*pindex < DWARF_UNW_CACHE_SIZE(cache->log_size);
pindex = &cache->links[*pindex].coll_chain)
{
if (*pindex == head)
{
*pindex = cache->links[*pindex].coll_chain;
break;
}
}
}
/* enter new rs in the hash table */
index = hash (c->ip, cache->log_size);
cache->links[head].coll_chain = cache->hash[index];
cache->hash[index] = head;
cache->links[head].ip = c->ip;
cache->links[head].valid = 1;
cache->links[head].signal_frame = tdep_cache_frame(c);
return cache->buckets + head;
}
static int
create_state_record_for (struct dwarf_cursor *c, dwarf_state_record_t *sr,
unw_word_t ip)
{
int ret;
switch (c->pi.format)
{
case UNW_INFO_FORMAT_TABLE:
case UNW_INFO_FORMAT_REMOTE_TABLE:
if ((ret = setup_fde(c, sr)) < 0)
return ret;
ret = parse_fde (c, ip, sr);
break;
case UNW_INFO_FORMAT_DYNAMIC:
ret = parse_dynamic (c, ip, sr);
break;
default:
Debug (1, "Unexpected unwind-info format %d\n", c->pi.format);
ret = -UNW_EINVAL;
}
return ret;
}
static inline int
eval_location_expr (struct dwarf_cursor *c, unw_word_t stack_val, unw_addr_space_t as,
unw_accessors_t *a, unw_word_t addr,
dwarf_loc_t *locp, void *arg)
{
int ret, is_register;
unw_word_t len, val;
/* read the length of the expression: */
if ((ret = dwarf_read_uleb128 (as, a, &addr, &len, arg)) < 0)
return ret;
/* evaluate the expression: */
if ((ret = dwarf_eval_expr (c, stack_val, &addr, len, &val, &is_register)) < 0)
return ret;
if (is_register)
*locp = DWARF_REG_LOC (c, dwarf_to_unw_regnum (val));
else
*locp = DWARF_MEM_LOC (c, val);
return 0;
}
static int
apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs)
{
unw_word_t regnum, addr, cfa, ip;
unw_word_t prev_ip, prev_cfa;
unw_addr_space_t as;
dwarf_loc_t cfa_loc;
unw_accessors_t *a;
int i, ret;
void *arg;
prev_ip = c->ip;
prev_cfa = c->cfa;
as = c->as;
arg = c->as_arg;
a = unw_get_accessors_int (as);
/* Evaluate the CFA first, because it may be referred to by other
expressions. */
if (rs->reg.where[DWARF_CFA_REG_COLUMN] == DWARF_WHERE_REG)
{
/* CFA is equal to [reg] + offset: */
/* As a special-case, if the stack-pointer is the CFA and the
stack-pointer wasn't saved, popping the CFA implicitly pops
the stack-pointer as well. */
if ((rs->reg.val[DWARF_CFA_REG_COLUMN] == UNW_TDEP_SP)
&& (UNW_TDEP_SP < ARRAY_SIZE(rs->reg.val))
&& (rs->reg.where[UNW_TDEP_SP] == DWARF_WHERE_SAME))
cfa = c->cfa;
else
{
regnum = dwarf_to_unw_regnum (rs->reg.val[DWARF_CFA_REG_COLUMN]);
if ((ret = unw_get_reg ((unw_cursor_t *) c, regnum, &cfa)) < 0)
return ret;
}
cfa += rs->reg.val[DWARF_CFA_OFF_COLUMN];
}
else
{
/* CFA is equal to EXPR: */
assert (rs->reg.where[DWARF_CFA_REG_COLUMN] == DWARF_WHERE_EXPR);
addr = rs->reg.val[DWARF_CFA_REG_COLUMN];
/* The dwarf standard doesn't specify an initial value to be pushed on */
/* the stack before DW_CFA_def_cfa_expression evaluation. We push on a */
/* dummy value (0) to keep the eval_location_expr function consistent. */
if ((ret = eval_location_expr (c, 0, as, a, addr, &cfa_loc, arg)) < 0)
return ret;
/* the returned location better be a memory location... */
if (DWARF_IS_REG_LOC (cfa_loc))
return -UNW_EBADFRAME;
cfa = DWARF_GET_LOC (cfa_loc);
}
dwarf_loc_t new_loc[DWARF_NUM_PRESERVED_REGS];
memcpy(new_loc, c->loc, sizeof(new_loc));
for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i)
{
switch ((dwarf_where_t) rs->reg.where[i])
{
case DWARF_WHERE_UNDEF:
new_loc[i] = DWARF_NULL_LOC;
break;
case DWARF_WHERE_SAME:
break;
case DWARF_WHERE_CFAREL:
new_loc[i] = DWARF_MEM_LOC (c, cfa + rs->reg.val[i]);
break;
case DWARF_WHERE_REG:
#ifdef __s390x__
/* GPRs can be saved in FPRs on s390x */
if (unw_is_fpreg (dwarf_to_unw_regnum (rs->reg.val[i])))
{
new_loc[i] = DWARF_FPREG_LOC (c, dwarf_to_unw_regnum (rs->reg.val[i]));
break;
}
#endif
new_loc[i] = new_loc[rs->reg.val[i]];
break;
case DWARF_WHERE_EXPR:
addr = rs->reg.val[i];
/* The dwarf standard requires the current CFA to be pushed on the */
/* stack before DW_CFA_expression evaluation. */
if ((ret = eval_location_expr (c, cfa, as, a, addr, new_loc + i, arg)) < 0)
return ret;
break;
case DWARF_WHERE_VAL_EXPR:
addr = rs->reg.val[i];
/* The dwarf standard requires the current CFA to be pushed on the */
/* stack before DW_CFA_val_expression evaluation. */
if ((ret = eval_location_expr (c, cfa, as, a, addr, new_loc + i, arg)) < 0)
return ret;
new_loc[i] = DWARF_VAL_LOC (c, DWARF_GET_LOC (new_loc[i]));
break;
}
}
memcpy(c->loc, new_loc, sizeof(new_loc));
c->cfa = cfa;
/* DWARF spec says undefined return address location means end of stack. */
if (DWARF_IS_NULL_LOC (c->loc[rs->ret_addr_column]))
{
c->ip = 0;
ret = 0;
}
else
{
ret = dwarf_get (c, c->loc[rs->ret_addr_column], &ip);
if (ret < 0)
return ret;
c->ip = ip;
ret = 1;
}
/* XXX: check for ip to be code_aligned */
if (c->ip == prev_ip && c->cfa == prev_cfa)
{
Dprintf ("%s: ip and cfa unchanged; stopping here (ip=0x%lx)\n",
__FUNCTION__, (long) c->ip);
return -UNW_EBADFRAME;
}
if (c->stash_frames)
tdep_stash_frame (c, rs);
return ret;
}
/* Find the saved locations. */
static int
find_reg_state (struct dwarf_cursor *c, dwarf_state_record_t *sr)
{
dwarf_reg_state_t *rs;
struct dwarf_rs_cache *cache;
int ret = 0;
intrmask_t saved_mask;
if ((cache = get_rs_cache(c->as, &saved_mask)) &&
(rs = rs_lookup(cache, c)))
{
/* update hint; no locking needed: single-word writes are atomic */
unsigned short index = rs - cache->buckets;
c->use_prev_instr = ! cache->links[index].signal_frame;
memcpy (&sr->rs_current, rs, sizeof (*rs));
}
else
{
ret = fetch_proc_info (c, c->ip);
int next_use_prev_instr = c->use_prev_instr;
if (ret >= 0)
{
/* Update use_prev_instr for the next frame. */
assert(c->pi.unwind_info);
struct dwarf_cie_info *dci = c->pi.unwind_info;
next_use_prev_instr = ! dci->signal_frame;
ret = create_state_record_for (c, sr, c->ip);
}
put_unwind_info (c, &c->pi);
c->use_prev_instr = next_use_prev_instr;
if (cache && ret >= 0)
{
rs = rs_new (cache, c);
cache->links[rs - cache->buckets].hint = 0;
memcpy(rs, &sr->rs_current, sizeof(*rs));
}
}
unsigned short index = -1;
if (cache)
{
if (rs)
{
index = rs - cache->buckets;
c->hint = cache->links[index].hint;
cache->links[c->prev_rs].hint = index + 1;
c->prev_rs = index;
}
put_rs_cache (c->as, cache, &saved_mask);
}
if (ret < 0)
return ret;
if (cache)
tdep_reuse_frame (c, cache->links[index].signal_frame);
return 0;
}
/* The function finds the saved locations and applies the register
state as well. */
HIDDEN int
dwarf_step (struct dwarf_cursor *c)
{
int ret;
dwarf_state_record_t sr;
if ((ret = find_reg_state (c, &sr)) < 0)
return ret;
return apply_reg_state (c, &sr.rs_current);
}
HIDDEN int
dwarf_make_proc_info (struct dwarf_cursor *c)
{
#if 0
if (c->as->caching_policy == UNW_CACHE_NONE
|| get_cached_proc_info (c) < 0)
#endif
/* Need to check if current frame contains
args_size, and set cursor appropriately. Only
needed for unw_resume */
dwarf_state_record_t sr;
int ret;
/* Lookup it up the slow way... */
ret = fetch_proc_info (c, c->ip);
if (ret >= 0)
ret = create_state_record_for (c, &sr, c->ip);
put_unwind_info (c, &c->pi);
if (ret < 0)
return ret;
c->args_size = sr.args_size;
return 0;
}
static int
dwarf_reg_states_dynamic_iterate(struct dwarf_cursor *c,
unw_reg_states_callback cb,
void *token)
{
Debug (1, "Not yet implemented\n");
return -UNW_ENOINFO;
}
static int
dwarf_reg_states_table_iterate(struct dwarf_cursor *c,
unw_reg_states_callback cb,
void *token)
{
dwarf_state_record_t sr;
int ret = setup_fde(c, &sr);
struct dwarf_cie_info *dci = c->pi.unwind_info;
unw_word_t addr = dci->fde_instr_start;
unw_word_t curr_ip = c->pi.start_ip;
dwarf_stackable_reg_state_t *rs_stack = NULL;
while (ret >= 0 && curr_ip < c->pi.end_ip && addr < dci->fde_instr_end)
{
unw_word_t prev_ip = curr_ip;
ret = run_cfi_program (c, &sr, &curr_ip, prev_ip, &addr, dci->fde_instr_end,
&rs_stack, dci);
if (ret >= 0 && prev_ip < curr_ip)
ret = cb(token, &sr.rs_current, sizeof(sr.rs_current), prev_ip, curr_ip);
}
empty_rstate_stack(&rs_stack);
#if defined(NEED_LAST_IP)
if (ret >= 0 && curr_ip < c->pi.last_ip)
/* report the dead zone after the procedure ends */
ret = cb(token, &sr.rs_current, sizeof(sr.rs_current), curr_ip, c->pi.last_ip);
#else
if (ret >= 0 && curr_ip < c->pi.end_ip)
/* report for whatever is left before procedure end */
ret = cb(token, &sr.rs_current, sizeof(sr.rs_current), curr_ip, c->pi.end_ip);
#endif
return ret;
}
HIDDEN int
dwarf_reg_states_iterate(struct dwarf_cursor *c,
unw_reg_states_callback cb,
void *token)
{
int ret = fetch_proc_info (c, c->ip);
int next_use_prev_instr = c->use_prev_instr;
if (ret >= 0)
{
/* Update use_prev_instr for the next frame. */
assert(c->pi.unwind_info);
struct dwarf_cie_info *dci = c->pi.unwind_info;
next_use_prev_instr = ! dci->signal_frame;
switch (c->pi.format)
{
case UNW_INFO_FORMAT_TABLE:
case UNW_INFO_FORMAT_REMOTE_TABLE:
ret = dwarf_reg_states_table_iterate(c, cb, token);
break;
case UNW_INFO_FORMAT_DYNAMIC:
ret = dwarf_reg_states_dynamic_iterate (c, cb, token);
break;
default:
Debug (1, "Unexpected unwind-info format %d\n", c->pi.format);
ret = -UNW_EINVAL;
}
}
put_unwind_info (c, &c->pi);
c->use_prev_instr = next_use_prev_instr;
return ret;
}
HIDDEN int
dwarf_apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs)
{
return apply_reg_state(c, rs);
}
| /* libunwind - a platform-independent unwind library
Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P.
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "dwarf_i.h"
#include "libunwind_i.h"
#include <stddef.h>
#include <limits.h>
#define alloc_reg_state() (mempool_alloc (&dwarf_reg_state_pool))
#define free_reg_state(rs) (mempool_free (&dwarf_reg_state_pool, rs))
#define DWARF_UNW_CACHE_SIZE(log_size) (1 << log_size)
#define DWARF_UNW_HASH_SIZE(log_size) (1 << (log_size + 1))
static inline int
read_regnum (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
unw_word_t *valp, void *arg)
{
int ret;
if ((ret = dwarf_read_uleb128 (as, a, addr, valp, arg)) < 0)
return ret;
if (*valp >= DWARF_NUM_PRESERVED_REGS)
{
Debug (1, "Invalid register number %u\n", (unsigned int) *valp);
return -UNW_EBADREG;
}
return 0;
}
static inline void
set_reg (dwarf_state_record_t *sr, unw_word_t regnum, dwarf_where_t where,
unw_word_t val)
{
sr->rs_current.reg.where[regnum] = where;
sr->rs_current.reg.val[regnum] = val;
}
static inline int
push_rstate_stack(dwarf_stackable_reg_state_t **rs_stack)
{
dwarf_stackable_reg_state_t *old_rs = *rs_stack;
if (NULL == (*rs_stack = alloc_reg_state ()))
{
*rs_stack = old_rs;
return -1;
}
(*rs_stack)->next = old_rs;
return 0;
}
static inline void
pop_rstate_stack(dwarf_stackable_reg_state_t **rs_stack)
{
dwarf_stackable_reg_state_t *old_rs = *rs_stack;
*rs_stack = old_rs->next;
free_reg_state (old_rs);
}
static inline void
empty_rstate_stack(dwarf_stackable_reg_state_t **rs_stack)
{
while (*rs_stack)
pop_rstate_stack(rs_stack);
}
/* Run a CFI program to update the register state. */
static int
run_cfi_program (struct dwarf_cursor *c, dwarf_state_record_t *sr,
unw_word_t *ip, unw_word_t end_ip,
unw_word_t *addr, unw_word_t end_addr,
dwarf_stackable_reg_state_t **rs_stack,
struct dwarf_cie_info *dci)
{
unw_addr_space_t as;
void *arg;
if (c->pi.flags & UNW_PI_FLAG_DEBUG_FRAME)
{
/* .debug_frame CFI is stored in local address space. */
as = unw_local_addr_space;
arg = NULL;
}
else
{
as = c->as;
arg = c->as_arg;
}
unw_accessors_t *a = unw_get_accessors_int (as);
int ret = 0;
while (*ip <= end_ip && *addr < end_addr && ret >= 0)
{
unw_word_t operand = 0, regnum, val, len;
uint8_t u8, op;
uint16_t u16;
uint32_t u32;
if ((ret = dwarf_readu8 (as, a, addr, &op, arg)) < 0)
break;
if (op & DWARF_CFA_OPCODE_MASK)
{
operand = op & DWARF_CFA_OPERAND_MASK;
op &= ~DWARF_CFA_OPERAND_MASK;
}
switch ((dwarf_cfa_t) op)
{
case DW_CFA_advance_loc:
*ip += operand * dci->code_align;
Debug (15, "CFA_advance_loc to 0x%lx\n", (long) *ip);
break;
case DW_CFA_advance_loc1:
if ((ret = dwarf_readu8 (as, a, addr, &u8, arg)) < 0)
break;
*ip += u8 * dci->code_align;
Debug (15, "CFA_advance_loc1 to 0x%lx\n", (long) *ip);
break;
case DW_CFA_advance_loc2:
if ((ret = dwarf_readu16 (as, a, addr, &u16, arg)) < 0)
break;
*ip += u16 * dci->code_align;
Debug (15, "CFA_advance_loc2 to 0x%lx\n", (long) *ip);
break;
case DW_CFA_advance_loc4:
if ((ret = dwarf_readu32 (as, a, addr, &u32, arg)) < 0)
break;
*ip += u32 * dci->code_align;
Debug (15, "CFA_advance_loc4 to 0x%lx\n", (long) *ip);
break;
case DW_CFA_MIPS_advance_loc8:
#ifdef UNW_TARGET_MIPS
{
uint64_t u64 = 0;
if ((ret = dwarf_readu64 (as, a, addr, &u64, arg)) < 0)
break;
*ip += u64 * dci->code_align;
Debug (15, "CFA_MIPS_advance_loc8\n");
break;
}
#else
Debug (1, "DW_CFA_MIPS_advance_loc8 on non-MIPS target\n");
ret = -UNW_EINVAL;
break;
#endif
case DW_CFA_offset:
regnum = operand;
if (regnum >= DWARF_NUM_PRESERVED_REGS)
{
Debug (1, "Invalid register number %u in DW_cfa_OFFSET\n",
(unsigned int) regnum);
ret = -UNW_EBADREG;
break;
}
if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0)
break;
set_reg (sr, regnum, DWARF_WHERE_CFAREL, val * dci->data_align);
Debug (15, "CFA_offset r%lu at cfa+0x%lx\n",
(long) regnum, (long) (val * dci->data_align));
break;
case DW_CFA_offset_extended:
if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
|| ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0))
break;
set_reg (sr, regnum, DWARF_WHERE_CFAREL, val * dci->data_align);
Debug (15, "CFA_offset_extended r%lu at cf+0x%lx\n",
(long) regnum, (long) (val * dci->data_align));
break;
case DW_CFA_offset_extended_sf:
if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
|| ((ret = dwarf_read_sleb128 (as, a, addr, &val, arg)) < 0))
break;
set_reg (sr, regnum, DWARF_WHERE_CFAREL, val * dci->data_align);
Debug (15, "CFA_offset_extended_sf r%lu at cf+0x%lx\n",
(long) regnum, (long) (val * dci->data_align));
break;
case DW_CFA_restore:
regnum = operand;
if (regnum >= DWARF_NUM_PRESERVED_REGS)
{
Debug (1, "Invalid register number %u in DW_CFA_restore\n",
(unsigned int) regnum);
ret = -UNW_EINVAL;
break;
}
sr->rs_current.reg.where[regnum] = sr->rs_initial.reg.where[regnum];
sr->rs_current.reg.val[regnum] = sr->rs_initial.reg.val[regnum];
Debug (15, "CFA_restore r%lu\n", (long) regnum);
break;
case DW_CFA_restore_extended:
if ((ret = dwarf_read_uleb128 (as, a, addr, ®num, arg)) < 0)
break;
if (regnum >= DWARF_NUM_PRESERVED_REGS)
{
Debug (1, "Invalid register number %u in "
"DW_CFA_restore_extended\n", (unsigned int) regnum);
ret = -UNW_EINVAL;
break;
}
sr->rs_current.reg.where[regnum] = sr->rs_initial.reg.where[regnum];
sr->rs_current.reg.val[regnum] = sr->rs_initial.reg.val[regnum];
Debug (15, "CFA_restore_extended r%lu\n", (long) regnum);
break;
case DW_CFA_nop:
break;
case DW_CFA_set_loc:
if ((ret = dwarf_read_encoded_pointer (as, a, addr, dci->fde_encoding,
&c->pi, ip,
arg)) < 0)
break;
Debug (15, "CFA_set_loc to 0x%lx\n", (long) *ip);
break;
case DW_CFA_undefined:
if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
break;
set_reg (sr, regnum, DWARF_WHERE_UNDEF, 0);
Debug (15, "CFA_undefined r%lu\n", (long) regnum);
break;
case DW_CFA_same_value:
if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
break;
set_reg (sr, regnum, DWARF_WHERE_SAME, 0);
Debug (15, "CFA_same_value r%lu\n", (long) regnum);
break;
case DW_CFA_register:
if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
|| ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0))
break;
set_reg (sr, regnum, DWARF_WHERE_REG, val);
Debug (15, "CFA_register r%lu to r%lu\n", (long) regnum, (long) val);
break;
case DW_CFA_remember_state:
if (push_rstate_stack(rs_stack) < 0)
{
Debug (1, "Out of memory in DW_CFA_remember_state\n");
ret = -UNW_ENOMEM;
break;
}
(*rs_stack)->state = sr->rs_current;
Debug (15, "CFA_remember_state\n");
break;
case DW_CFA_restore_state:
if (!*rs_stack)
{
Debug (1, "register-state stack underflow\n");
ret = -UNW_EINVAL;
break;
}
sr->rs_current = (*rs_stack)->state;
pop_rstate_stack(rs_stack);
Debug (15, "CFA_restore_state\n");
break;
case DW_CFA_def_cfa:
if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
|| ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0))
break;
set_reg (sr, DWARF_CFA_REG_COLUMN, DWARF_WHERE_REG, regnum);
set_reg (sr, DWARF_CFA_OFF_COLUMN, 0, val); /* NOT factored! */
Debug (15, "CFA_def_cfa r%lu+0x%lx\n", (long) regnum, (long) val);
break;
case DW_CFA_def_cfa_sf:
if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
|| ((ret = dwarf_read_sleb128 (as, a, addr, &val, arg)) < 0))
break;
set_reg (sr, DWARF_CFA_REG_COLUMN, DWARF_WHERE_REG, regnum);
set_reg (sr, DWARF_CFA_OFF_COLUMN, 0,
val * dci->data_align); /* factored! */
Debug (15, "CFA_def_cfa_sf r%lu+0x%lx\n",
(long) regnum, (long) (val * dci->data_align));
break;
case DW_CFA_def_cfa_register:
if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
break;
set_reg (sr, DWARF_CFA_REG_COLUMN, DWARF_WHERE_REG, regnum);
Debug (15, "CFA_def_cfa_register r%lu\n", (long) regnum);
break;
case DW_CFA_def_cfa_offset:
if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0)
break;
set_reg (sr, DWARF_CFA_OFF_COLUMN, 0, val); /* NOT factored! */
Debug (15, "CFA_def_cfa_offset 0x%lx\n", (long) val);
break;
case DW_CFA_def_cfa_offset_sf:
if ((ret = dwarf_read_sleb128 (as, a, addr, &val, arg)) < 0)
break;
set_reg (sr, DWARF_CFA_OFF_COLUMN, 0,
val * dci->data_align); /* factored! */
Debug (15, "CFA_def_cfa_offset_sf 0x%lx\n",
(long) (val * dci->data_align));
break;
case DW_CFA_def_cfa_expression:
/* Save the address of the DW_FORM_block for later evaluation. */
set_reg (sr, DWARF_CFA_REG_COLUMN, DWARF_WHERE_EXPR, *addr);
if ((ret = dwarf_read_uleb128 (as, a, addr, &len, arg)) < 0)
break;
Debug (15, "CFA_def_cfa_expr @ 0x%lx [%lu bytes]\n",
(long) *addr, (long) len);
*addr += len;
break;
case DW_CFA_expression:
if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
break;
/* Save the address of the DW_FORM_block for later evaluation. */
set_reg (sr, regnum, DWARF_WHERE_EXPR, *addr);
if ((ret = dwarf_read_uleb128 (as, a, addr, &len, arg)) < 0)
break;
Debug (15, "CFA_expression r%lu @ 0x%lx [%lu bytes]\n",
(long) regnum, (long) addr, (long) len);
*addr += len;
break;
case DW_CFA_val_expression:
if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
break;
/* Save the address of the DW_FORM_block for later evaluation. */
set_reg (sr, regnum, DWARF_WHERE_VAL_EXPR, *addr);
if ((ret = dwarf_read_uleb128 (as, a, addr, &len, arg)) < 0)
break;
Debug (15, "CFA_val_expression r%lu @ 0x%lx [%lu bytes]\n",
(long) regnum, (long) addr, (long) len);
*addr += len;
break;
case DW_CFA_GNU_args_size:
if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0)
break;
sr->args_size = val;
Debug (15, "CFA_GNU_args_size %lu\n", (long) val);
break;
case DW_CFA_GNU_negative_offset_extended:
/* A comment in GCC says that this is obsoleted by
DW_CFA_offset_extended_sf, but that it's used by older
PowerPC code. */
if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0)
|| ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0))
break;
set_reg (sr, regnum, DWARF_WHERE_CFAREL, -(val * dci->data_align));
Debug (15, "CFA_GNU_negative_offset_extended cfa+0x%lx\n",
(long) -(val * dci->data_align));
break;
case DW_CFA_GNU_window_save:
#ifdef UNW_TARGET_SPARC
/* This is a special CFA to handle all 16 windowed registers
on SPARC. */
for (regnum = 16; regnum < 32; ++regnum)
set_reg (sr, regnum, DWARF_WHERE_CFAREL,
(regnum - 16) * sizeof (unw_word_t));
Debug (15, "CFA_GNU_window_save\n");
break;
#else
/* FALL THROUGH */
#endif
case DW_CFA_lo_user:
case DW_CFA_hi_user:
Debug (1, "Unexpected CFA opcode 0x%x\n", op);
ret = -UNW_EINVAL;
break;
}
}
if (ret > 0)
ret = 0;
return ret;
}
static int
fetch_proc_info (struct dwarf_cursor *c, unw_word_t ip)
{
int ret, dynamic = 1;
/* The 'ip' can point either to the previous or next instruction
depending on what type of frame we have: normal call or a place
to resume execution (e.g. after signal frame).
For a normal call frame we need to back up so we point within the
call itself; this is important because a) the call might be the
very last instruction of the function and the edge of the FDE,
and b) so that run_cfi_program() runs locations up to the call
but not more.
For signal frame, we need to do the exact opposite and look
up using the current 'ip' value. That is where execution will
continue, and it's important we get this right, as 'ip' could be
right at the function entry and hence FDE edge, or at instruction
that manipulates CFA (push/pop). */
if (c->use_prev_instr)
{
#if defined(__arm__)
/* On arm, the least bit denotes thumb/arm mode, clear it. */
ip &= ~(unw_word_t)0x1;
#endif
--ip;
}
memset (&c->pi, 0, sizeof (c->pi));
/* check dynamic info first --- it overrides everything else */
ret = unwi_find_dynamic_proc_info (c->as, ip, &c->pi, 1,
c->as_arg);
if (ret == -UNW_ENOINFO)
{
dynamic = 0;
if ((ret = tdep_find_proc_info (c, ip, 1)) < 0)
return ret;
}
if (c->pi.format != UNW_INFO_FORMAT_DYNAMIC
&& c->pi.format != UNW_INFO_FORMAT_TABLE
&& c->pi.format != UNW_INFO_FORMAT_REMOTE_TABLE)
return -UNW_ENOINFO;
c->pi_valid = 1;
c->pi_is_dynamic = dynamic;
/* Let system/machine-dependent code determine frame-specific attributes. */
if (ret >= 0)
tdep_fetch_frame (c, ip, 1);
return ret;
}
static int
parse_dynamic (struct dwarf_cursor *c, unw_word_t ip, dwarf_state_record_t *sr)
{
Debug (1, "Not yet implemented\n");
return -UNW_ENOINFO;
}
static inline void
put_unwind_info (struct dwarf_cursor *c, unw_proc_info_t *pi)
{
if (c->pi_is_dynamic)
unwi_put_dynamic_unwind_info (c->as, pi, c->as_arg);
else if (pi->unwind_info && pi->format == UNW_INFO_FORMAT_TABLE)
{
mempool_free (&dwarf_cie_info_pool, pi->unwind_info);
pi->unwind_info = NULL;
}
c->pi_valid = 0;
}
static inline int
setup_fde (struct dwarf_cursor *c, dwarf_state_record_t *sr)
{
int i, ret;
assert (c->pi_valid);
memset (sr, 0, sizeof (*sr));
for (i = 0; i < DWARF_NUM_PRESERVED_REGS + 2; ++i)
set_reg (sr, i, DWARF_WHERE_SAME, 0);
struct dwarf_cie_info *dci = c->pi.unwind_info;
sr->rs_current.ret_addr_column = dci->ret_addr_column;
unw_word_t addr = dci->cie_instr_start;
unw_word_t curr_ip = 0;
dwarf_stackable_reg_state_t *rs_stack = NULL;
ret = run_cfi_program (c, sr, &curr_ip, ~(unw_word_t) 0, &addr,
dci->cie_instr_end,
&rs_stack, dci);
empty_rstate_stack(&rs_stack);
if (ret < 0)
return ret;
memcpy (&sr->rs_initial, &sr->rs_current, sizeof (sr->rs_initial));
return 0;
}
static inline int
parse_fde (struct dwarf_cursor *c, unw_word_t ip, dwarf_state_record_t *sr)
{
int ret;
struct dwarf_cie_info *dci = c->pi.unwind_info;
unw_word_t addr = dci->fde_instr_start;
unw_word_t curr_ip = c->pi.start_ip;
dwarf_stackable_reg_state_t *rs_stack = NULL;
/* Process up to current `ip` for signal frame and `ip - 1` for normal call frame
See `c->use_prev_instr` use in `fetch_proc_info` for details. */
ret = run_cfi_program (c, sr, &curr_ip, ip - c->use_prev_instr, &addr, dci->fde_instr_end,
&rs_stack, dci);
empty_rstate_stack(&rs_stack);
if (ret < 0)
return ret;
return 0;
}
HIDDEN int
dwarf_flush_rs_cache (struct dwarf_rs_cache *cache)
{
int i;
if (cache->log_size == DWARF_DEFAULT_LOG_UNW_CACHE_SIZE
|| !cache->hash) {
cache->hash = cache->default_hash;
cache->buckets = cache->default_buckets;
cache->links = cache->default_links;
cache->log_size = DWARF_DEFAULT_LOG_UNW_CACHE_SIZE;
} else {
if (cache->hash && cache->hash != cache->default_hash)
munmap(cache->hash, DWARF_UNW_HASH_SIZE(cache->prev_log_size)
* sizeof (cache->hash[0]));
if (cache->buckets && cache->buckets != cache->default_buckets)
munmap(cache->buckets, DWARF_UNW_CACHE_SIZE(cache->prev_log_size)
* sizeof (cache->buckets[0]));
if (cache->links && cache->links != cache->default_links)
munmap(cache->links, DWARF_UNW_CACHE_SIZE(cache->prev_log_size)
* sizeof (cache->links[0]));
GET_MEMORY(cache->hash, DWARF_UNW_HASH_SIZE(cache->log_size)
* sizeof (cache->hash[0]));
GET_MEMORY(cache->buckets, DWARF_UNW_CACHE_SIZE(cache->log_size)
* sizeof (cache->buckets[0]));
GET_MEMORY(cache->links, DWARF_UNW_CACHE_SIZE(cache->log_size)
* sizeof (cache->links[0]));
if (!cache->hash || !cache->buckets || !cache->links)
{
Debug (1, "Unable to allocate cache memory");
return -UNW_ENOMEM;
}
cache->prev_log_size = cache->log_size;
}
cache->rr_head = 0;
for (i = 0; i < DWARF_UNW_CACHE_SIZE(cache->log_size); ++i)
{
cache->links[i].coll_chain = -1;
cache->links[i].ip = 0;
cache->links[i].valid = 0;
}
for (i = 0; i< DWARF_UNW_HASH_SIZE(cache->log_size); ++i)
cache->hash[i] = -1;
return 0;
}
static inline struct dwarf_rs_cache *
get_rs_cache (unw_addr_space_t as, intrmask_t *saved_maskp)
{
struct dwarf_rs_cache *cache = &as->global_cache;
unw_caching_policy_t caching = as->caching_policy;
if (caching == UNW_CACHE_NONE)
return NULL;
#if defined(HAVE___CACHE_PER_THREAD) && HAVE___CACHE_PER_THREAD
if (likely (caching == UNW_CACHE_PER_THREAD))
{
static _Thread_local struct dwarf_rs_cache tls_cache __attribute__((tls_model("initial-exec")));
Debug (16, "using TLS cache\n");
cache = &tls_cache;
}
else
#else
if (likely (caching == UNW_CACHE_GLOBAL))
#endif
{
Debug (16, "acquiring lock\n");
lock_acquire (&cache->lock, *saved_maskp);
}
if ((atomic_load (&as->cache_generation) != atomic_load (&cache->generation))
|| !cache->hash)
{
/* cache_size is only set in the global_cache, copy it over before flushing */
cache->log_size = as->global_cache.log_size;
if (dwarf_flush_rs_cache (cache) < 0)
return NULL;
atomic_store (&cache->generation, atomic_load (&as->cache_generation));
}
return cache;
}
static inline void
put_rs_cache (unw_addr_space_t as, struct dwarf_rs_cache *cache,
intrmask_t *saved_maskp)
{
assert (as->caching_policy != UNW_CACHE_NONE);
Debug (16, "unmasking signals/interrupts and releasing lock\n");
if (likely (as->caching_policy == UNW_CACHE_GLOBAL))
lock_release (&cache->lock, *saved_maskp);
}
static inline unw_hash_index_t CONST_ATTR
hash (unw_word_t ip, unsigned short log_size)
{
/* based on (sqrt(5)/2-1)*2^64 */
# define magic ((unw_word_t) 0x9e3779b97f4a7c16ULL)
return ip * magic >> ((sizeof(unw_word_t) * 8) - (log_size + 1));
}
static inline long
cache_match (struct dwarf_rs_cache *cache, unsigned short index, unw_word_t ip)
{
return (cache->links[index].valid && (ip == cache->links[index].ip));
}
static dwarf_reg_state_t *
rs_lookup (struct dwarf_rs_cache *cache, struct dwarf_cursor *c)
{
unsigned short index;
unw_word_t ip = c->ip;
if (c->hint > 0)
{
index = c->hint - 1;
if (cache_match (cache, index, ip))
return &cache->buckets[index];
}
for (index = cache->hash[hash (ip, cache->log_size)];
index < DWARF_UNW_CACHE_SIZE(cache->log_size);
index = cache->links[index].coll_chain)
{
if (cache_match (cache, index, ip))
return &cache->buckets[index];
}
return NULL;
}
static inline dwarf_reg_state_t *
rs_new (struct dwarf_rs_cache *cache, struct dwarf_cursor * c)
{
unw_hash_index_t index;
unsigned short head;
head = cache->rr_head;
cache->rr_head = (head + 1) & (DWARF_UNW_CACHE_SIZE(cache->log_size) - 1);
/* remove the old rs from the hash table (if it's there): */
if (cache->links[head].ip)
{
unsigned short *pindex;
for (pindex = &cache->hash[hash (cache->links[head].ip, cache->log_size)];
*pindex < DWARF_UNW_CACHE_SIZE(cache->log_size);
pindex = &cache->links[*pindex].coll_chain)
{
if (*pindex == head)
{
*pindex = cache->links[*pindex].coll_chain;
break;
}
}
}
/* enter new rs in the hash table */
index = hash (c->ip, cache->log_size);
cache->links[head].coll_chain = cache->hash[index];
cache->hash[index] = head;
cache->links[head].ip = c->ip;
cache->links[head].valid = 1;
cache->links[head].signal_frame = tdep_cache_frame(c);
return cache->buckets + head;
}
static int
create_state_record_for (struct dwarf_cursor *c, dwarf_state_record_t *sr,
unw_word_t ip)
{
int ret;
switch (c->pi.format)
{
case UNW_INFO_FORMAT_TABLE:
case UNW_INFO_FORMAT_REMOTE_TABLE:
if ((ret = setup_fde(c, sr)) < 0)
return ret;
ret = parse_fde (c, ip, sr);
break;
case UNW_INFO_FORMAT_DYNAMIC:
ret = parse_dynamic (c, ip, sr);
break;
default:
Debug (1, "Unexpected unwind-info format %d\n", c->pi.format);
ret = -UNW_EINVAL;
}
return ret;
}
static inline int
eval_location_expr (struct dwarf_cursor *c, unw_word_t stack_val, unw_addr_space_t as,
unw_accessors_t *a, unw_word_t addr,
dwarf_loc_t *locp, void *arg)
{
int ret, is_register;
unw_word_t len, val;
/* read the length of the expression: */
if ((ret = dwarf_read_uleb128 (as, a, &addr, &len, arg)) < 0)
return ret;
/* evaluate the expression: */
if ((ret = dwarf_eval_expr (c, stack_val, &addr, len, &val, &is_register)) < 0)
return ret;
if (is_register)
*locp = DWARF_REG_LOC (c, dwarf_to_unw_regnum (val));
else
*locp = DWARF_MEM_LOC (c, val);
return 0;
}
static int
apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs)
{
unw_word_t regnum, addr, cfa, ip;
unw_word_t prev_ip, prev_cfa;
unw_addr_space_t as;
dwarf_loc_t cfa_loc;
unw_accessors_t *a;
int i, ret;
void *arg;
prev_ip = c->ip;
prev_cfa = c->cfa;
as = c->as;
arg = c->as_arg;
a = unw_get_accessors_int (as);
/* Evaluate the CFA first, because it may be referred to by other
expressions. */
if (rs->reg.where[DWARF_CFA_REG_COLUMN] == DWARF_WHERE_REG)
{
/* CFA is equal to [reg] + offset: */
/* As a special-case, if the stack-pointer is the CFA and the
stack-pointer wasn't saved, popping the CFA implicitly pops
the stack-pointer as well. */
if ((rs->reg.val[DWARF_CFA_REG_COLUMN] == UNW_TDEP_SP)
&& (UNW_TDEP_SP < ARRAY_SIZE(rs->reg.val))
&& (rs->reg.where[UNW_TDEP_SP] == DWARF_WHERE_SAME))
cfa = c->cfa;
else
{
regnum = dwarf_to_unw_regnum (rs->reg.val[DWARF_CFA_REG_COLUMN]);
if ((ret = unw_get_reg ((unw_cursor_t *) c, regnum, &cfa)) < 0)
return ret;
}
cfa += rs->reg.val[DWARF_CFA_OFF_COLUMN];
}
else
{
/* CFA is equal to EXPR: */
assert (rs->reg.where[DWARF_CFA_REG_COLUMN] == DWARF_WHERE_EXPR);
addr = rs->reg.val[DWARF_CFA_REG_COLUMN];
/* The dwarf standard doesn't specify an initial value to be pushed on */
/* the stack before DW_CFA_def_cfa_expression evaluation. We push on a */
/* dummy value (0) to keep the eval_location_expr function consistent. */
if ((ret = eval_location_expr (c, 0, as, a, addr, &cfa_loc, arg)) < 0)
return ret;
/* the returned location better be a memory location... */
if (DWARF_IS_REG_LOC (cfa_loc))
return -UNW_EBADFRAME;
cfa = DWARF_GET_LOC (cfa_loc);
}
dwarf_loc_t new_loc[DWARF_NUM_PRESERVED_REGS];
memcpy(new_loc, c->loc, sizeof(new_loc));
for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i)
{
switch ((dwarf_where_t) rs->reg.where[i])
{
case DWARF_WHERE_UNDEF:
new_loc[i] = DWARF_NULL_LOC;
break;
case DWARF_WHERE_SAME:
break;
case DWARF_WHERE_CFAREL:
new_loc[i] = DWARF_MEM_LOC (c, cfa + rs->reg.val[i]);
break;
case DWARF_WHERE_REG:
#ifdef __s390x__
/* GPRs can be saved in FPRs on s390x */
if (unw_is_fpreg (dwarf_to_unw_regnum (rs->reg.val[i])))
{
new_loc[i] = DWARF_FPREG_LOC (c, dwarf_to_unw_regnum (rs->reg.val[i]));
break;
}
#endif
new_loc[i] = new_loc[rs->reg.val[i]];
break;
case DWARF_WHERE_EXPR:
addr = rs->reg.val[i];
/* The dwarf standard requires the current CFA to be pushed on the */
/* stack before DW_CFA_expression evaluation. */
if ((ret = eval_location_expr (c, cfa, as, a, addr, new_loc + i, arg)) < 0)
return ret;
break;
case DWARF_WHERE_VAL_EXPR:
addr = rs->reg.val[i];
/* The dwarf standard requires the current CFA to be pushed on the */
/* stack before DW_CFA_val_expression evaluation. */
if ((ret = eval_location_expr (c, cfa, as, a, addr, new_loc + i, arg)) < 0)
return ret;
new_loc[i] = DWARF_VAL_LOC (c, DWARF_GET_LOC (new_loc[i]));
break;
}
}
memcpy(c->loc, new_loc, sizeof(new_loc));
c->cfa = cfa;
/* DWARF spec says undefined return address location means end of stack. */
if (DWARF_IS_NULL_LOC (c->loc[rs->ret_addr_column]))
{
c->ip = 0;
ret = 0;
}
else
{
ret = dwarf_get (c, c->loc[rs->ret_addr_column], &ip);
if (ret < 0)
return ret;
c->ip = ip;
ret = 1;
}
/* XXX: check for ip to be code_aligned */
if (c->ip == prev_ip && c->cfa == prev_cfa)
{
Dprintf ("%s: ip and cfa unchanged; stopping here (ip=0x%lx)\n",
__FUNCTION__, (long) c->ip);
return -UNW_EBADFRAME;
}
if (c->stash_frames)
tdep_stash_frame (c, rs);
return ret;
}
/* Find the saved locations. */
static int
find_reg_state (struct dwarf_cursor *c, dwarf_state_record_t *sr)
{
dwarf_reg_state_t *rs;
struct dwarf_rs_cache *cache;
int ret = 0;
intrmask_t saved_mask;
if ((cache = get_rs_cache(c->as, &saved_mask)) &&
(rs = rs_lookup(cache, c)))
{
/* update hint; no locking needed: single-word writes are atomic */
unsigned short index = rs - cache->buckets;
c->use_prev_instr = ! cache->links[index].signal_frame;
memcpy (&sr->rs_current, rs, sizeof (*rs));
}
else
{
ret = fetch_proc_info (c, c->ip);
int next_use_prev_instr = c->use_prev_instr;
if (ret >= 0)
{
/* Update use_prev_instr for the next frame. */
assert(c->pi.unwind_info);
struct dwarf_cie_info *dci = c->pi.unwind_info;
next_use_prev_instr = ! dci->signal_frame;
ret = create_state_record_for (c, sr, c->ip);
}
put_unwind_info (c, &c->pi);
c->use_prev_instr = next_use_prev_instr;
if (cache && ret >= 0)
{
rs = rs_new (cache, c);
cache->links[rs - cache->buckets].hint = 0;
memcpy(rs, &sr->rs_current, sizeof(*rs));
}
}
unsigned short index = -1;
if (cache)
{
if (rs)
{
index = rs - cache->buckets;
c->hint = cache->links[index].hint;
cache->links[c->prev_rs].hint = index + 1;
c->prev_rs = index;
}
put_rs_cache (c->as, cache, &saved_mask);
}
if (ret < 0)
return ret;
if (cache)
tdep_reuse_frame (c, cache->links[index].signal_frame);
return 0;
}
/* The function finds the saved locations and applies the register
state as well. */
HIDDEN int
dwarf_step (struct dwarf_cursor *c)
{
int ret;
dwarf_state_record_t sr;
if ((ret = find_reg_state (c, &sr)) < 0)
return ret;
return apply_reg_state (c, &sr.rs_current);
}
HIDDEN int
dwarf_make_proc_info (struct dwarf_cursor *c)
{
#if 0
if (c->as->caching_policy == UNW_CACHE_NONE
|| get_cached_proc_info (c) < 0)
#endif
/* Need to check if current frame contains
args_size, and set cursor appropriately. Only
needed for unw_resume */
dwarf_state_record_t sr;
int ret;
/* Lookup it up the slow way... */
ret = fetch_proc_info (c, c->ip);
if (ret >= 0)
ret = create_state_record_for (c, &sr, c->ip);
put_unwind_info (c, &c->pi);
if (ret < 0)
return ret;
c->args_size = sr.args_size;
return 0;
}
static int
dwarf_reg_states_dynamic_iterate(struct dwarf_cursor *c,
unw_reg_states_callback cb,
void *token)
{
Debug (1, "Not yet implemented\n");
return -UNW_ENOINFO;
}
static int
dwarf_reg_states_table_iterate(struct dwarf_cursor *c,
unw_reg_states_callback cb,
void *token)
{
dwarf_state_record_t sr;
int ret = setup_fde(c, &sr);
struct dwarf_cie_info *dci = c->pi.unwind_info;
unw_word_t addr = dci->fde_instr_start;
unw_word_t curr_ip = c->pi.start_ip;
dwarf_stackable_reg_state_t *rs_stack = NULL;
while (ret >= 0 && curr_ip < c->pi.end_ip && addr < dci->fde_instr_end)
{
unw_word_t prev_ip = curr_ip;
ret = run_cfi_program (c, &sr, &curr_ip, prev_ip, &addr, dci->fde_instr_end,
&rs_stack, dci);
if (ret >= 0 && prev_ip < curr_ip)
ret = cb(token, &sr.rs_current, sizeof(sr.rs_current), prev_ip, curr_ip);
}
empty_rstate_stack(&rs_stack);
#if defined(NEED_LAST_IP)
if (ret >= 0 && curr_ip < c->pi.last_ip)
/* report the dead zone after the procedure ends */
ret = cb(token, &sr.rs_current, sizeof(sr.rs_current), curr_ip, c->pi.last_ip);
#else
if (ret >= 0 && curr_ip < c->pi.end_ip)
/* report for whatever is left before procedure end */
ret = cb(token, &sr.rs_current, sizeof(sr.rs_current), curr_ip, c->pi.end_ip);
#endif
return ret;
}
HIDDEN int
dwarf_reg_states_iterate(struct dwarf_cursor *c,
unw_reg_states_callback cb,
void *token)
{
int ret = fetch_proc_info (c, c->ip);
int next_use_prev_instr = c->use_prev_instr;
if (ret >= 0)
{
/* Update use_prev_instr for the next frame. */
assert(c->pi.unwind_info);
struct dwarf_cie_info *dci = c->pi.unwind_info;
next_use_prev_instr = ! dci->signal_frame;
switch (c->pi.format)
{
case UNW_INFO_FORMAT_TABLE:
case UNW_INFO_FORMAT_REMOTE_TABLE:
ret = dwarf_reg_states_table_iterate(c, cb, token);
break;
case UNW_INFO_FORMAT_DYNAMIC:
ret = dwarf_reg_states_dynamic_iterate (c, cb, token);
break;
default:
Debug (1, "Unexpected unwind-info format %d\n", c->pi.format);
ret = -UNW_EINVAL;
}
}
put_unwind_info (c, &c->pi);
c->use_prev_instr = next_use_prev_instr;
return ret;
}
HIDDEN int
dwarf_apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs)
{
return apply_reg_state(c, rs);
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/x86_64/Gget_proc_info.c | /* libunwind - a platform-independent unwind library
Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P.
Contributed by David Mosberger-Tang <[email protected]>
Modified for x86_64 by Max Asbock <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
int
unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi)
{
struct cursor *c = (struct cursor *) cursor;
if (dwarf_make_proc_info (&c->dwarf) < 0)
{
/* On x86-64, some key routines such as _start() and _dl_start()
are missing DWARF unwind info. We don't want to fail in that
case, because those frames are uninteresting and just mark
the end of the frame-chain anyhow. */
memset (pi, 0, sizeof (*pi));
pi->start_ip = c->dwarf.ip;
pi->end_ip = c->dwarf.ip + 1;
return 0;
}
*pi = c->dwarf.pi;
return 0;
}
| /* libunwind - a platform-independent unwind library
Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P.
Contributed by David Mosberger-Tang <[email protected]>
Modified for x86_64 by Max Asbock <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
int
unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi)
{
struct cursor *c = (struct cursor *) cursor;
if (dwarf_make_proc_info (&c->dwarf) < 0)
{
/* On x86-64, some key routines such as _start() and _dl_start()
are missing DWARF unwind info. We don't want to fail in that
case, because those frames are uninteresting and just mark
the end of the frame-chain anyhow. */
memset (pi, 0, sizeof (*pi));
pi->start_ip = c->dwarf.ip;
pi->end_ip = c->dwarf.ip + 1;
return 0;
}
*pi = c->dwarf.pi;
return 0;
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/metadata/loader.c | /**
* \file
* Image Loader
*
* Authors:
* Paolo Molaro ([email protected])
* Miguel de Icaza ([email protected])
* Patrik Torstensson ([email protected])
*
* Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
* Copyright 2004-2009 Novell, Inc (http://www.novell.com)
* Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
*
* This file is used by the interpreter and the JIT engine to locate
* assemblies. Used to load AssemblyRef and later to resolve various
* kinds of `Refs'.
*
* TODO:
* This should keep track of the assembly versions that we are loading.
*
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#include <glib.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <mono/metadata/metadata.h>
#include <mono/metadata/image.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/tokentype.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/metadata-update.h>
#include <mono/metadata/loader.h>
#include <mono/metadata/loader-internals.h>
#include <mono/metadata/class-init.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/reflection.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/marshal.h>
#include <mono/metadata/lock-tracer.h>
#include <mono/metadata/exception-internals.h>
#include <mono/metadata/jit-info.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-dl.h>
#include <mono/utils/mono-membar.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/mono-tls.h>
#include <mono/utils/mono-path.h>
/*
* This lock protects the hash tables inside MonoImage used by the metadata
* loading functions in class.c and loader.c.
*
* See domain-internals.h for locking policy in combination with the
* domain lock.
*/
static MonoCoopMutex loader_mutex;
static mono_mutex_t global_loader_data_mutex;
static gboolean loader_lock_inited;
static gboolean loader_lock_track_ownership;
/*
* This TLS variable holds how many times the current thread has acquired the loader
* lock.
*/
static MonoNativeTlsKey loader_lock_nest_id;
MonoDefaults mono_defaults;
/* Statistics */
static gint32 inflated_signatures_size;
static gint32 memberref_sig_cache_size;
static gint32 methods_size;
static gint32 signatures_size;
void
mono_loader_init ()
{
static gboolean inited;
// FIXME: potential race
if (!inited) {
mono_coop_mutex_init_recursive (&loader_mutex);
mono_os_mutex_init_recursive (&global_loader_data_mutex);
loader_lock_inited = TRUE;
mono_global_loader_cache_init ();
mono_native_tls_alloc (&loader_lock_nest_id, NULL);
mono_counters_init ();
mono_counters_register ("Inflated signatures size",
MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &inflated_signatures_size);
mono_counters_register ("Memberref signature cache size",
MONO_COUNTER_METADATA | MONO_COUNTER_INT, &memberref_sig_cache_size);
mono_counters_register ("MonoMethod size",
MONO_COUNTER_METADATA | MONO_COUNTER_INT, &methods_size);
mono_counters_register ("MonoMethodSignature size",
MONO_COUNTER_METADATA | MONO_COUNTER_INT, &signatures_size);
inited = TRUE;
}
}
MonoDefaults *
mono_get_defaults (void)
{
return &mono_defaults;
}
void
mono_global_loader_data_lock (void)
{
mono_locks_os_acquire (&global_loader_data_mutex, LoaderGlobalDataLock);
}
void
mono_global_loader_data_unlock (void)
{
mono_locks_os_release (&global_loader_data_mutex, LoaderGlobalDataLock);
}
/**
* mono_loader_lock:
*
* See \c docs/thread-safety.txt for the locking strategy.
*/
void
mono_loader_lock (void)
{
mono_locks_coop_acquire (&loader_mutex, LoaderLock);
if (G_UNLIKELY (loader_lock_track_ownership)) {
mono_native_tls_set_value (loader_lock_nest_id, GUINT_TO_POINTER (GPOINTER_TO_UINT (mono_native_tls_get_value (loader_lock_nest_id)) + 1));
}
}
/**
* mono_loader_unlock:
*/
void
mono_loader_unlock (void)
{
mono_locks_coop_release (&loader_mutex, LoaderLock);
if (G_UNLIKELY (loader_lock_track_ownership)) {
mono_native_tls_set_value (loader_lock_nest_id, GUINT_TO_POINTER (GPOINTER_TO_UINT (mono_native_tls_get_value (loader_lock_nest_id)) - 1));
}
}
/*
* mono_loader_lock_track_ownership:
*
* Set whenever the runtime should track ownership of the loader lock. If set to TRUE,
* the mono_loader_lock_is_owned_by_self () can be called to query whenever the current
* thread owns the loader lock.
*/
void
mono_loader_lock_track_ownership (gboolean track)
{
loader_lock_track_ownership = track;
}
/*
* mono_loader_lock_is_owned_by_self:
*
* Return whenever the current thread owns the loader lock.
* This is useful to avoid blocking operations while holding the loader lock.
*/
gboolean
mono_loader_lock_is_owned_by_self (void)
{
g_assert (loader_lock_track_ownership);
return GPOINTER_TO_UINT (mono_native_tls_get_value (loader_lock_nest_id)) > 0;
}
/*
* mono_loader_lock_if_inited:
*
* Acquire the loader lock if it has been initialized, no-op otherwise. This can
* be used in runtime initialization code which can be executed before mono_loader_init ().
*/
void
mono_loader_lock_if_inited (void)
{
if (loader_lock_inited)
mono_loader_lock ();
}
void
mono_loader_unlock_if_inited (void)
{
if (loader_lock_inited)
mono_loader_unlock ();
}
/*
* find_cached_memberref_sig:
*
* Return a cached copy of the memberref signature identified by SIG_IDX.
* We use a gpointer since the cache stores both MonoTypes and MonoMethodSignatures.
* A cache is needed since the type/signature parsing routines allocate everything
* from a mempool, so without a cache, multiple requests for the same signature would
* lead to unbounded memory growth. For normal methods/fields this is not a problem
* since the resulting methods/fields are cached, but inflated methods/fields cannot
* be cached.
* LOCKING: Acquires the loader lock.
*/
static gpointer
find_cached_memberref_sig (MonoImage *image, guint32 sig_idx)
{
gpointer res;
mono_image_lock (image);
res = g_hash_table_lookup (image->memberref_signatures, GUINT_TO_POINTER (sig_idx));
mono_image_unlock (image);
return res;
}
static gpointer
cache_memberref_sig (MonoImage *image, guint32 sig_idx, gpointer sig)
{
gpointer prev_sig;
mono_image_lock (image);
prev_sig = g_hash_table_lookup (image->memberref_signatures, GUINT_TO_POINTER (sig_idx));
if (prev_sig) {
/* Somebody got in before us */
sig = prev_sig;
}
else {
g_hash_table_insert (image->memberref_signatures, GUINT_TO_POINTER (sig_idx), sig);
/* An approximation based on glib 2.18 */
mono_atomic_fetch_add_i32 (&memberref_sig_cache_size, sizeof (gpointer) * 4);
}
mono_image_unlock (image);
return sig;
}
static MonoClassField*
field_from_memberref (MonoImage *image, guint32 token, MonoClass **retklass,
MonoGenericContext *context, MonoError *error)
{
MonoClass *klass = NULL;
MonoClassField *field;
MonoTableInfo *tables = image->tables;
MonoType *sig_type;
guint32 cols[6];
guint32 nindex, class_index;
const char *fname;
const char *ptr;
guint32 idx = mono_metadata_token_index (token);
error_init (error);
mono_metadata_decode_row (&tables [MONO_TABLE_MEMBERREF], idx-1, cols, MONO_MEMBERREF_SIZE);
nindex = cols [MONO_MEMBERREF_CLASS] >> MONO_MEMBERREF_PARENT_BITS;
class_index = cols [MONO_MEMBERREF_CLASS] & MONO_MEMBERREF_PARENT_MASK;
fname = mono_metadata_string_heap (image, cols [MONO_MEMBERREF_NAME]);
switch (class_index) {
case MONO_MEMBERREF_PARENT_TYPEDEF:
klass = mono_class_get_checked (image, MONO_TOKEN_TYPE_DEF | nindex, error);
break;
case MONO_MEMBERREF_PARENT_TYPEREF:
klass = mono_class_from_typeref_checked (image, MONO_TOKEN_TYPE_REF | nindex, error);
break;
case MONO_MEMBERREF_PARENT_TYPESPEC:
klass = mono_class_get_and_inflate_typespec_checked (image, MONO_TOKEN_TYPE_SPEC | nindex, context, error);
break;
default:
mono_error_set_bad_image (error, image, "Bad field field '%u' signature 0x%08x", class_index, token);
}
if (!klass)
return NULL;
ptr = mono_metadata_blob_heap (image, cols [MONO_MEMBERREF_SIGNATURE]);
mono_metadata_decode_blob_size (ptr, &ptr);
/* we may want to check the signature here... */
if (*ptr++ != 0x6) {
mono_error_set_field_missing (error, klass, fname, NULL, "Bad field signature class token %08x field token %08x", class_index, token);
return NULL;
}
/* FIXME: This needs a cache, especially for generic instances, since
* we ask mono_metadata_parse_type_checked () to allocates everything from a mempool.
* FIXME part2, mono_metadata_parse_type_checked actually allows for a transient type instead.
* FIXME part3, transient types are not 100% transient, so we need to take care of that first.
*/
sig_type = (MonoType *)find_cached_memberref_sig (image, cols [MONO_MEMBERREF_SIGNATURE]);
if (!sig_type) {
ERROR_DECL (inner_error);
sig_type = mono_metadata_parse_type_checked (image, NULL, 0, FALSE, ptr, &ptr, inner_error);
if (sig_type == NULL) {
mono_error_set_field_missing (error, klass, fname, NULL, "Could not parse field signature %08x due to: %s", token, mono_error_get_message (inner_error));
mono_error_cleanup (inner_error);
return NULL;
}
sig_type = (MonoType *)cache_memberref_sig (image, cols [MONO_MEMBERREF_SIGNATURE], sig_type);
}
mono_class_init_internal (klass); /*FIXME is this really necessary?*/
if (retklass)
*retklass = klass;
field = mono_class_get_field_from_name_full (klass, fname, sig_type);
if (!field) {
mono_error_set_field_missing (error, klass, fname, sig_type, "Could not find field in class");
}
return field;
}
/**
* mono_field_from_token:
* \deprecated use the \c _checked variant
* Notes: runtime code MUST not use this function
*/
MonoClassField*
mono_field_from_token (MonoImage *image, guint32 token, MonoClass **retklass, MonoGenericContext *context)
{
ERROR_DECL (error);
MonoClassField *res = mono_field_from_token_checked (image, token, retklass, context, error);
mono_error_assert_ok (error);
return res;
}
MonoClassField*
mono_field_from_token_checked (MonoImage *image, guint32 token, MonoClass **retklass, MonoGenericContext *context, MonoError *error)
{
MonoClass *k;
guint32 type;
MonoClassField *field;
error_init (error);
if (image_is_dynamic (image)) {
MonoClassField *result;
MonoClass *handle_class;
*retklass = NULL;
ERROR_DECL (inner_error);
result = (MonoClassField *)mono_lookup_dynamic_token_class (image, token, TRUE, &handle_class, context, inner_error);
mono_error_cleanup (inner_error);
// This checks the memberref type as well
if (!result || handle_class != mono_defaults.fieldhandle_class) {
mono_error_set_bad_image (error, image, "Bad field token 0x%08x", token);
return NULL;
}
*retklass = m_field_get_parent (result);
return result;
}
if ((field = (MonoClassField *)mono_conc_hashtable_lookup (image->field_cache, GUINT_TO_POINTER (token)))) {
*retklass = m_field_get_parent (field);
return field;
}
if (mono_metadata_token_table (token) == MONO_TABLE_MEMBERREF) {
field = field_from_memberref (image, token, retklass, context, error);
} else {
type = mono_metadata_typedef_from_field (image, mono_metadata_token_index (token));
if (!type) {
mono_error_set_bad_image (error, image, "Invalid field token 0x%08x", token);
return NULL;
}
k = mono_class_get_checked (image, MONO_TOKEN_TYPE_DEF | type, error);
if (!k)
return NULL;
mono_class_init_internal (k);
if (retklass)
*retklass = k;
if (mono_class_has_failure (k)) {
ERROR_DECL (causedby_error);
mono_error_set_for_class_failure (causedby_error, k);
mono_error_set_bad_image (error, image, "Could not resolve field token 0x%08x, due to: %s", token, mono_error_get_message (causedby_error));
mono_error_cleanup (causedby_error);
} else {
field = mono_class_get_field (k, token);
if (!field) {
mono_error_set_bad_image (error, image, "Could not resolve field token 0x%08x", token);
}
}
}
MonoClass *field_parent = NULL;
if (field && ((field_parent = m_field_get_parent (field))) && !mono_class_is_ginst (field_parent) && !mono_class_is_gtd (field_parent)) {
mono_image_lock (image);
mono_conc_hashtable_insert (image->field_cache, GUINT_TO_POINTER (token), field);
mono_image_unlock (image);
}
return field;
}
static gboolean
mono_metadata_signature_vararg_match (MonoMethodSignature *sig1, MonoMethodSignature *sig2)
{
int i;
if (sig1->hasthis != sig2->hasthis ||
sig1->sentinelpos != sig2->sentinelpos)
return FALSE;
for (i = 0; i < sig1->sentinelpos; i++) {
MonoType *p1 = sig1->params[i];
MonoType *p2 = sig2->params[i];
/*if (p1->attrs != p2->attrs)
return FALSE;
*/
if (!mono_metadata_type_equal (p1, p2))
return FALSE;
}
if (!mono_metadata_type_equal (sig1->ret, sig2->ret))
return FALSE;
return TRUE;
}
static MonoMethod *
find_method_in_class (MonoClass *klass, const char *name, const char *qname, const char *fqname,
MonoMethodSignature *sig, MonoClass *from_class, MonoError *error)
{
int i;
/* FIXME: method refs from metadata-upate probably end up here */
/* Search directly in the metadata to avoid calling setup_methods () */
error_init (error);
MonoImage *klass_image = m_class_get_image (klass);
/* FIXME: !mono_class_is_ginst (from_class) condition causes test failures. */
if (m_class_get_type_token (klass) && !image_is_dynamic (klass_image) && !m_class_get_methods (klass) && !m_class_get_rank (klass) && klass == from_class && !mono_class_is_ginst (from_class)) {
int first_idx = mono_class_get_first_method_idx (klass);
int mcount = mono_class_get_method_count (klass);
for (i = 0; i < mcount; ++i) {
guint32 cols [MONO_METHOD_SIZE];
MonoMethod *method;
const char *m_name;
MonoMethodSignature *other_sig;
mono_metadata_decode_table_row (klass_image, MONO_TABLE_METHOD, first_idx + i, cols, MONO_METHOD_SIZE);
m_name = mono_metadata_string_heap (klass_image, cols [MONO_METHOD_NAME]);
if (!((fqname && !strcmp (m_name, fqname)) ||
(qname && !strcmp (m_name, qname)) ||
(name && !strcmp (m_name, name))))
continue;
method = mono_get_method_checked (klass_image, MONO_TOKEN_METHOD_DEF | (first_idx + i + 1), klass, NULL, error);
if (!is_ok (error)) //bail out if we hit a loader error
return NULL;
if (method) {
other_sig = mono_method_signature_checked (method, error);
if (!is_ok (error)) //bail out if we hit a loader error
return NULL;
if (other_sig && (sig->call_convention != MONO_CALL_VARARG) && mono_metadata_signature_equal (sig, other_sig))
return method;
}
}
}
mono_class_setup_methods (klass); /* FIXME don't swallow the error here. */
/*
We can't fail lookup of methods otherwise the runtime will fail with MissingMethodException instead of TypeLoadException.
See mono/tests/generic-type-load-exception.2.il
FIXME we should better report this error to the caller
*/
if (!m_class_get_methods (klass) || mono_class_has_failure (klass)) {
ERROR_DECL (cause_error);
mono_error_set_for_class_failure (cause_error, klass);
mono_error_set_type_load_class (error, klass, "Could not find method '%s' due to a type load error: %s", name, mono_error_get_message (cause_error));
mono_error_cleanup (cause_error);
return NULL;
}
int mcount = mono_class_get_method_count (klass);
MonoMethod **klass_methods = m_class_get_methods (klass);
for (i = 0; i < mcount; ++i) {
MonoMethod *m = klass_methods [i];
MonoMethodSignature *msig;
/* We must cope with failing to load some of the types. */
if (!m)
continue;
if (!((fqname && !strcmp (m->name, fqname)) ||
(qname && !strcmp (m->name, qname)) ||
(name && !strcmp (m->name, name))))
continue;
msig = mono_method_signature_checked (m, error);
if (!is_ok (error)) //bail out if we hit a loader error
return NULL;
if (!msig)
continue;
if (sig->call_convention == MONO_CALL_VARARG) {
if (mono_metadata_signature_vararg_match (sig, msig))
break;
} else {
if (mono_metadata_signature_equal (sig, msig))
break;
}
}
if (i < mcount)
return mono_class_get_method_by_index (from_class, i);
return NULL;
}
static MonoMethod *
find_method (MonoClass *in_class, MonoClass *ic, const char* name, MonoMethodSignature *sig, MonoClass *from_class, MonoError *error)
{
int i;
char *qname, *fqname, *class_name;
gboolean is_interface;
MonoMethod *result = NULL;
MonoClass *initial_class = in_class;
error_init (error);
is_interface = MONO_CLASS_IS_INTERFACE_INTERNAL (in_class);
if (ic) {
class_name = mono_type_get_name_full (m_class_get_byval_arg (ic), MONO_TYPE_NAME_FORMAT_IL);
qname = g_strconcat (class_name, ".", name, (const char*)NULL);
const char *ic_name_space = m_class_get_name_space (ic);
if (ic_name_space && ic_name_space [0])
fqname = g_strconcat (ic_name_space, ".", class_name, ".", name, (const char*)NULL);
else
fqname = NULL;
} else
class_name = qname = fqname = NULL;
while (in_class) {
g_assert (from_class);
result = find_method_in_class (in_class, name, qname, fqname, sig, from_class, error);
if (result || !is_ok (error))
goto out;
if (name [0] == '.' && (!strcmp (name, ".ctor") || !strcmp (name, ".cctor")))
break;
/*
* This happens when we fail to lazily load the interfaces of one of the types.
* On such case we can't just bail out since user code depends on us trying harder.
*/
if (m_class_get_interface_offsets_count (from_class) != m_class_get_interface_offsets_count (in_class)) {
in_class = m_class_get_parent (in_class);
from_class = m_class_get_parent (from_class);
continue;
}
int in_class_interface_offsets_count = m_class_get_interface_offsets_count (in_class);
MonoClass **in_class_interfaces_packed = m_class_get_interfaces_packed (in_class);
MonoClass **from_class_interfaces_packed = m_class_get_interfaces_packed (from_class);
for (i = 0; i < in_class_interface_offsets_count; i++) {
MonoClass *in_ic = in_class_interfaces_packed [i];
MonoClass *from_ic = from_class_interfaces_packed [i];
char *ic_qname, *ic_fqname, *ic_class_name;
ic_class_name = mono_type_get_name_full (m_class_get_byval_arg (in_ic), MONO_TYPE_NAME_FORMAT_IL);
ic_qname = g_strconcat (ic_class_name, ".", name, (const char*)NULL);
const char *in_ic_name_space = m_class_get_name_space (in_ic);
if (in_ic_name_space && in_ic_name_space [0])
ic_fqname = g_strconcat (in_ic_name_space, ".", ic_class_name, ".", name, (const char*)NULL);
else
ic_fqname = NULL;
result = find_method_in_class (in_ic, ic ? name : NULL, ic_qname, ic_fqname, sig, from_ic, error);
g_free (ic_class_name);
g_free (ic_fqname);
g_free (ic_qname);
if (result || !is_ok (error))
goto out;
}
in_class = m_class_get_parent (in_class);
from_class = m_class_get_parent (from_class);
}
g_assert (!in_class == !from_class);
if (is_interface)
result = find_method_in_class (mono_defaults.object_class, name, qname, fqname, sig, mono_defaults.object_class, error);
//we did not find the method
if (!result && is_ok (error))
mono_error_set_method_missing (error, initial_class, name, sig, NULL);
out:
g_free (class_name);
g_free (fqname);
g_free (qname);
return result;
}
static MonoMethodSignature*
inflate_generic_signature_checked (MonoImage *image, MonoMethodSignature *sig, MonoGenericContext *context, MonoError *error)
{
MonoMethodSignature *res;
gboolean is_open;
int i;
error_init (error);
if (!context)
return sig;
res = (MonoMethodSignature *)g_malloc0 (MONO_SIZEOF_METHOD_SIGNATURE + ((gint32)sig->param_count) * sizeof (MonoType*));
res->param_count = sig->param_count;
res->sentinelpos = -1;
res->ret = mono_class_inflate_generic_type_checked (sig->ret, context, error);
if (!is_ok (error))
goto fail;
is_open = mono_class_is_open_constructed_type (res->ret);
for (i = 0; i < sig->param_count; ++i) {
res->params [i] = mono_class_inflate_generic_type_checked (sig->params [i], context, error);
if (!is_ok (error))
goto fail;
if (!is_open)
is_open = mono_class_is_open_constructed_type (res->params [i]);
}
res->hasthis = sig->hasthis;
res->explicit_this = sig->explicit_this;
res->call_convention = sig->call_convention;
res->pinvoke = sig->pinvoke;
res->generic_param_count = sig->generic_param_count;
res->sentinelpos = sig->sentinelpos;
res->has_type_parameters = is_open;
res->is_inflated = 1;
return res;
fail:
if (res->ret)
mono_metadata_free_type (res->ret);
for (i = 0; i < sig->param_count; ++i) {
if (res->params [i])
mono_metadata_free_type (res->params [i]);
}
g_free (res);
return NULL;
}
/**
* mono_inflate_generic_signature:
*
* Inflate \p sig with \p context, and return a canonical copy. On error, set \p error, and return NULL.
*/
MonoMethodSignature*
mono_inflate_generic_signature (MonoMethodSignature *sig, MonoGenericContext *context, MonoError *error)
{
MonoMethodSignature *res, *cached;
res = inflate_generic_signature_checked (NULL, sig, context, error);
if (!is_ok (error))
return NULL;
cached = mono_metadata_get_inflated_signature (res, context);
if (cached != res)
mono_metadata_free_inflated_signature (res);
return cached;
}
static MonoMethodHeader*
inflate_generic_header (MonoMethodHeader *header, MonoGenericContext *context, MonoError *error)
{
size_t locals_size = sizeof (gpointer) * header->num_locals;
size_t clauses_size = header->num_clauses * sizeof (MonoExceptionClause);
size_t header_size = MONO_SIZEOF_METHOD_HEADER + locals_size + clauses_size;
MonoMethodHeader *res = (MonoMethodHeader *)g_malloc0 (header_size);
res->num_locals = header->num_locals;
res->clauses = (MonoExceptionClause *) &res->locals [res->num_locals] ;
memcpy (res->clauses, header->clauses, clauses_size);
res->code = header->code;
res->code_size = header->code_size;
res->max_stack = header->max_stack;
res->num_clauses = header->num_clauses;
res->init_locals = header->init_locals;
res->is_transient = TRUE;
error_init (error);
for (int i = 0; i < header->num_locals; ++i) {
res->locals [i] = mono_class_inflate_generic_type_checked (header->locals [i], context, error);
goto_if_nok (error, fail);
}
if (res->num_clauses) {
for (int i = 0; i < header->num_clauses; ++i) {
MonoExceptionClause *clause = &res->clauses [i];
if (clause->flags != MONO_EXCEPTION_CLAUSE_NONE)
continue;
clause->data.catch_class = mono_class_inflate_generic_class_checked (clause->data.catch_class, context, error);
goto_if_nok (error, fail);
}
}
return res;
fail:
g_free (res);
return NULL;
}
/**
* mono_method_get_signature_full:
* \p token is the method ref/def/spec token used in a \c call IL instruction.
* \deprecated use the \c _checked variant
* Notes: runtime code MUST not use this function
*/
MonoMethodSignature*
mono_method_get_signature_full (MonoMethod *method, MonoImage *image, guint32 token, MonoGenericContext *context)
{
ERROR_DECL (error);
MonoMethodSignature *res = mono_method_get_signature_checked (method, image, token, context, error);
mono_error_cleanup (error);
return res;
}
MonoMethodSignature*
mono_method_get_signature_checked (MonoMethod *method, MonoImage *image, guint32 token, MonoGenericContext *context, MonoError *error)
{
int table = mono_metadata_token_table (token);
int idx = mono_metadata_token_index (token);
int sig_idx;
guint32 cols [MONO_MEMBERREF_SIZE];
MonoMethodSignature *sig;
const char *ptr;
error_init (error);
/* !table is for wrappers: we should really assign their own token to them */
if (!table || table == MONO_TABLE_METHOD)
return mono_method_signature_checked (method, error);
if (table == MONO_TABLE_METHODSPEC) {
/* the verifier (do_invoke_method) will turn the NULL into a verifier error */
if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) || !method->is_inflated) {
mono_error_set_bad_image (error, image, "Method is a pinvoke or open generic");
return NULL;
}
return mono_method_signature_checked (method, error);
}
if (mono_class_is_ginst (method->klass))
return mono_method_signature_checked (method, error);
if (image_is_dynamic (image)) {
sig = mono_reflection_lookup_signature (image, method, token, error);
if (!sig)
return NULL;
} else {
mono_metadata_decode_row (&image->tables [MONO_TABLE_MEMBERREF], idx-1, cols, MONO_MEMBERREF_SIZE);
sig_idx = cols [MONO_MEMBERREF_SIGNATURE];
sig = (MonoMethodSignature *)find_cached_memberref_sig (image, sig_idx);
if (!sig) {
ptr = mono_metadata_blob_heap (image, sig_idx);
mono_metadata_decode_blob_size (ptr, &ptr);
sig = mono_metadata_parse_method_signature_full (image, NULL, 0, ptr, NULL, error);
if (!sig)
return NULL;
sig = (MonoMethodSignature *)cache_memberref_sig (image, sig_idx, sig);
}
}
if (context) {
MonoMethodSignature *cached;
/* This signature is not owned by a MonoMethod, so need to cache */
sig = inflate_generic_signature_checked (image, sig, context, error);
if (!is_ok (error))
return NULL;
cached = mono_metadata_get_inflated_signature (sig, context);
if (cached != sig)
mono_metadata_free_inflated_signature (sig);
else
mono_atomic_fetch_add_i32 (&inflated_signatures_size, mono_metadata_signature_size (cached));
sig = cached;
}
g_assert (is_ok (error));
return sig;
}
/**
* mono_method_get_signature:
* \p token is the method_ref/def/spec token used in a call IL instruction.
* \deprecated use the \c _checked variant
* Notes: runtime code MUST not use this function
*/
MonoMethodSignature*
mono_method_get_signature (MonoMethod *method, MonoImage *image, guint32 token)
{
ERROR_DECL (error);
MonoMethodSignature *res = mono_method_get_signature_checked (method, image, token, NULL, error);
mono_error_cleanup (error);
return res;
}
/* this is only for the typespec array methods */
MonoMethod*
mono_method_search_in_array_class (MonoClass *klass, const char *name, MonoMethodSignature *sig)
{
int i;
mono_class_setup_methods (klass);
g_assert (!mono_class_has_failure (klass)); /*FIXME this should not fail, right?*/
int mcount = mono_class_get_method_count (klass);
MonoMethod **klass_methods = m_class_get_methods (klass);
for (i = 0; i < mcount; ++i) {
MonoMethod *method = klass_methods [i];
if (strcmp (method->name, name) == 0 && sig->param_count == method->signature->param_count)
return method;
}
return NULL;
}
static MonoMethod *
method_from_memberref (MonoImage *image, guint32 idx, MonoGenericContext *typespec_context,
gboolean *used_context, MonoError *error)
{
MonoClass *klass = NULL;
MonoMethod *method = NULL;
MonoTableInfo *tables = image->tables;
guint32 cols[6];
guint32 nindex, class_index, sig_idx;
const char *mname;
MonoMethodSignature *sig;
const char *ptr;
error_init (error);
mono_metadata_decode_row (&tables [MONO_TABLE_MEMBERREF], idx-1, cols, MONO_MEMBERREF_SIZE);
nindex = cols [MONO_MEMBERREF_CLASS] >> MONO_MEMBERREF_PARENT_BITS;
class_index = cols [MONO_MEMBERREF_CLASS] & MONO_MEMBERREF_PARENT_MASK;
/*g_print ("methodref: 0x%x 0x%x %s\n", class, nindex,
mono_metadata_string_heap (m, cols [MONO_MEMBERREF_NAME]));*/
mname = mono_metadata_string_heap (image, cols [MONO_MEMBERREF_NAME]);
/*
* Whether we actually used the `typespec_context' or not.
* This is used to tell our caller whether or not it's safe to insert the returned
* method into a cache.
*/
if (used_context)
*used_context = class_index == MONO_MEMBERREF_PARENT_TYPESPEC;
switch (class_index) {
case MONO_MEMBERREF_PARENT_TYPEREF:
klass = mono_class_from_typeref_checked (image, MONO_TOKEN_TYPE_REF | nindex, error);
if (!klass)
goto fail;
break;
case MONO_MEMBERREF_PARENT_TYPESPEC:
/*
* Parse the TYPESPEC in the parent's context.
*/
klass = mono_class_get_and_inflate_typespec_checked (image, MONO_TOKEN_TYPE_SPEC | nindex, typespec_context, error);
if (!klass)
goto fail;
break;
case MONO_MEMBERREF_PARENT_TYPEDEF:
klass = mono_class_get_checked (image, MONO_TOKEN_TYPE_DEF | nindex, error);
if (!klass)
goto fail;
break;
case MONO_MEMBERREF_PARENT_METHODDEF: {
method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | nindex, NULL, NULL, error);
if (!method)
goto fail;
return method;
}
default:
mono_error_set_bad_image (error, image, "Memberref parent unknown: class: %d, index %d", class_index, nindex);
goto fail;
}
g_assert (klass);
mono_class_init_internal (klass);
sig_idx = cols [MONO_MEMBERREF_SIGNATURE];
ptr = mono_metadata_blob_heap (image, sig_idx);
mono_metadata_decode_blob_size (ptr, &ptr);
sig = (MonoMethodSignature *)find_cached_memberref_sig (image, sig_idx);
if (!sig) {
sig = mono_metadata_parse_method_signature_full (image, NULL, 0, ptr, NULL, error);
if (sig == NULL)
goto fail;
sig = (MonoMethodSignature *)cache_memberref_sig (image, sig_idx, sig);
}
switch (class_index) {
case MONO_MEMBERREF_PARENT_TYPEREF:
case MONO_MEMBERREF_PARENT_TYPEDEF:
method = find_method (klass, NULL, mname, sig, klass, error);
break;
case MONO_MEMBERREF_PARENT_TYPESPEC: {
MonoType *type;
type = m_class_get_byval_arg (klass);
if (type->type != MONO_TYPE_ARRAY && type->type != MONO_TYPE_SZARRAY) {
MonoClass *in_class = mono_class_is_ginst (klass) ? mono_class_get_generic_class (klass)->container_class : klass;
method = find_method (in_class, NULL, mname, sig, klass, error);
break;
}
/* we're an array and we created these methods already in klass in mono_class_init_internal () */
method = mono_method_search_in_array_class (klass, mname, sig);
break;
}
default:
mono_error_set_bad_image (error, image,"Memberref parent unknown: class: %d, index %d", class_index, nindex);
goto fail;
}
if (!method && is_ok (error))
mono_error_set_method_missing (error, klass, mname, sig, "Failed to load due to unknown reasons");
return method;
fail:
g_assert (!is_ok (error));
return NULL;
}
static MonoMethod *
method_from_methodspec (MonoImage *image, MonoGenericContext *context, guint32 idx, MonoError *error)
{
MonoMethod *method;
MonoClass *klass;
MonoTableInfo *tables = image->tables;
MonoGenericContext new_context;
MonoGenericInst *inst;
const char *ptr;
guint32 cols [MONO_METHODSPEC_SIZE];
guint32 token, nindex, param_count;
error_init (error);
mono_metadata_decode_row (&tables [MONO_TABLE_METHODSPEC], idx - 1, cols, MONO_METHODSPEC_SIZE);
token = cols [MONO_METHODSPEC_METHOD];
nindex = token >> MONO_METHODDEFORREF_BITS;
ptr = mono_metadata_blob_heap (image, cols [MONO_METHODSPEC_SIGNATURE]);
mono_metadata_decode_value (ptr, &ptr);
ptr++;
param_count = mono_metadata_decode_value (ptr, &ptr);
inst = mono_metadata_parse_generic_inst (image, NULL, param_count, ptr, &ptr, error);
if (!inst)
return NULL;
if (context && inst->is_open) {
inst = mono_metadata_inflate_generic_inst (inst, context, error);
if (!is_ok (error))
return NULL;
}
if ((token & MONO_METHODDEFORREF_MASK) == MONO_METHODDEFORREF_METHODDEF) {
method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | nindex, NULL, context, error);
if (!method)
return NULL;
} else {
method = method_from_memberref (image, nindex, context, NULL, error);
}
if (!method)
return NULL;
klass = method->klass;
if (mono_class_is_ginst (klass)) {
g_assert (method->is_inflated);
method = ((MonoMethodInflated *) method)->declaring;
}
new_context.class_inst = mono_class_is_ginst (klass) ? mono_class_get_generic_class (klass)->context.class_inst : NULL;
new_context.method_inst = inst;
method = mono_class_inflate_generic_method_full_checked (method, klass, &new_context, error);
return method;
}
/*
* LOCKING: assumes the loader lock to be taken.
*/
static MonoMethod *
mono_get_method_from_token (MonoImage *image, guint32 token, MonoClass *klass,
MonoGenericContext *context, gboolean *used_context, MonoError *error)
{
MonoMethod *result;
int table = mono_metadata_token_table (token);
int idx = mono_metadata_token_index (token);
MonoTableInfo *tables = image->tables;
MonoGenericContainer *generic_container = NULL, *container = NULL;
const char *sig = NULL;
guint32 cols [MONO_METHOD_SIZE];
error_init (error);
if (image_is_dynamic (image)) {
MonoClass *handle_class;
result = (MonoMethod *)mono_lookup_dynamic_token_class (image, token, TRUE, &handle_class, context, error);
return_val_if_nok (error, NULL);
// This checks the memberref type as well
if (result && handle_class != mono_defaults.methodhandle_class) {
mono_error_set_bad_image (error, image, "Bad method token 0x%08x on dynamic image", token);
return NULL;
}
return result;
}
if (table != MONO_TABLE_METHOD) {
if (table == MONO_TABLE_METHODSPEC) {
if (used_context) *used_context = TRUE;
return method_from_methodspec (image, context, idx, error);
}
if (table != MONO_TABLE_MEMBERREF) {
mono_error_set_bad_image (error, image, "Bad method token 0x%08x.", token);
return NULL;
}
return method_from_memberref (image, idx, context, used_context, error);
}
if (used_context) *used_context = FALSE;
if (mono_metadata_table_bounds_check (image, MONO_TABLE_METHOD, idx)) {
mono_error_set_bad_image (error, image, "Bad method token 0x%08x (out of bounds).", token);
return NULL;
}
if (!klass) {
guint32 type = mono_metadata_typedef_from_method (image, token);
if (!type) {
mono_error_set_bad_image (error, image, "Bad method token 0x%08x (could not find corresponding typedef).", token);
return NULL;
}
klass = mono_class_get_checked (image, MONO_TOKEN_TYPE_DEF | type, error);
if (klass == NULL)
return NULL;
}
mono_metadata_decode_row (&image->tables [MONO_TABLE_METHOD], idx - 1, cols, MONO_METHOD_SIZE);
if ((cols [MONO_METHOD_FLAGS] & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(cols [MONO_METHOD_IMPLFLAGS] & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)) {
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethodPInvoke));
} else {
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethod));
mono_atomic_fetch_add_i32 (&methods_size, sizeof (MonoMethod));
}
mono_atomic_inc_i32 (&mono_stats.method_count);
result->slot = -1;
result->klass = klass;
result->flags = cols [MONO_METHOD_FLAGS];
result->iflags = cols [MONO_METHOD_IMPLFLAGS];
result->token = token;
result->name = mono_metadata_string_heap (image, cols [MONO_METHOD_NAME]);
/* If a method is abstract and marked as an icall, silently ignore the
* icall attribute so that we don't later emit a warning that the icall
* can't be found.
*/
if ((result->flags & METHOD_ATTRIBUTE_ABSTRACT) &&
(result->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
result->iflags &= ~METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL;
if (!sig) /* already taken from the methodref */
sig = mono_metadata_blob_heap (image, cols [MONO_METHOD_SIGNATURE]);
/* size = */ mono_metadata_decode_blob_size (sig, &sig);
container = mono_class_try_get_generic_container (klass);
/*
* load_generic_params does a binary search so only call it if the method
* is generic.
*/
if (*sig & 0x10) {
generic_container = mono_metadata_load_generic_params (image, token, container, result);
}
if (generic_container) {
result->is_generic = TRUE;
/*FIXME put this before the image alloc*/
if (!mono_metadata_load_generic_param_constraints_checked (image, token, generic_container, error))
return NULL;
container = generic_container;
}
if (cols [MONO_METHOD_IMPLFLAGS] & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) {
if (result->klass == mono_defaults.string_class && !strcmp (result->name, ".ctor"))
result->string_ctor = 1;
} else if (cols [MONO_METHOD_FLAGS] & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)result;
#ifdef TARGET_WIN32
/* IJW is P/Invoke with a predefined function pointer. */
if (m_image_is_module_handle (image) && (cols [MONO_METHOD_IMPLFLAGS] & METHOD_IMPL_ATTRIBUTE_NATIVE)) {
piinfo->addr = mono_image_rva_map (image, cols [MONO_METHOD_RVA]);
g_assert (piinfo->addr);
}
#endif
piinfo->implmap_idx = mono_metadata_implmap_from_method (image, idx - 1);
/* Native methods can have no map. */
if (piinfo->implmap_idx)
piinfo->piflags = mono_metadata_decode_row_col (&tables [MONO_TABLE_IMPLMAP], piinfo->implmap_idx - 1, MONO_IMPLMAP_FLAGS);
}
if (generic_container)
mono_method_set_generic_container (result, generic_container);
return result;
}
/**
* mono_get_method:
*/
MonoMethod *
mono_get_method (MonoImage *image, guint32 token, MonoClass *klass)
{
ERROR_DECL (error);
MonoMethod *result = mono_get_method_checked (image, token, klass, NULL, error);
mono_error_cleanup (error);
return result;
}
/**
* mono_get_method_full:
*/
MonoMethod *
mono_get_method_full (MonoImage *image, guint32 token, MonoClass *klass,
MonoGenericContext *context)
{
ERROR_DECL (error);
MonoMethod *result = mono_get_method_checked (image, token, klass, context, error);
mono_error_cleanup (error);
return result;
}
MonoMethod *
mono_get_method_checked (MonoImage *image, guint32 token, MonoClass *klass, MonoGenericContext *context, MonoError *error)
{
MonoMethod *result = NULL;
gboolean used_context = FALSE;
/* FIXME: method definition lookups for metadata-update probably end up here */
/* We do everything inside the lock to prevent creation races */
error_init (error);
mono_image_lock (image);
if (mono_metadata_token_table (token) == MONO_TABLE_METHOD) {
if (!image->method_cache)
image->method_cache = g_hash_table_new (NULL, NULL);
result = (MonoMethod *)g_hash_table_lookup (image->method_cache, GINT_TO_POINTER (mono_metadata_token_index (token)));
} else if (!image_is_dynamic (image)) {
if (!image->methodref_cache)
image->methodref_cache = g_hash_table_new (NULL, NULL);
result = (MonoMethod *)g_hash_table_lookup (image->methodref_cache, GINT_TO_POINTER (token));
}
mono_image_unlock (image);
if (result)
return result;
result = mono_get_method_from_token (image, token, klass, context, &used_context, error);
if (!result)
return NULL;
mono_image_lock (image);
if (!used_context && !result->is_inflated) {
MonoMethod *result2 = NULL;
if (mono_metadata_token_table (token) == MONO_TABLE_METHOD)
result2 = (MonoMethod *)g_hash_table_lookup (image->method_cache, GINT_TO_POINTER (mono_metadata_token_index (token)));
else if (!image_is_dynamic (image))
result2 = (MonoMethod *)g_hash_table_lookup (image->methodref_cache, GINT_TO_POINTER (token));
if (result2) {
mono_image_unlock (image);
return result2;
}
if (mono_metadata_token_table (token) == MONO_TABLE_METHOD)
g_hash_table_insert (image->method_cache, GINT_TO_POINTER (mono_metadata_token_index (token)), result);
else if (!image_is_dynamic (image))
g_hash_table_insert (image->methodref_cache, GINT_TO_POINTER (token), result);
}
mono_image_unlock (image);
return result;
}
static MonoMethod*
get_method_constrained (MonoImage *image, MonoMethod *method, MonoClass *constrained_class, MonoGenericContext *context, MonoError *error)
{
MonoClass *base_class = method->klass;
error_init (error);
if (!mono_class_is_assignable_from_internal (base_class, constrained_class)) {
char *base_class_name = mono_type_get_full_name (base_class);
char *constrained_class_name = mono_type_get_full_name (constrained_class);
mono_error_set_invalid_operation (error, "constrained call: %s is not assignable from %s", base_class_name, constrained_class_name);
g_free (base_class_name);
g_free (constrained_class_name);
return NULL;
}
/* If the constraining class is actually an interface, we don't learn
* anything new by constraining.
*/
if (MONO_CLASS_IS_INTERFACE_INTERNAL (constrained_class))
return method;
mono_class_setup_vtable (base_class);
if (mono_class_has_failure (base_class)) {
mono_error_set_for_class_failure (error, base_class);
return NULL;
}
MonoGenericContext inflated_method_ctx;
memset (&inflated_method_ctx, 0, sizeof (inflated_method_ctx));
inflated_method_ctx.class_inst = NULL;
inflated_method_ctx.method_inst = NULL;
gboolean inflated_generic_method = FALSE;
if (method->is_inflated) {
MonoGenericContext *method_ctx = mono_method_get_context (method);
/* If method is an instantiation of a generic method definition, ie
* class H<T> { void M<U> (...) { ... } }
* and method is H<C>.M<D>
* we will get at the end a refined HSubclass<...>.M<U> and we will need to re-instantiate it with D.
* to get HSubclass<...>.M<D>
*
*/
if (method_ctx->method_inst != NULL) {
inflated_generic_method = TRUE;
inflated_method_ctx.method_inst = method_ctx->method_inst;
}
}
int vtable_slot = 0;
if (!MONO_CLASS_IS_INTERFACE_INTERNAL (base_class)) {
/*if the base class isn't an interface and the method isn't
* virtual, there's nothing to do, we're already on the method
* we want to call. */
if ((method->flags & METHOD_ATTRIBUTE_VIRTUAL) == 0)
return method;
/* if this isn't an interface method, get the vtable slot and
* find the corresponding method in the constrained class,
* which is a subclass of the base class. */
vtable_slot = mono_method_get_vtable_index (method);
mono_class_setup_vtable (constrained_class);
if (mono_class_has_failure (constrained_class)) {
mono_error_set_for_class_failure (error, constrained_class);
return NULL;
}
} else {
if ((method->flags & METHOD_ATTRIBUTE_VIRTUAL) == 0)
return method;
mono_class_setup_vtable (constrained_class);
if (mono_class_has_failure (constrained_class)) {
mono_error_set_for_class_failure (error, constrained_class);
return NULL;
}
/* Get the slot of the method in the interface. Then get the
* interface base in constrained_class */
int itf_slot = mono_method_get_vtable_index (method);
g_assert (itf_slot >= 0);
gboolean variant = FALSE;
int itf_base = mono_class_interface_offset_with_variance (constrained_class, base_class, &variant);
vtable_slot = itf_slot + itf_base;
}
g_assert (vtable_slot >= 0);
MonoMethod *res = mono_class_get_vtable_entry (constrained_class, vtable_slot);
if (res == NULL && mono_class_is_abstract (constrained_class) ) {
/* Constraining class is abstract, there may not be a refined method. */
return method;
}
g_assert (res != NULL);
if (inflated_generic_method) {
g_assert (res->is_generic || res->is_inflated);
res = mono_class_inflate_generic_method_checked (res, &inflated_method_ctx, error);
return_val_if_nok (error, NULL);
}
return res;
}
MonoMethod *
mono_get_method_constrained_with_method (MonoImage *image, MonoMethod *method, MonoClass *constrained_class,
MonoGenericContext *context, MonoError *error)
{
g_assert (method);
return get_method_constrained (image, method, constrained_class, context, error);
}
/**
* mono_get_method_constrained:
* This is used when JITing the <code>constrained.</code> opcode.
* \returns The contrained method, which has been inflated
* as the function return value; and the original CIL-stream method as
* declared in \p cil_method. The latter is used for verification.
*/
MonoMethod *
mono_get_method_constrained (MonoImage *image, guint32 token, MonoClass *constrained_class,
MonoGenericContext *context, MonoMethod **cil_method)
{
ERROR_DECL (error);
MonoMethod *result = mono_get_method_constrained_checked (image, token, constrained_class, context, cil_method, error);
mono_error_cleanup (error);
return result;
}
MonoMethod *
mono_get_method_constrained_checked (MonoImage *image, guint32 token, MonoClass *constrained_class, MonoGenericContext *context, MonoMethod **cil_method, MonoError *error)
{
error_init (error);
*cil_method = mono_get_method_checked (image, token, NULL, context, error);
if (!*cil_method)
return NULL;
return get_method_constrained (image, *cil_method, constrained_class, context, error);
}
/**
* mono_free_method:
*/
void
mono_free_method (MonoMethod *method)
{
if (!method)
return;
MONO_PROFILER_RAISE (method_free, (method));
/* FIXME: This hack will go away when the profiler will support freeing methods */
if (G_UNLIKELY (mono_profiler_installed ()))
return;
if (method->signature) {
/*
* FIXME: This causes crashes because the types inside signatures and
* locals are shared.
*/
/* mono_metadata_free_method_signature (method->signature); */
/* g_free (method->signature); */
}
if (method_is_dynamic (method)) {
MonoMethodWrapper *mw = (MonoMethodWrapper*)method;
int i;
mono_marshal_free_dynamic_wrappers (method);
mono_image_property_remove (m_class_get_image (method->klass), method);
g_free ((char*)method->name);
if (mw->header) {
g_free ((char*)mw->header->code);
for (i = 0; i < mw->header->num_locals; ++i)
g_free (mw->header->locals [i]);
g_free (mw->header->clauses);
g_free (mw->header);
}
g_free (mw->method_data);
g_free (method->signature);
g_free (method);
}
}
/**
* mono_method_get_param_names:
*/
void
mono_method_get_param_names (MonoMethod *method, const char **names)
{
int i, lastp;
MonoClass *klass;
MonoTableInfo *methodt;
MonoTableInfo *paramt;
MonoMethodSignature *signature;
guint32 idx;
if (method->is_inflated)
method = ((MonoMethodInflated *) method)->declaring;
signature = mono_method_signature_internal (method);
/*FIXME this check is somewhat redundant since the caller usally will have to get the signature to figure out the
number of arguments and allocate a properly sized array. */
if (signature == NULL)
return;
if (!signature->param_count)
return;
for (i = 0; i < signature->param_count; ++i)
names [i] = "";
klass = method->klass;
if (m_class_get_rank (klass))
return;
mono_class_init_internal (klass);
MonoImage *klass_image = m_class_get_image (klass);
if (image_is_dynamic (klass_image)) {
MonoReflectionMethodAux *method_aux =
(MonoReflectionMethodAux *)g_hash_table_lookup (
((MonoDynamicImage*)m_class_get_image (method->klass))->method_aux_hash, method);
if (method_aux && method_aux->param_names) {
for (i = 0; i < mono_method_signature_internal (method)->param_count; ++i)
if (method_aux->param_names [i + 1])
names [i] = method_aux->param_names [i + 1];
}
return;
}
if (method->wrapper_type) {
char **pnames = NULL;
mono_image_lock (klass_image);
if (klass_image->wrapper_param_names)
pnames = (char **)g_hash_table_lookup (klass_image->wrapper_param_names, method);
mono_image_unlock (klass_image);
if (pnames) {
for (i = 0; i < signature->param_count; ++i)
names [i] = pnames [i];
}
return;
}
methodt = &klass_image->tables [MONO_TABLE_METHOD];
paramt = &klass_image->tables [MONO_TABLE_PARAM];
idx = mono_method_get_index (method);
if (idx > 0) {
guint32 cols [MONO_PARAM_SIZE];
guint param_index;
param_index = mono_metadata_decode_row_col (methodt, idx - 1, MONO_METHOD_PARAMLIST);
if (idx < table_info_get_rows (methodt))
lastp = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
else
lastp = table_info_get_rows (paramt) + 1;
for (i = param_index; i < lastp; ++i) {
mono_metadata_decode_row (paramt, i -1, cols, MONO_PARAM_SIZE);
if (cols [MONO_PARAM_SEQUENCE] && cols [MONO_PARAM_SEQUENCE] <= signature->param_count) /* skip return param spec and bounds check*/
names [cols [MONO_PARAM_SEQUENCE] - 1] = mono_metadata_string_heap (klass_image, cols [MONO_PARAM_NAME]);
}
}
}
/**
* mono_method_get_param_token:
*/
guint32
mono_method_get_param_token (MonoMethod *method, int index)
{
MonoClass *klass = method->klass;
MonoTableInfo *methodt;
guint32 idx;
mono_class_init_internal (klass);
MonoImage *klass_image = m_class_get_image (klass);
g_assert (!image_is_dynamic (klass_image));
methodt = &klass_image->tables [MONO_TABLE_METHOD];
idx = mono_method_get_index (method);
if (idx > 0) {
guint param_index = mono_metadata_decode_row_col (methodt, idx - 1, MONO_METHOD_PARAMLIST);
if (index == -1)
/* Return value */
return mono_metadata_make_token (MONO_TABLE_PARAM, 0);
else
return mono_metadata_make_token (MONO_TABLE_PARAM, param_index + index);
}
return 0;
}
/**
* mono_method_get_marshal_info:
*/
void
mono_method_get_marshal_info (MonoMethod *method, MonoMarshalSpec **mspecs)
{
int i, lastp;
MonoClass *klass = method->klass;
MonoTableInfo *methodt;
MonoTableInfo *paramt;
MonoMethodSignature *signature;
guint32 idx;
signature = mono_method_signature_internal (method);
g_assert (signature); /*FIXME there is no way to signal error from this function*/
for (i = 0; i < signature->param_count + 1; ++i)
mspecs [i] = NULL;
if (image_is_dynamic (m_class_get_image (method->klass))) {
MonoReflectionMethodAux *method_aux =
(MonoReflectionMethodAux *)g_hash_table_lookup (
((MonoDynamicImage*)m_class_get_image (method->klass))->method_aux_hash, method);
if (method_aux && method_aux->param_marshall) {
MonoMarshalSpec **dyn_specs = method_aux->param_marshall;
for (i = 0; i < signature->param_count + 1; ++i) {
if (dyn_specs [i]) {
mspecs [i] = g_new0 (MonoMarshalSpec, 1);
memcpy (mspecs [i], dyn_specs [i], sizeof (MonoMarshalSpec));
if (mspecs [i]->native == MONO_NATIVE_CUSTOM) {
mspecs [i]->data.custom_data.custom_name = g_strdup (dyn_specs [i]->data.custom_data.custom_name);
mspecs [i]->data.custom_data.cookie = g_strdup (dyn_specs [i]->data.custom_data.cookie);
}
}
}
}
return;
}
/* dynamic method added to non-dynamic image */
if (method->dynamic)
return;
mono_class_init_internal (klass);
MonoImage *klass_image = m_class_get_image (klass);
methodt = &klass_image->tables [MONO_TABLE_METHOD];
paramt = &klass_image->tables [MONO_TABLE_PARAM];
idx = mono_method_get_index (method);
if (idx > 0) {
guint32 cols [MONO_PARAM_SIZE];
guint param_index = mono_metadata_decode_row_col (methodt, idx - 1, MONO_METHOD_PARAMLIST);
if (idx < table_info_get_rows (methodt))
lastp = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
else
lastp = table_info_get_rows (paramt) + 1;
for (i = param_index; i < lastp; ++i) {
mono_metadata_decode_row (paramt, i -1, cols, MONO_PARAM_SIZE);
if (cols [MONO_PARAM_FLAGS] & PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL && cols [MONO_PARAM_SEQUENCE] <= signature->param_count) {
const char *tp;
tp = mono_metadata_get_marshal_info (klass_image, i - 1, FALSE);
g_assert (tp);
mspecs [cols [MONO_PARAM_SEQUENCE]]= mono_metadata_parse_marshal_spec (klass_image, tp);
}
}
return;
}
}
/**
* mono_method_has_marshal_info:
*/
gboolean
mono_method_has_marshal_info (MonoMethod *method)
{
int i, lastp;
MonoClass *klass = method->klass;
MonoTableInfo *methodt;
MonoTableInfo *paramt;
guint32 idx;
if (image_is_dynamic (m_class_get_image (method->klass))) {
MonoReflectionMethodAux *method_aux =
(MonoReflectionMethodAux *)g_hash_table_lookup (
((MonoDynamicImage*)m_class_get_image (method->klass))->method_aux_hash, method);
MonoMarshalSpec **dyn_specs = method_aux->param_marshall;
if (dyn_specs) {
for (i = 0; i < mono_method_signature_internal (method)->param_count + 1; ++i)
if (dyn_specs [i])
return TRUE;
}
return FALSE;
}
mono_class_init_internal (klass);
methodt = &m_class_get_image (klass)->tables [MONO_TABLE_METHOD];
paramt = &m_class_get_image (klass)->tables [MONO_TABLE_PARAM];
idx = mono_method_get_index (method);
if (idx > 0) {
guint32 cols [MONO_PARAM_SIZE];
guint param_index = mono_metadata_decode_row_col (methodt, idx - 1, MONO_METHOD_PARAMLIST);
if (idx + 1 < table_info_get_rows (methodt))
lastp = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
else
lastp = table_info_get_rows (paramt) + 1;
for (i = param_index; i < lastp; ++i) {
mono_metadata_decode_row (paramt, i -1, cols, MONO_PARAM_SIZE);
if (cols [MONO_PARAM_FLAGS] & PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL)
return TRUE;
}
return FALSE;
}
return FALSE;
}
gpointer
mono_method_get_wrapper_data (MonoMethod *method, guint32 id)
{
void **data;
g_assert (method != NULL);
g_assert (method->wrapper_type != MONO_WRAPPER_NONE);
data = (void **)((MonoMethodWrapper *)method)->method_data;
g_assert (data != NULL);
g_assert (id <= GPOINTER_TO_UINT (*data));
return data [id];
}
typedef struct {
MonoStackWalk func;
gpointer user_data;
} StackWalkUserData;
static gboolean
stack_walk_adapter (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer data)
{
StackWalkUserData *d = (StackWalkUserData *)data;
switch (frame->type) {
case FRAME_TYPE_DEBUGGER_INVOKE:
case FRAME_TYPE_MANAGED_TO_NATIVE:
case FRAME_TYPE_TRAMPOLINE:
case FRAME_TYPE_INTERP_TO_MANAGED:
case FRAME_TYPE_INTERP_TO_MANAGED_WITH_CTX:
case FRAME_TYPE_INTERP_ENTRY:
case FRAME_TYPE_JIT_ENTRY:
return FALSE;
case FRAME_TYPE_MANAGED:
case FRAME_TYPE_INTERP:
case FRAME_TYPE_IL_STATE:
g_assert (frame->ji);
return d->func (frame->actual_method, frame->native_offset, frame->il_offset, frame->managed, d->user_data);
break;
default:
g_assert_not_reached ();
return FALSE;
}
}
void
mono_stack_walk (MonoStackWalk func, gpointer user_data)
{
StackWalkUserData ud = { func, user_data };
mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (stack_walk_adapter, NULL, MONO_UNWIND_LOOKUP_ALL, &ud);
}
/**
* mono_stack_walk_no_il:
*/
void
mono_stack_walk_no_il (MonoStackWalk func, gpointer user_data)
{
StackWalkUserData ud = { func, user_data };
mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (stack_walk_adapter, NULL, MONO_UNWIND_DEFAULT, &ud);
}
typedef struct {
MonoStackWalkAsyncSafe func;
gpointer user_data;
} AsyncStackWalkUserData;
static gboolean
async_stack_walk_adapter (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer data)
{
AsyncStackWalkUserData *d = (AsyncStackWalkUserData *)data;
switch (frame->type) {
case FRAME_TYPE_DEBUGGER_INVOKE:
case FRAME_TYPE_MANAGED_TO_NATIVE:
case FRAME_TYPE_TRAMPOLINE:
case FRAME_TYPE_INTERP_TO_MANAGED:
case FRAME_TYPE_INTERP_TO_MANAGED_WITH_CTX:
return FALSE;
case FRAME_TYPE_MANAGED:
case FRAME_TYPE_INTERP:
if (!frame->ji)
return FALSE;
MonoMethod *method;
method = frame->ji->async ? NULL : frame->actual_method;
return d->func (method, mono_get_root_domain (), frame->ji->code_start, frame->native_offset, d->user_data);
default:
g_assert_not_reached ();
return FALSE;
}
}
/**
* mono_stack_walk_async_safe:
* Async safe version callable from signal handlers.
*/
void
mono_stack_walk_async_safe (MonoStackWalkAsyncSafe func, void *initial_sig_context, void *user_data)
{
MonoContext ctx;
AsyncStackWalkUserData ud = { func, user_data };
mono_sigctx_to_monoctx (initial_sig_context, &ctx);
mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (async_stack_walk_adapter, &ctx, MONO_UNWIND_SIGNAL_SAFE, &ud);
}
static gboolean
last_managed (MonoMethod *m, gint no, gint ilo, gboolean managed, gpointer data)
{
MonoMethod **dest = (MonoMethod **)data;
*dest = m;
/*g_print ("In %s::%s [%d] [%d]\n", m->klass->name, m->name, no, ilo);*/
return managed;
}
/**
* mono_method_get_last_managed:
*/
MonoMethod*
mono_method_get_last_managed (void)
{
MonoMethod *m = NULL;
mono_stack_walk_no_il (last_managed, &m);
return m;
}
/**
* mono_method_signature_checked_slow:
*
* Return the signature of the method M. On failure, returns NULL, and ERR is set.
* Call mono_method_signature_checked instead.
*/
MonoMethodSignature*
mono_method_signature_checked_slow (MonoMethod *m, MonoError *error)
{
int idx;
MonoImage* img;
const char *sig;
gboolean can_cache_signature;
MonoGenericContainer *container;
MonoMethodSignature *signature = NULL, *sig2;
guint32 sig_offset;
/* We need memory barriers below because of the double-checked locking pattern */
error_init (error);
if (m->signature)
return m->signature;
img = m_class_get_image (m->klass);
if (m->is_inflated) {
MonoMethodInflated *imethod = (MonoMethodInflated *) m;
/* the lock is recursive */
signature = mono_method_signature_internal (imethod->declaring);
signature = inflate_generic_signature_checked (m_class_get_image (imethod->declaring->klass), signature, mono_method_get_context (m), error);
if (!is_ok (error))
return NULL;
mono_atomic_fetch_add_i32 (&inflated_signatures_size, mono_metadata_signature_size (signature));
mono_image_lock (img);
mono_memory_barrier ();
if (!m->signature)
m->signature = signature;
mono_image_unlock (img);
return m->signature;
}
g_assert (mono_metadata_token_table (m->token) == MONO_TABLE_METHOD);
idx = mono_metadata_token_index (m->token);
sig = mono_metadata_blob_heap (img, sig_offset = mono_metadata_decode_row_col (&img->tables [MONO_TABLE_METHOD], idx - 1, MONO_METHOD_SIGNATURE));
g_assert (!mono_class_is_ginst (m->klass));
container = mono_method_get_generic_container (m);
if (!container)
container = mono_class_try_get_generic_container (m->klass);
/* Generic signatures depend on the container so they cannot be cached */
/* icall/pinvoke signatures cannot be cached cause we modify them below */
can_cache_signature = !(m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) && !(m->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) && !container;
/* If the method has parameter attributes, that can modify the signature */
if (mono_metadata_method_has_param_attrs (img, idx))
can_cache_signature = FALSE;
if (can_cache_signature) {
mono_image_lock (img);
signature = (MonoMethodSignature *)g_hash_table_lookup (img->method_signatures, sig);
mono_image_unlock (img);
}
if (!signature) {
const char *sig_body;
/* size = */ mono_metadata_decode_blob_size (sig, &sig_body);
signature = mono_metadata_parse_method_signature_full (img, container, idx, sig_body, NULL, error);
if (!signature)
return NULL;
if (can_cache_signature) {
mono_image_lock (img);
sig2 = (MonoMethodSignature *)g_hash_table_lookup (img->method_signatures, sig);
if (!sig2)
g_hash_table_insert (img->method_signatures, (gpointer)sig, signature);
mono_image_unlock (img);
}
mono_atomic_fetch_add_i32 (&signatures_size, mono_metadata_signature_size (signature));
}
/* Verify metadata consistency */
if (signature->generic_param_count) {
if (!container || !container->is_method) {
mono_error_set_method_missing (error, m->klass, m->name, signature, "Signature claims method has generic parameters, but generic_params table says it doesn't for method 0x%08x from image %s", idx, img->name);
return NULL;
}
if (container->type_argc != signature->generic_param_count) {
mono_error_set_method_missing (error, m->klass, m->name, signature, "Inconsistent generic parameter count. Signature says %d, generic_params table says %d for method 0x%08x from image %s", signature->generic_param_count, container->type_argc, idx, img->name);
return NULL;
}
} else if (container && container->is_method && container->type_argc) {
mono_error_set_method_missing (error, m->klass, m->name, signature, "generic_params table claims method has generic parameters, but signature says it doesn't for method 0x%08x from image %s", idx, img->name);
return NULL;
}
if (m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) {
signature->pinvoke = 1;
#ifdef TARGET_WIN32
/*
* On Windows the default pinvoke calling convention is STDCALL but
* we need CDECL since this is actually an icall.
*/
signature->call_convention = MONO_CALL_C;
#endif
} else if (m->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
MonoCallConvention conv = (MonoCallConvention)0;
MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)m;
signature->pinvoke = 1;
switch (piinfo->piflags & PINVOKE_ATTRIBUTE_CALL_CONV_MASK) {
case 0: /* no call conv, so using default */
case PINVOKE_ATTRIBUTE_CALL_CONV_WINAPI:
conv = MONO_CALL_DEFAULT;
break;
case PINVOKE_ATTRIBUTE_CALL_CONV_CDECL:
conv = MONO_CALL_C;
break;
case PINVOKE_ATTRIBUTE_CALL_CONV_STDCALL:
conv = MONO_CALL_STDCALL;
break;
case PINVOKE_ATTRIBUTE_CALL_CONV_THISCALL:
conv = MONO_CALL_THISCALL;
break;
case PINVOKE_ATTRIBUTE_CALL_CONV_FASTCALL:
conv = MONO_CALL_FASTCALL;
break;
case PINVOKE_ATTRIBUTE_CALL_CONV_GENERIC:
case PINVOKE_ATTRIBUTE_CALL_CONV_GENERICINST:
default: {
mono_error_set_method_missing (error, m->klass, m->name, signature, "Unsupported calling convention : 0x%04x for method 0x%08x from image %s", piinfo->piflags, idx, img->name);
}
return NULL;
}
signature->call_convention = conv;
}
mono_image_lock (img);
mono_memory_barrier ();
if (!m->signature)
m->signature = signature;
mono_image_unlock (img);
return m->signature;
}
/**
* mono_method_signature_internal_slow:
* \returns the signature of the method \p m. On failure, returns NULL.
* Call mono_method_signature_internal instead.
*/
MonoMethodSignature*
mono_method_signature_internal_slow (MonoMethod *m)
{
ERROR_DECL (error);
MonoMethodSignature *sig = mono_method_signature_checked (m, error);
if (sig)
return sig;
char *type_name = mono_type_get_full_name (m->klass);
g_warning ("Could not load signature of %s:%s due to: %s", type_name, m->name, mono_error_get_message (error));
g_free (type_name);
mono_error_cleanup (error);
return NULL;
}
/**
* mono_method_signature:
* \returns the signature of the method \p m. On failure, returns NULL.
*/
MonoMethodSignature*
mono_method_signature (MonoMethod *m)
{
MonoMethodSignature *sig;
MONO_ENTER_GC_UNSAFE;
sig = mono_method_signature_internal (m);
MONO_EXIT_GC_UNSAFE;
return sig;
}
/**
* mono_method_get_name:
*/
const char*
mono_method_get_name (MonoMethod *method)
{
return method->name;
}
/**
* mono_method_get_class:
*/
MonoClass*
mono_method_get_class (MonoMethod *method)
{
return method->klass;
}
/**
* mono_method_get_token:
*/
guint32
mono_method_get_token (MonoMethod *method)
{
return method->token;
}
gboolean
mono_method_has_no_body (MonoMethod *method)
{
return ((method->flags & METHOD_ATTRIBUTE_ABSTRACT) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL));
}
// FIXME Replace all internal callers of mono_method_get_header_checked with
// mono_method_get_header_internal; the difference is in error initialization.
MonoMethodHeader*
mono_method_get_header_internal (MonoMethod *method, MonoError *error)
{
int idx;
guint32 rva;
MonoImage* img;
gpointer loc = NULL;
MonoGenericContainer *container;
error_init (error);
img = m_class_get_image (method->klass);
// FIXME: for internal callers maybe it makes sense to do this check at the call site, not
// here?
if (mono_method_has_no_body (method)) {
if (mono_method_get_is_reabstracted (method))
mono_error_set_generic_error (error, "System", "EntryPointNotFoundException", "%s", method->name);
else
mono_error_set_bad_image (error, img, "Method has no body");
return NULL;
}
if (method->is_inflated) {
MonoMethodInflated *imethod = (MonoMethodInflated *) method;
MonoMethodHeader *header, *iheader;
header = mono_method_get_header_checked (imethod->declaring, error);
if (!header)
return NULL;
iheader = inflate_generic_header (header, mono_method_get_context (method), error);
mono_metadata_free_mh (header);
if (!iheader) {
return NULL;
}
return iheader;
}
if (method->wrapper_type != MONO_WRAPPER_NONE || method->sre_method) {
MonoMethodWrapper *mw = (MonoMethodWrapper *)method;
g_assert (mw->header);
return mw->header;
}
/*
* We don't need locks here: the new header is allocated from malloc memory
* and is not stored anywhere in the runtime, the user needs to free it.
*/
g_assert (mono_metadata_token_table (method->token) == MONO_TABLE_METHOD);
idx = mono_metadata_token_index (method->token);
if (G_UNLIKELY (img->has_updates))
loc = mono_metadata_update_get_updated_method_rva (img, idx);
if (!loc) {
rva = mono_metadata_decode_row_col (&img->tables [MONO_TABLE_METHOD], idx - 1, MONO_METHOD_RVA);
loc = mono_image_rva_map (img, rva);
}
if (!loc) {
mono_error_set_bad_image (error, img, "Method has zero rva");
return NULL;
}
/*
* When parsing the types of local variables, we must pass any container available
* to ensure that both VAR and MVAR will get the right owner.
*/
container = mono_method_get_generic_container (method);
if (!container)
container = mono_class_try_get_generic_container (method->klass);
return mono_metadata_parse_mh_full (img, container, (const char *)loc, error);
}
MonoMethodHeader*
mono_method_get_header_checked (MonoMethod *method, MonoError *error)
// Public function that must initialize MonoError for compatibility.
{
MONO_API_ERROR_INIT (error);
return mono_method_get_header_internal (method, error);
}
/**
* mono_method_get_header:
*/
MonoMethodHeader*
mono_method_get_header (MonoMethod *method)
{
ERROR_DECL (error);
MonoMethodHeader *header = mono_method_get_header_checked (method, error);
mono_error_cleanup (error);
return header;
}
/**
* mono_method_get_flags:
*/
guint32
mono_method_get_flags (MonoMethod *method, guint32 *iflags)
{
if (iflags)
*iflags = method->iflags;
return method->flags;
}
/**
* mono_method_get_index:
* Find the method index in the metadata \c MethodDef table.
*/
guint32
mono_method_get_index (MonoMethod *method)
{
MonoClass *klass = method->klass;
int i;
if (m_class_get_rank (klass))
/* constructed array methods are not in the MethodDef table */
return 0;
if (method->token)
return mono_metadata_token_index (method->token);
mono_class_setup_methods (klass);
if (mono_class_has_failure (klass))
return 0;
int first_idx = mono_class_get_first_method_idx (klass);
int mcount = mono_class_get_method_count (klass);
MonoMethod **klass_methods = m_class_get_methods (klass);
for (i = 0; i < mcount; ++i) {
if (method == klass_methods [i]) {
if (m_class_get_image (klass)->uncompressed_metadata)
return mono_metadata_translate_token_index (m_class_get_image (klass), MONO_TABLE_METHOD, first_idx + i + 1);
else
return first_idx + i + 1;
}
}
return 0;
}
| /**
* \file
* Image Loader
*
* Authors:
* Paolo Molaro ([email protected])
* Miguel de Icaza ([email protected])
* Patrik Torstensson ([email protected])
*
* Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
* Copyright 2004-2009 Novell, Inc (http://www.novell.com)
* Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
*
* This file is used by the interpreter and the JIT engine to locate
* assemblies. Used to load AssemblyRef and later to resolve various
* kinds of `Refs'.
*
* TODO:
* This should keep track of the assembly versions that we are loading.
*
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#include <glib.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <mono/metadata/metadata.h>
#include <mono/metadata/image.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/tokentype.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/metadata-update.h>
#include <mono/metadata/loader.h>
#include <mono/metadata/loader-internals.h>
#include <mono/metadata/class-init.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/reflection.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/marshal.h>
#include <mono/metadata/lock-tracer.h>
#include <mono/metadata/exception-internals.h>
#include <mono/metadata/jit-info.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-dl.h>
#include <mono/utils/mono-membar.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/mono-tls.h>
#include <mono/utils/mono-path.h>
/*
* This lock protects the hash tables inside MonoImage used by the metadata
* loading functions in class.c and loader.c.
*
* See domain-internals.h for locking policy in combination with the
* domain lock.
*/
static MonoCoopMutex loader_mutex;
static mono_mutex_t global_loader_data_mutex;
static gboolean loader_lock_inited;
static gboolean loader_lock_track_ownership;
/*
* This TLS variable holds how many times the current thread has acquired the loader
* lock.
*/
static MonoNativeTlsKey loader_lock_nest_id;
MonoDefaults mono_defaults;
/* Statistics */
static gint32 inflated_signatures_size;
static gint32 memberref_sig_cache_size;
static gint32 methods_size;
static gint32 signatures_size;
void
mono_loader_init ()
{
static gboolean inited;
// FIXME: potential race
if (!inited) {
mono_coop_mutex_init_recursive (&loader_mutex);
mono_os_mutex_init_recursive (&global_loader_data_mutex);
loader_lock_inited = TRUE;
mono_global_loader_cache_init ();
mono_native_tls_alloc (&loader_lock_nest_id, NULL);
mono_counters_init ();
mono_counters_register ("Inflated signatures size",
MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &inflated_signatures_size);
mono_counters_register ("Memberref signature cache size",
MONO_COUNTER_METADATA | MONO_COUNTER_INT, &memberref_sig_cache_size);
mono_counters_register ("MonoMethod size",
MONO_COUNTER_METADATA | MONO_COUNTER_INT, &methods_size);
mono_counters_register ("MonoMethodSignature size",
MONO_COUNTER_METADATA | MONO_COUNTER_INT, &signatures_size);
inited = TRUE;
}
}
MonoDefaults *
mono_get_defaults (void)
{
return &mono_defaults;
}
void
mono_global_loader_data_lock (void)
{
mono_locks_os_acquire (&global_loader_data_mutex, LoaderGlobalDataLock);
}
void
mono_global_loader_data_unlock (void)
{
mono_locks_os_release (&global_loader_data_mutex, LoaderGlobalDataLock);
}
/**
* mono_loader_lock:
*
* See \c docs/thread-safety.txt for the locking strategy.
*/
void
mono_loader_lock (void)
{
mono_locks_coop_acquire (&loader_mutex, LoaderLock);
if (G_UNLIKELY (loader_lock_track_ownership)) {
mono_native_tls_set_value (loader_lock_nest_id, GUINT_TO_POINTER (GPOINTER_TO_UINT (mono_native_tls_get_value (loader_lock_nest_id)) + 1));
}
}
/**
* mono_loader_unlock:
*/
void
mono_loader_unlock (void)
{
mono_locks_coop_release (&loader_mutex, LoaderLock);
if (G_UNLIKELY (loader_lock_track_ownership)) {
mono_native_tls_set_value (loader_lock_nest_id, GUINT_TO_POINTER (GPOINTER_TO_UINT (mono_native_tls_get_value (loader_lock_nest_id)) - 1));
}
}
/*
* mono_loader_lock_track_ownership:
*
* Set whenever the runtime should track ownership of the loader lock. If set to TRUE,
* the mono_loader_lock_is_owned_by_self () can be called to query whenever the current
* thread owns the loader lock.
*/
void
mono_loader_lock_track_ownership (gboolean track)
{
loader_lock_track_ownership = track;
}
/*
* mono_loader_lock_is_owned_by_self:
*
* Return whenever the current thread owns the loader lock.
* This is useful to avoid blocking operations while holding the loader lock.
*/
gboolean
mono_loader_lock_is_owned_by_self (void)
{
g_assert (loader_lock_track_ownership);
return GPOINTER_TO_UINT (mono_native_tls_get_value (loader_lock_nest_id)) > 0;
}
/*
* mono_loader_lock_if_inited:
*
* Acquire the loader lock if it has been initialized, no-op otherwise. This can
* be used in runtime initialization code which can be executed before mono_loader_init ().
*/
void
mono_loader_lock_if_inited (void)
{
if (loader_lock_inited)
mono_loader_lock ();
}
void
mono_loader_unlock_if_inited (void)
{
if (loader_lock_inited)
mono_loader_unlock ();
}
/*
* find_cached_memberref_sig:
*
* Return a cached copy of the memberref signature identified by SIG_IDX.
* We use a gpointer since the cache stores both MonoTypes and MonoMethodSignatures.
* A cache is needed since the type/signature parsing routines allocate everything
* from a mempool, so without a cache, multiple requests for the same signature would
* lead to unbounded memory growth. For normal methods/fields this is not a problem
* since the resulting methods/fields are cached, but inflated methods/fields cannot
* be cached.
* LOCKING: Acquires the loader lock.
*/
static gpointer
find_cached_memberref_sig (MonoImage *image, guint32 sig_idx)
{
gpointer res;
mono_image_lock (image);
res = g_hash_table_lookup (image->memberref_signatures, GUINT_TO_POINTER (sig_idx));
mono_image_unlock (image);
return res;
}
static gpointer
cache_memberref_sig (MonoImage *image, guint32 sig_idx, gpointer sig)
{
gpointer prev_sig;
mono_image_lock (image);
prev_sig = g_hash_table_lookup (image->memberref_signatures, GUINT_TO_POINTER (sig_idx));
if (prev_sig) {
/* Somebody got in before us */
sig = prev_sig;
}
else {
g_hash_table_insert (image->memberref_signatures, GUINT_TO_POINTER (sig_idx), sig);
/* An approximation based on glib 2.18 */
mono_atomic_fetch_add_i32 (&memberref_sig_cache_size, sizeof (gpointer) * 4);
}
mono_image_unlock (image);
return sig;
}
static MonoClassField*
field_from_memberref (MonoImage *image, guint32 token, MonoClass **retklass,
MonoGenericContext *context, MonoError *error)
{
MonoClass *klass = NULL;
MonoClassField *field;
MonoTableInfo *tables = image->tables;
MonoType *sig_type;
guint32 cols[6];
guint32 nindex, class_index;
const char *fname;
const char *ptr;
guint32 idx = mono_metadata_token_index (token);
error_init (error);
mono_metadata_decode_row (&tables [MONO_TABLE_MEMBERREF], idx-1, cols, MONO_MEMBERREF_SIZE);
nindex = cols [MONO_MEMBERREF_CLASS] >> MONO_MEMBERREF_PARENT_BITS;
class_index = cols [MONO_MEMBERREF_CLASS] & MONO_MEMBERREF_PARENT_MASK;
fname = mono_metadata_string_heap (image, cols [MONO_MEMBERREF_NAME]);
switch (class_index) {
case MONO_MEMBERREF_PARENT_TYPEDEF:
klass = mono_class_get_checked (image, MONO_TOKEN_TYPE_DEF | nindex, error);
break;
case MONO_MEMBERREF_PARENT_TYPEREF:
klass = mono_class_from_typeref_checked (image, MONO_TOKEN_TYPE_REF | nindex, error);
break;
case MONO_MEMBERREF_PARENT_TYPESPEC:
klass = mono_class_get_and_inflate_typespec_checked (image, MONO_TOKEN_TYPE_SPEC | nindex, context, error);
break;
default:
mono_error_set_bad_image (error, image, "Bad field field '%u' signature 0x%08x", class_index, token);
}
if (!klass)
return NULL;
ptr = mono_metadata_blob_heap (image, cols [MONO_MEMBERREF_SIGNATURE]);
mono_metadata_decode_blob_size (ptr, &ptr);
/* we may want to check the signature here... */
if (*ptr++ != 0x6) {
mono_error_set_field_missing (error, klass, fname, NULL, "Bad field signature class token %08x field token %08x", class_index, token);
return NULL;
}
/* FIXME: This needs a cache, especially for generic instances, since
* we ask mono_metadata_parse_type_checked () to allocates everything from a mempool.
* FIXME part2, mono_metadata_parse_type_checked actually allows for a transient type instead.
* FIXME part3, transient types are not 100% transient, so we need to take care of that first.
*/
sig_type = (MonoType *)find_cached_memberref_sig (image, cols [MONO_MEMBERREF_SIGNATURE]);
if (!sig_type) {
ERROR_DECL (inner_error);
sig_type = mono_metadata_parse_type_checked (image, NULL, 0, FALSE, ptr, &ptr, inner_error);
if (sig_type == NULL) {
mono_error_set_field_missing (error, klass, fname, NULL, "Could not parse field signature %08x due to: %s", token, mono_error_get_message (inner_error));
mono_error_cleanup (inner_error);
return NULL;
}
sig_type = (MonoType *)cache_memberref_sig (image, cols [MONO_MEMBERREF_SIGNATURE], sig_type);
}
mono_class_init_internal (klass); /*FIXME is this really necessary?*/
if (retklass)
*retklass = klass;
field = mono_class_get_field_from_name_full (klass, fname, sig_type);
if (!field) {
mono_error_set_field_missing (error, klass, fname, sig_type, "Could not find field in class");
}
return field;
}
/**
* mono_field_from_token:
* \deprecated use the \c _checked variant
* Notes: runtime code MUST not use this function
*/
MonoClassField*
mono_field_from_token (MonoImage *image, guint32 token, MonoClass **retklass, MonoGenericContext *context)
{
ERROR_DECL (error);
MonoClassField *res = mono_field_from_token_checked (image, token, retklass, context, error);
mono_error_assert_ok (error);
return res;
}
MonoClassField*
mono_field_from_token_checked (MonoImage *image, guint32 token, MonoClass **retklass, MonoGenericContext *context, MonoError *error)
{
MonoClass *k;
guint32 type;
MonoClassField *field;
error_init (error);
if (image_is_dynamic (image)) {
MonoClassField *result;
MonoClass *handle_class;
*retklass = NULL;
ERROR_DECL (inner_error);
result = (MonoClassField *)mono_lookup_dynamic_token_class (image, token, TRUE, &handle_class, context, inner_error);
mono_error_cleanup (inner_error);
// This checks the memberref type as well
if (!result || handle_class != mono_defaults.fieldhandle_class) {
mono_error_set_bad_image (error, image, "Bad field token 0x%08x", token);
return NULL;
}
*retklass = m_field_get_parent (result);
return result;
}
if ((field = (MonoClassField *)mono_conc_hashtable_lookup (image->field_cache, GUINT_TO_POINTER (token)))) {
*retklass = m_field_get_parent (field);
return field;
}
if (mono_metadata_token_table (token) == MONO_TABLE_MEMBERREF) {
field = field_from_memberref (image, token, retklass, context, error);
} else {
type = mono_metadata_typedef_from_field (image, mono_metadata_token_index (token));
if (!type) {
mono_error_set_bad_image (error, image, "Invalid field token 0x%08x", token);
return NULL;
}
k = mono_class_get_checked (image, MONO_TOKEN_TYPE_DEF | type, error);
if (!k)
return NULL;
mono_class_init_internal (k);
if (retklass)
*retklass = k;
if (mono_class_has_failure (k)) {
ERROR_DECL (causedby_error);
mono_error_set_for_class_failure (causedby_error, k);
mono_error_set_bad_image (error, image, "Could not resolve field token 0x%08x, due to: %s", token, mono_error_get_message (causedby_error));
mono_error_cleanup (causedby_error);
} else {
field = mono_class_get_field (k, token);
if (!field) {
mono_error_set_bad_image (error, image, "Could not resolve field token 0x%08x", token);
}
}
}
MonoClass *field_parent = NULL;
if (field && ((field_parent = m_field_get_parent (field))) && !mono_class_is_ginst (field_parent) && !mono_class_is_gtd (field_parent)) {
mono_image_lock (image);
mono_conc_hashtable_insert (image->field_cache, GUINT_TO_POINTER (token), field);
mono_image_unlock (image);
}
return field;
}
static gboolean
mono_metadata_signature_vararg_match (MonoMethodSignature *sig1, MonoMethodSignature *sig2)
{
int i;
if (sig1->hasthis != sig2->hasthis ||
sig1->sentinelpos != sig2->sentinelpos)
return FALSE;
for (i = 0; i < sig1->sentinelpos; i++) {
MonoType *p1 = sig1->params[i];
MonoType *p2 = sig2->params[i];
/*if (p1->attrs != p2->attrs)
return FALSE;
*/
if (!mono_metadata_type_equal (p1, p2))
return FALSE;
}
if (!mono_metadata_type_equal (sig1->ret, sig2->ret))
return FALSE;
return TRUE;
}
static MonoMethod *
find_method_in_class (MonoClass *klass, const char *name, const char *qname, const char *fqname,
MonoMethodSignature *sig, MonoClass *from_class, MonoError *error)
{
int i;
/* FIXME: method refs from metadata-upate probably end up here */
/* Search directly in the metadata to avoid calling setup_methods () */
error_init (error);
MonoImage *klass_image = m_class_get_image (klass);
/* FIXME: !mono_class_is_ginst (from_class) condition causes test failures. */
if (m_class_get_type_token (klass) && !image_is_dynamic (klass_image) && !m_class_get_methods (klass) && !m_class_get_rank (klass) && klass == from_class && !mono_class_is_ginst (from_class)) {
int first_idx = mono_class_get_first_method_idx (klass);
int mcount = mono_class_get_method_count (klass);
for (i = 0; i < mcount; ++i) {
guint32 cols [MONO_METHOD_SIZE];
MonoMethod *method;
const char *m_name;
MonoMethodSignature *other_sig;
mono_metadata_decode_table_row (klass_image, MONO_TABLE_METHOD, first_idx + i, cols, MONO_METHOD_SIZE);
m_name = mono_metadata_string_heap (klass_image, cols [MONO_METHOD_NAME]);
if (!((fqname && !strcmp (m_name, fqname)) ||
(qname && !strcmp (m_name, qname)) ||
(name && !strcmp (m_name, name))))
continue;
method = mono_get_method_checked (klass_image, MONO_TOKEN_METHOD_DEF | (first_idx + i + 1), klass, NULL, error);
if (!is_ok (error)) //bail out if we hit a loader error
return NULL;
if (method) {
other_sig = mono_method_signature_checked (method, error);
if (!is_ok (error)) //bail out if we hit a loader error
return NULL;
if (other_sig && (sig->call_convention != MONO_CALL_VARARG) && mono_metadata_signature_equal (sig, other_sig))
return method;
}
}
}
mono_class_setup_methods (klass); /* FIXME don't swallow the error here. */
/*
We can't fail lookup of methods otherwise the runtime will fail with MissingMethodException instead of TypeLoadException.
See mono/tests/generic-type-load-exception.2.il
FIXME we should better report this error to the caller
*/
if (!m_class_get_methods (klass) || mono_class_has_failure (klass)) {
ERROR_DECL (cause_error);
mono_error_set_for_class_failure (cause_error, klass);
mono_error_set_type_load_class (error, klass, "Could not find method '%s' due to a type load error: %s", name, mono_error_get_message (cause_error));
mono_error_cleanup (cause_error);
return NULL;
}
int mcount = mono_class_get_method_count (klass);
MonoMethod **klass_methods = m_class_get_methods (klass);
for (i = 0; i < mcount; ++i) {
MonoMethod *m = klass_methods [i];
MonoMethodSignature *msig;
/* We must cope with failing to load some of the types. */
if (!m)
continue;
if (!((fqname && !strcmp (m->name, fqname)) ||
(qname && !strcmp (m->name, qname)) ||
(name && !strcmp (m->name, name))))
continue;
msig = mono_method_signature_checked (m, error);
if (!is_ok (error)) //bail out if we hit a loader error
return NULL;
if (!msig)
continue;
if (sig->call_convention == MONO_CALL_VARARG) {
if (mono_metadata_signature_vararg_match (sig, msig))
break;
} else {
if (mono_metadata_signature_equal (sig, msig))
break;
}
}
if (i < mcount)
return mono_class_get_method_by_index (from_class, i);
return NULL;
}
static MonoMethod *
find_method (MonoClass *in_class, MonoClass *ic, const char* name, MonoMethodSignature *sig, MonoClass *from_class, MonoError *error)
{
int i;
char *qname, *fqname, *class_name;
gboolean is_interface;
MonoMethod *result = NULL;
MonoClass *initial_class = in_class;
error_init (error);
is_interface = MONO_CLASS_IS_INTERFACE_INTERNAL (in_class);
if (ic) {
class_name = mono_type_get_name_full (m_class_get_byval_arg (ic), MONO_TYPE_NAME_FORMAT_IL);
qname = g_strconcat (class_name, ".", name, (const char*)NULL);
const char *ic_name_space = m_class_get_name_space (ic);
if (ic_name_space && ic_name_space [0])
fqname = g_strconcat (ic_name_space, ".", class_name, ".", name, (const char*)NULL);
else
fqname = NULL;
} else
class_name = qname = fqname = NULL;
while (in_class) {
g_assert (from_class);
result = find_method_in_class (in_class, name, qname, fqname, sig, from_class, error);
if (result || !is_ok (error))
goto out;
if (name [0] == '.' && (!strcmp (name, ".ctor") || !strcmp (name, ".cctor")))
break;
/*
* This happens when we fail to lazily load the interfaces of one of the types.
* On such case we can't just bail out since user code depends on us trying harder.
*/
if (m_class_get_interface_offsets_count (from_class) != m_class_get_interface_offsets_count (in_class)) {
in_class = m_class_get_parent (in_class);
from_class = m_class_get_parent (from_class);
continue;
}
int in_class_interface_offsets_count = m_class_get_interface_offsets_count (in_class);
MonoClass **in_class_interfaces_packed = m_class_get_interfaces_packed (in_class);
MonoClass **from_class_interfaces_packed = m_class_get_interfaces_packed (from_class);
for (i = 0; i < in_class_interface_offsets_count; i++) {
MonoClass *in_ic = in_class_interfaces_packed [i];
MonoClass *from_ic = from_class_interfaces_packed [i];
char *ic_qname, *ic_fqname, *ic_class_name;
ic_class_name = mono_type_get_name_full (m_class_get_byval_arg (in_ic), MONO_TYPE_NAME_FORMAT_IL);
ic_qname = g_strconcat (ic_class_name, ".", name, (const char*)NULL);
const char *in_ic_name_space = m_class_get_name_space (in_ic);
if (in_ic_name_space && in_ic_name_space [0])
ic_fqname = g_strconcat (in_ic_name_space, ".", ic_class_name, ".", name, (const char*)NULL);
else
ic_fqname = NULL;
result = find_method_in_class (in_ic, ic ? name : NULL, ic_qname, ic_fqname, sig, from_ic, error);
g_free (ic_class_name);
g_free (ic_fqname);
g_free (ic_qname);
if (result || !is_ok (error))
goto out;
}
in_class = m_class_get_parent (in_class);
from_class = m_class_get_parent (from_class);
}
g_assert (!in_class == !from_class);
if (is_interface)
result = find_method_in_class (mono_defaults.object_class, name, qname, fqname, sig, mono_defaults.object_class, error);
//we did not find the method
if (!result && is_ok (error))
mono_error_set_method_missing (error, initial_class, name, sig, NULL);
out:
g_free (class_name);
g_free (fqname);
g_free (qname);
return result;
}
static MonoMethodSignature*
inflate_generic_signature_checked (MonoImage *image, MonoMethodSignature *sig, MonoGenericContext *context, MonoError *error)
{
MonoMethodSignature *res;
gboolean is_open;
int i;
error_init (error);
if (!context)
return sig;
res = (MonoMethodSignature *)g_malloc0 (MONO_SIZEOF_METHOD_SIGNATURE + ((gint32)sig->param_count) * sizeof (MonoType*));
res->param_count = sig->param_count;
res->sentinelpos = -1;
res->ret = mono_class_inflate_generic_type_checked (sig->ret, context, error);
if (!is_ok (error))
goto fail;
is_open = mono_class_is_open_constructed_type (res->ret);
for (i = 0; i < sig->param_count; ++i) {
res->params [i] = mono_class_inflate_generic_type_checked (sig->params [i], context, error);
if (!is_ok (error))
goto fail;
if (!is_open)
is_open = mono_class_is_open_constructed_type (res->params [i]);
}
res->hasthis = sig->hasthis;
res->explicit_this = sig->explicit_this;
res->call_convention = sig->call_convention;
res->pinvoke = sig->pinvoke;
res->generic_param_count = sig->generic_param_count;
res->sentinelpos = sig->sentinelpos;
res->has_type_parameters = is_open;
res->is_inflated = 1;
return res;
fail:
if (res->ret)
mono_metadata_free_type (res->ret);
for (i = 0; i < sig->param_count; ++i) {
if (res->params [i])
mono_metadata_free_type (res->params [i]);
}
g_free (res);
return NULL;
}
/**
* mono_inflate_generic_signature:
*
* Inflate \p sig with \p context, and return a canonical copy. On error, set \p error, and return NULL.
*/
MonoMethodSignature*
mono_inflate_generic_signature (MonoMethodSignature *sig, MonoGenericContext *context, MonoError *error)
{
MonoMethodSignature *res, *cached;
res = inflate_generic_signature_checked (NULL, sig, context, error);
if (!is_ok (error))
return NULL;
cached = mono_metadata_get_inflated_signature (res, context);
if (cached != res)
mono_metadata_free_inflated_signature (res);
return cached;
}
static MonoMethodHeader*
inflate_generic_header (MonoMethodHeader *header, MonoGenericContext *context, MonoError *error)
{
size_t locals_size = sizeof (gpointer) * header->num_locals;
size_t clauses_size = header->num_clauses * sizeof (MonoExceptionClause);
size_t header_size = MONO_SIZEOF_METHOD_HEADER + locals_size + clauses_size;
MonoMethodHeader *res = (MonoMethodHeader *)g_malloc0 (header_size);
res->num_locals = header->num_locals;
res->clauses = (MonoExceptionClause *) &res->locals [res->num_locals] ;
memcpy (res->clauses, header->clauses, clauses_size);
res->code = header->code;
res->code_size = header->code_size;
res->max_stack = header->max_stack;
res->num_clauses = header->num_clauses;
res->init_locals = header->init_locals;
res->is_transient = TRUE;
error_init (error);
for (int i = 0; i < header->num_locals; ++i) {
res->locals [i] = mono_class_inflate_generic_type_checked (header->locals [i], context, error);
goto_if_nok (error, fail);
}
if (res->num_clauses) {
for (int i = 0; i < header->num_clauses; ++i) {
MonoExceptionClause *clause = &res->clauses [i];
if (clause->flags != MONO_EXCEPTION_CLAUSE_NONE)
continue;
clause->data.catch_class = mono_class_inflate_generic_class_checked (clause->data.catch_class, context, error);
goto_if_nok (error, fail);
}
}
return res;
fail:
g_free (res);
return NULL;
}
/**
* mono_method_get_signature_full:
* \p token is the method ref/def/spec token used in a \c call IL instruction.
* \deprecated use the \c _checked variant
* Notes: runtime code MUST not use this function
*/
MonoMethodSignature*
mono_method_get_signature_full (MonoMethod *method, MonoImage *image, guint32 token, MonoGenericContext *context)
{
ERROR_DECL (error);
MonoMethodSignature *res = mono_method_get_signature_checked (method, image, token, context, error);
mono_error_cleanup (error);
return res;
}
MonoMethodSignature*
mono_method_get_signature_checked (MonoMethod *method, MonoImage *image, guint32 token, MonoGenericContext *context, MonoError *error)
{
int table = mono_metadata_token_table (token);
int idx = mono_metadata_token_index (token);
int sig_idx;
guint32 cols [MONO_MEMBERREF_SIZE];
MonoMethodSignature *sig;
const char *ptr;
error_init (error);
/* !table is for wrappers: we should really assign their own token to them */
if (!table || table == MONO_TABLE_METHOD)
return mono_method_signature_checked (method, error);
if (table == MONO_TABLE_METHODSPEC) {
/* the verifier (do_invoke_method) will turn the NULL into a verifier error */
if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) || !method->is_inflated) {
mono_error_set_bad_image (error, image, "Method is a pinvoke or open generic");
return NULL;
}
return mono_method_signature_checked (method, error);
}
if (mono_class_is_ginst (method->klass))
return mono_method_signature_checked (method, error);
if (image_is_dynamic (image)) {
sig = mono_reflection_lookup_signature (image, method, token, error);
if (!sig)
return NULL;
} else {
mono_metadata_decode_row (&image->tables [MONO_TABLE_MEMBERREF], idx-1, cols, MONO_MEMBERREF_SIZE);
sig_idx = cols [MONO_MEMBERREF_SIGNATURE];
sig = (MonoMethodSignature *)find_cached_memberref_sig (image, sig_idx);
if (!sig) {
ptr = mono_metadata_blob_heap (image, sig_idx);
mono_metadata_decode_blob_size (ptr, &ptr);
sig = mono_metadata_parse_method_signature_full (image, NULL, 0, ptr, NULL, error);
if (!sig)
return NULL;
sig = (MonoMethodSignature *)cache_memberref_sig (image, sig_idx, sig);
}
}
if (context) {
MonoMethodSignature *cached;
/* This signature is not owned by a MonoMethod, so need to cache */
sig = inflate_generic_signature_checked (image, sig, context, error);
if (!is_ok (error))
return NULL;
cached = mono_metadata_get_inflated_signature (sig, context);
if (cached != sig)
mono_metadata_free_inflated_signature (sig);
else
mono_atomic_fetch_add_i32 (&inflated_signatures_size, mono_metadata_signature_size (cached));
sig = cached;
}
g_assert (is_ok (error));
return sig;
}
/**
* mono_method_get_signature:
* \p token is the method_ref/def/spec token used in a call IL instruction.
* \deprecated use the \c _checked variant
* Notes: runtime code MUST not use this function
*/
MonoMethodSignature*
mono_method_get_signature (MonoMethod *method, MonoImage *image, guint32 token)
{
ERROR_DECL (error);
MonoMethodSignature *res = mono_method_get_signature_checked (method, image, token, NULL, error);
mono_error_cleanup (error);
return res;
}
/* this is only for the typespec array methods */
MonoMethod*
mono_method_search_in_array_class (MonoClass *klass, const char *name, MonoMethodSignature *sig)
{
int i;
mono_class_setup_methods (klass);
g_assert (!mono_class_has_failure (klass)); /*FIXME this should not fail, right?*/
int mcount = mono_class_get_method_count (klass);
MonoMethod **klass_methods = m_class_get_methods (klass);
for (i = 0; i < mcount; ++i) {
MonoMethod *method = klass_methods [i];
if (strcmp (method->name, name) == 0 && sig->param_count == method->signature->param_count)
return method;
}
return NULL;
}
static MonoMethod *
method_from_memberref (MonoImage *image, guint32 idx, MonoGenericContext *typespec_context,
gboolean *used_context, MonoError *error)
{
MonoClass *klass = NULL;
MonoMethod *method = NULL;
MonoTableInfo *tables = image->tables;
guint32 cols[6];
guint32 nindex, class_index, sig_idx;
const char *mname;
MonoMethodSignature *sig;
const char *ptr;
error_init (error);
mono_metadata_decode_row (&tables [MONO_TABLE_MEMBERREF], idx-1, cols, MONO_MEMBERREF_SIZE);
nindex = cols [MONO_MEMBERREF_CLASS] >> MONO_MEMBERREF_PARENT_BITS;
class_index = cols [MONO_MEMBERREF_CLASS] & MONO_MEMBERREF_PARENT_MASK;
/*g_print ("methodref: 0x%x 0x%x %s\n", class, nindex,
mono_metadata_string_heap (m, cols [MONO_MEMBERREF_NAME]));*/
mname = mono_metadata_string_heap (image, cols [MONO_MEMBERREF_NAME]);
/*
* Whether we actually used the `typespec_context' or not.
* This is used to tell our caller whether or not it's safe to insert the returned
* method into a cache.
*/
if (used_context)
*used_context = class_index == MONO_MEMBERREF_PARENT_TYPESPEC;
switch (class_index) {
case MONO_MEMBERREF_PARENT_TYPEREF:
klass = mono_class_from_typeref_checked (image, MONO_TOKEN_TYPE_REF | nindex, error);
if (!klass)
goto fail;
break;
case MONO_MEMBERREF_PARENT_TYPESPEC:
/*
* Parse the TYPESPEC in the parent's context.
*/
klass = mono_class_get_and_inflate_typespec_checked (image, MONO_TOKEN_TYPE_SPEC | nindex, typespec_context, error);
if (!klass)
goto fail;
break;
case MONO_MEMBERREF_PARENT_TYPEDEF:
klass = mono_class_get_checked (image, MONO_TOKEN_TYPE_DEF | nindex, error);
if (!klass)
goto fail;
break;
case MONO_MEMBERREF_PARENT_METHODDEF: {
method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | nindex, NULL, NULL, error);
if (!method)
goto fail;
return method;
}
default:
mono_error_set_bad_image (error, image, "Memberref parent unknown: class: %d, index %d", class_index, nindex);
goto fail;
}
g_assert (klass);
mono_class_init_internal (klass);
sig_idx = cols [MONO_MEMBERREF_SIGNATURE];
ptr = mono_metadata_blob_heap (image, sig_idx);
mono_metadata_decode_blob_size (ptr, &ptr);
sig = (MonoMethodSignature *)find_cached_memberref_sig (image, sig_idx);
if (!sig) {
sig = mono_metadata_parse_method_signature_full (image, NULL, 0, ptr, NULL, error);
if (sig == NULL)
goto fail;
sig = (MonoMethodSignature *)cache_memberref_sig (image, sig_idx, sig);
}
switch (class_index) {
case MONO_MEMBERREF_PARENT_TYPEREF:
case MONO_MEMBERREF_PARENT_TYPEDEF:
method = find_method (klass, NULL, mname, sig, klass, error);
break;
case MONO_MEMBERREF_PARENT_TYPESPEC: {
MonoType *type;
type = m_class_get_byval_arg (klass);
if (type->type != MONO_TYPE_ARRAY && type->type != MONO_TYPE_SZARRAY) {
MonoClass *in_class = mono_class_is_ginst (klass) ? mono_class_get_generic_class (klass)->container_class : klass;
method = find_method (in_class, NULL, mname, sig, klass, error);
break;
}
/* we're an array and we created these methods already in klass in mono_class_init_internal () */
method = mono_method_search_in_array_class (klass, mname, sig);
break;
}
default:
mono_error_set_bad_image (error, image,"Memberref parent unknown: class: %d, index %d", class_index, nindex);
goto fail;
}
if (!method && is_ok (error))
mono_error_set_method_missing (error, klass, mname, sig, "Failed to load due to unknown reasons");
return method;
fail:
g_assert (!is_ok (error));
return NULL;
}
static MonoMethod *
method_from_methodspec (MonoImage *image, MonoGenericContext *context, guint32 idx, MonoError *error)
{
MonoMethod *method;
MonoClass *klass;
MonoTableInfo *tables = image->tables;
MonoGenericContext new_context;
MonoGenericInst *inst;
const char *ptr;
guint32 cols [MONO_METHODSPEC_SIZE];
guint32 token, nindex, param_count;
error_init (error);
mono_metadata_decode_row (&tables [MONO_TABLE_METHODSPEC], idx - 1, cols, MONO_METHODSPEC_SIZE);
token = cols [MONO_METHODSPEC_METHOD];
nindex = token >> MONO_METHODDEFORREF_BITS;
ptr = mono_metadata_blob_heap (image, cols [MONO_METHODSPEC_SIGNATURE]);
mono_metadata_decode_value (ptr, &ptr);
ptr++;
param_count = mono_metadata_decode_value (ptr, &ptr);
inst = mono_metadata_parse_generic_inst (image, NULL, param_count, ptr, &ptr, error);
if (!inst)
return NULL;
if (context && inst->is_open) {
inst = mono_metadata_inflate_generic_inst (inst, context, error);
if (!is_ok (error))
return NULL;
}
if ((token & MONO_METHODDEFORREF_MASK) == MONO_METHODDEFORREF_METHODDEF) {
method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | nindex, NULL, context, error);
if (!method)
return NULL;
} else {
method = method_from_memberref (image, nindex, context, NULL, error);
}
if (!method)
return NULL;
klass = method->klass;
if (mono_class_is_ginst (klass)) {
g_assert (method->is_inflated);
method = ((MonoMethodInflated *) method)->declaring;
}
new_context.class_inst = mono_class_is_ginst (klass) ? mono_class_get_generic_class (klass)->context.class_inst : NULL;
new_context.method_inst = inst;
method = mono_class_inflate_generic_method_full_checked (method, klass, &new_context, error);
return method;
}
/*
* LOCKING: assumes the loader lock to be taken.
*/
static MonoMethod *
mono_get_method_from_token (MonoImage *image, guint32 token, MonoClass *klass,
MonoGenericContext *context, gboolean *used_context, MonoError *error)
{
MonoMethod *result;
int table = mono_metadata_token_table (token);
int idx = mono_metadata_token_index (token);
MonoTableInfo *tables = image->tables;
MonoGenericContainer *generic_container = NULL, *container = NULL;
const char *sig = NULL;
guint32 cols [MONO_METHOD_SIZE];
error_init (error);
if (image_is_dynamic (image)) {
MonoClass *handle_class;
result = (MonoMethod *)mono_lookup_dynamic_token_class (image, token, TRUE, &handle_class, context, error);
return_val_if_nok (error, NULL);
// This checks the memberref type as well
if (result && handle_class != mono_defaults.methodhandle_class) {
mono_error_set_bad_image (error, image, "Bad method token 0x%08x on dynamic image", token);
return NULL;
}
return result;
}
if (table != MONO_TABLE_METHOD) {
if (table == MONO_TABLE_METHODSPEC) {
if (used_context) *used_context = TRUE;
return method_from_methodspec (image, context, idx, error);
}
if (table != MONO_TABLE_MEMBERREF) {
mono_error_set_bad_image (error, image, "Bad method token 0x%08x.", token);
return NULL;
}
return method_from_memberref (image, idx, context, used_context, error);
}
if (used_context) *used_context = FALSE;
if (mono_metadata_table_bounds_check (image, MONO_TABLE_METHOD, idx)) {
mono_error_set_bad_image (error, image, "Bad method token 0x%08x (out of bounds).", token);
return NULL;
}
if (!klass) {
guint32 type = mono_metadata_typedef_from_method (image, token);
if (!type) {
mono_error_set_bad_image (error, image, "Bad method token 0x%08x (could not find corresponding typedef).", token);
return NULL;
}
klass = mono_class_get_checked (image, MONO_TOKEN_TYPE_DEF | type, error);
if (klass == NULL)
return NULL;
}
mono_metadata_decode_row (&image->tables [MONO_TABLE_METHOD], idx - 1, cols, MONO_METHOD_SIZE);
if ((cols [MONO_METHOD_FLAGS] & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(cols [MONO_METHOD_IMPLFLAGS] & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)) {
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethodPInvoke));
} else {
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethod));
mono_atomic_fetch_add_i32 (&methods_size, sizeof (MonoMethod));
}
mono_atomic_inc_i32 (&mono_stats.method_count);
result->slot = -1;
result->klass = klass;
result->flags = cols [MONO_METHOD_FLAGS];
result->iflags = cols [MONO_METHOD_IMPLFLAGS];
result->token = token;
result->name = mono_metadata_string_heap (image, cols [MONO_METHOD_NAME]);
/* If a method is abstract and marked as an icall, silently ignore the
* icall attribute so that we don't later emit a warning that the icall
* can't be found.
*/
if ((result->flags & METHOD_ATTRIBUTE_ABSTRACT) &&
(result->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
result->iflags &= ~METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL;
if (!sig) /* already taken from the methodref */
sig = mono_metadata_blob_heap (image, cols [MONO_METHOD_SIGNATURE]);
/* size = */ mono_metadata_decode_blob_size (sig, &sig);
container = mono_class_try_get_generic_container (klass);
/*
* load_generic_params does a binary search so only call it if the method
* is generic.
*/
if (*sig & 0x10) {
generic_container = mono_metadata_load_generic_params (image, token, container, result);
}
if (generic_container) {
result->is_generic = TRUE;
/*FIXME put this before the image alloc*/
if (!mono_metadata_load_generic_param_constraints_checked (image, token, generic_container, error))
return NULL;
container = generic_container;
}
if (cols [MONO_METHOD_IMPLFLAGS] & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) {
if (result->klass == mono_defaults.string_class && !strcmp (result->name, ".ctor"))
result->string_ctor = 1;
} else if (cols [MONO_METHOD_FLAGS] & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)result;
#ifdef TARGET_WIN32
/* IJW is P/Invoke with a predefined function pointer. */
if (m_image_is_module_handle (image) && (cols [MONO_METHOD_IMPLFLAGS] & METHOD_IMPL_ATTRIBUTE_NATIVE)) {
piinfo->addr = mono_image_rva_map (image, cols [MONO_METHOD_RVA]);
g_assert (piinfo->addr);
}
#endif
piinfo->implmap_idx = mono_metadata_implmap_from_method (image, idx - 1);
/* Native methods can have no map. */
if (piinfo->implmap_idx)
piinfo->piflags = mono_metadata_decode_row_col (&tables [MONO_TABLE_IMPLMAP], piinfo->implmap_idx - 1, MONO_IMPLMAP_FLAGS);
}
if (generic_container)
mono_method_set_generic_container (result, generic_container);
return result;
}
/**
* mono_get_method:
*/
MonoMethod *
mono_get_method (MonoImage *image, guint32 token, MonoClass *klass)
{
ERROR_DECL (error);
MonoMethod *result = mono_get_method_checked (image, token, klass, NULL, error);
mono_error_cleanup (error);
return result;
}
/**
* mono_get_method_full:
*/
MonoMethod *
mono_get_method_full (MonoImage *image, guint32 token, MonoClass *klass,
MonoGenericContext *context)
{
ERROR_DECL (error);
MonoMethod *result = mono_get_method_checked (image, token, klass, context, error);
mono_error_cleanup (error);
return result;
}
MonoMethod *
mono_get_method_checked (MonoImage *image, guint32 token, MonoClass *klass, MonoGenericContext *context, MonoError *error)
{
MonoMethod *result = NULL;
gboolean used_context = FALSE;
/* FIXME: method definition lookups for metadata-update probably end up here */
/* We do everything inside the lock to prevent creation races */
error_init (error);
mono_image_lock (image);
if (mono_metadata_token_table (token) == MONO_TABLE_METHOD) {
if (!image->method_cache)
image->method_cache = g_hash_table_new (NULL, NULL);
result = (MonoMethod *)g_hash_table_lookup (image->method_cache, GINT_TO_POINTER (mono_metadata_token_index (token)));
} else if (!image_is_dynamic (image)) {
if (!image->methodref_cache)
image->methodref_cache = g_hash_table_new (NULL, NULL);
result = (MonoMethod *)g_hash_table_lookup (image->methodref_cache, GINT_TO_POINTER (token));
}
mono_image_unlock (image);
if (result)
return result;
result = mono_get_method_from_token (image, token, klass, context, &used_context, error);
if (!result)
return NULL;
mono_image_lock (image);
if (!used_context && !result->is_inflated) {
MonoMethod *result2 = NULL;
if (mono_metadata_token_table (token) == MONO_TABLE_METHOD)
result2 = (MonoMethod *)g_hash_table_lookup (image->method_cache, GINT_TO_POINTER (mono_metadata_token_index (token)));
else if (!image_is_dynamic (image))
result2 = (MonoMethod *)g_hash_table_lookup (image->methodref_cache, GINT_TO_POINTER (token));
if (result2) {
mono_image_unlock (image);
return result2;
}
if (mono_metadata_token_table (token) == MONO_TABLE_METHOD)
g_hash_table_insert (image->method_cache, GINT_TO_POINTER (mono_metadata_token_index (token)), result);
else if (!image_is_dynamic (image))
g_hash_table_insert (image->methodref_cache, GINT_TO_POINTER (token), result);
}
mono_image_unlock (image);
return result;
}
static MonoMethod*
get_method_constrained (MonoImage *image, MonoMethod *method, MonoClass *constrained_class, MonoGenericContext *context, MonoError *error)
{
MonoClass *base_class = method->klass;
error_init (error);
if (!mono_class_is_assignable_from_internal (base_class, constrained_class)) {
char *base_class_name = mono_type_get_full_name (base_class);
char *constrained_class_name = mono_type_get_full_name (constrained_class);
mono_error_set_invalid_operation (error, "constrained call: %s is not assignable from %s", base_class_name, constrained_class_name);
g_free (base_class_name);
g_free (constrained_class_name);
return NULL;
}
/* If the constraining class is actually an interface, we don't learn
* anything new by constraining.
*/
if (MONO_CLASS_IS_INTERFACE_INTERNAL (constrained_class))
return method;
mono_class_setup_vtable (base_class);
if (mono_class_has_failure (base_class)) {
mono_error_set_for_class_failure (error, base_class);
return NULL;
}
MonoGenericContext inflated_method_ctx;
memset (&inflated_method_ctx, 0, sizeof (inflated_method_ctx));
inflated_method_ctx.class_inst = NULL;
inflated_method_ctx.method_inst = NULL;
gboolean inflated_generic_method = FALSE;
if (method->is_inflated) {
MonoGenericContext *method_ctx = mono_method_get_context (method);
/* If method is an instantiation of a generic method definition, ie
* class H<T> { void M<U> (...) { ... } }
* and method is H<C>.M<D>
* we will get at the end a refined HSubclass<...>.M<U> and we will need to re-instantiate it with D.
* to get HSubclass<...>.M<D>
*
*/
if (method_ctx->method_inst != NULL) {
inflated_generic_method = TRUE;
inflated_method_ctx.method_inst = method_ctx->method_inst;
}
}
int vtable_slot = 0;
if (!MONO_CLASS_IS_INTERFACE_INTERNAL (base_class)) {
/*if the base class isn't an interface and the method isn't
* virtual, there's nothing to do, we're already on the method
* we want to call. */
if ((method->flags & METHOD_ATTRIBUTE_VIRTUAL) == 0)
return method;
/* if this isn't an interface method, get the vtable slot and
* find the corresponding method in the constrained class,
* which is a subclass of the base class. */
vtable_slot = mono_method_get_vtable_index (method);
mono_class_setup_vtable (constrained_class);
if (mono_class_has_failure (constrained_class)) {
mono_error_set_for_class_failure (error, constrained_class);
return NULL;
}
} else {
if ((method->flags & METHOD_ATTRIBUTE_VIRTUAL) == 0)
return method;
mono_class_setup_vtable (constrained_class);
if (mono_class_has_failure (constrained_class)) {
mono_error_set_for_class_failure (error, constrained_class);
return NULL;
}
/* Get the slot of the method in the interface. Then get the
* interface base in constrained_class */
int itf_slot = mono_method_get_vtable_index (method);
g_assert (itf_slot >= 0);
gboolean variant = FALSE;
int itf_base = mono_class_interface_offset_with_variance (constrained_class, base_class, &variant);
vtable_slot = itf_slot + itf_base;
}
g_assert (vtable_slot >= 0);
MonoMethod *res = mono_class_get_vtable_entry (constrained_class, vtable_slot);
if (res == NULL && mono_class_is_abstract (constrained_class) ) {
/* Constraining class is abstract, there may not be a refined method. */
return method;
}
g_assert (res != NULL);
if (inflated_generic_method) {
g_assert (res->is_generic || res->is_inflated);
res = mono_class_inflate_generic_method_checked (res, &inflated_method_ctx, error);
return_val_if_nok (error, NULL);
}
return res;
}
MonoMethod *
mono_get_method_constrained_with_method (MonoImage *image, MonoMethod *method, MonoClass *constrained_class,
MonoGenericContext *context, MonoError *error)
{
g_assert (method);
return get_method_constrained (image, method, constrained_class, context, error);
}
/**
* mono_get_method_constrained:
* This is used when JITing the <code>constrained.</code> opcode.
* \returns The contrained method, which has been inflated
* as the function return value; and the original CIL-stream method as
* declared in \p cil_method. The latter is used for verification.
*/
MonoMethod *
mono_get_method_constrained (MonoImage *image, guint32 token, MonoClass *constrained_class,
MonoGenericContext *context, MonoMethod **cil_method)
{
ERROR_DECL (error);
MonoMethod *result = mono_get_method_constrained_checked (image, token, constrained_class, context, cil_method, error);
mono_error_cleanup (error);
return result;
}
MonoMethod *
mono_get_method_constrained_checked (MonoImage *image, guint32 token, MonoClass *constrained_class, MonoGenericContext *context, MonoMethod **cil_method, MonoError *error)
{
error_init (error);
*cil_method = mono_get_method_checked (image, token, NULL, context, error);
if (!*cil_method)
return NULL;
return get_method_constrained (image, *cil_method, constrained_class, context, error);
}
/**
* mono_free_method:
*/
void
mono_free_method (MonoMethod *method)
{
if (!method)
return;
MONO_PROFILER_RAISE (method_free, (method));
/* FIXME: This hack will go away when the profiler will support freeing methods */
if (G_UNLIKELY (mono_profiler_installed ()))
return;
if (method->signature) {
/*
* FIXME: This causes crashes because the types inside signatures and
* locals are shared.
*/
/* mono_metadata_free_method_signature (method->signature); */
/* g_free (method->signature); */
}
if (method_is_dynamic (method)) {
MonoMethodWrapper *mw = (MonoMethodWrapper*)method;
int i;
mono_marshal_free_dynamic_wrappers (method);
mono_image_property_remove (m_class_get_image (method->klass), method);
g_free ((char*)method->name);
if (mw->header) {
g_free ((char*)mw->header->code);
for (i = 0; i < mw->header->num_locals; ++i)
g_free (mw->header->locals [i]);
g_free (mw->header->clauses);
g_free (mw->header);
}
g_free (mw->method_data);
g_free (method->signature);
g_free (method);
}
}
/**
* mono_method_get_param_names:
*/
void
mono_method_get_param_names (MonoMethod *method, const char **names)
{
int i, lastp;
MonoClass *klass;
MonoTableInfo *methodt;
MonoTableInfo *paramt;
MonoMethodSignature *signature;
guint32 idx;
if (method->is_inflated)
method = ((MonoMethodInflated *) method)->declaring;
signature = mono_method_signature_internal (method);
/*FIXME this check is somewhat redundant since the caller usally will have to get the signature to figure out the
number of arguments and allocate a properly sized array. */
if (signature == NULL)
return;
if (!signature->param_count)
return;
for (i = 0; i < signature->param_count; ++i)
names [i] = "";
klass = method->klass;
if (m_class_get_rank (klass))
return;
mono_class_init_internal (klass);
MonoImage *klass_image = m_class_get_image (klass);
if (image_is_dynamic (klass_image)) {
MonoReflectionMethodAux *method_aux =
(MonoReflectionMethodAux *)g_hash_table_lookup (
((MonoDynamicImage*)m_class_get_image (method->klass))->method_aux_hash, method);
if (method_aux && method_aux->param_names) {
for (i = 0; i < mono_method_signature_internal (method)->param_count; ++i)
if (method_aux->param_names [i + 1])
names [i] = method_aux->param_names [i + 1];
}
return;
}
if (method->wrapper_type) {
char **pnames = NULL;
mono_image_lock (klass_image);
if (klass_image->wrapper_param_names)
pnames = (char **)g_hash_table_lookup (klass_image->wrapper_param_names, method);
mono_image_unlock (klass_image);
if (pnames) {
for (i = 0; i < signature->param_count; ++i)
names [i] = pnames [i];
}
return;
}
methodt = &klass_image->tables [MONO_TABLE_METHOD];
paramt = &klass_image->tables [MONO_TABLE_PARAM];
idx = mono_method_get_index (method);
if (idx > 0) {
guint32 cols [MONO_PARAM_SIZE];
guint param_index;
param_index = mono_metadata_decode_row_col (methodt, idx - 1, MONO_METHOD_PARAMLIST);
if (idx < table_info_get_rows (methodt))
lastp = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
else
lastp = table_info_get_rows (paramt) + 1;
for (i = param_index; i < lastp; ++i) {
mono_metadata_decode_row (paramt, i -1, cols, MONO_PARAM_SIZE);
if (cols [MONO_PARAM_SEQUENCE] && cols [MONO_PARAM_SEQUENCE] <= signature->param_count) /* skip return param spec and bounds check*/
names [cols [MONO_PARAM_SEQUENCE] - 1] = mono_metadata_string_heap (klass_image, cols [MONO_PARAM_NAME]);
}
}
}
/**
* mono_method_get_param_token:
*/
guint32
mono_method_get_param_token (MonoMethod *method, int index)
{
MonoClass *klass = method->klass;
MonoTableInfo *methodt;
guint32 idx;
mono_class_init_internal (klass);
MonoImage *klass_image = m_class_get_image (klass);
g_assert (!image_is_dynamic (klass_image));
methodt = &klass_image->tables [MONO_TABLE_METHOD];
idx = mono_method_get_index (method);
if (idx > 0) {
guint param_index = mono_metadata_decode_row_col (methodt, idx - 1, MONO_METHOD_PARAMLIST);
if (index == -1)
/* Return value */
return mono_metadata_make_token (MONO_TABLE_PARAM, 0);
else
return mono_metadata_make_token (MONO_TABLE_PARAM, param_index + index);
}
return 0;
}
/**
* mono_method_get_marshal_info:
*/
void
mono_method_get_marshal_info (MonoMethod *method, MonoMarshalSpec **mspecs)
{
int i, lastp;
MonoClass *klass = method->klass;
MonoTableInfo *methodt;
MonoTableInfo *paramt;
MonoMethodSignature *signature;
guint32 idx;
signature = mono_method_signature_internal (method);
g_assert (signature); /*FIXME there is no way to signal error from this function*/
for (i = 0; i < signature->param_count + 1; ++i)
mspecs [i] = NULL;
if (image_is_dynamic (m_class_get_image (method->klass))) {
MonoReflectionMethodAux *method_aux =
(MonoReflectionMethodAux *)g_hash_table_lookup (
((MonoDynamicImage*)m_class_get_image (method->klass))->method_aux_hash, method);
if (method_aux && method_aux->param_marshall) {
MonoMarshalSpec **dyn_specs = method_aux->param_marshall;
for (i = 0; i < signature->param_count + 1; ++i) {
if (dyn_specs [i]) {
mspecs [i] = g_new0 (MonoMarshalSpec, 1);
memcpy (mspecs [i], dyn_specs [i], sizeof (MonoMarshalSpec));
if (mspecs [i]->native == MONO_NATIVE_CUSTOM) {
mspecs [i]->data.custom_data.custom_name = g_strdup (dyn_specs [i]->data.custom_data.custom_name);
mspecs [i]->data.custom_data.cookie = g_strdup (dyn_specs [i]->data.custom_data.cookie);
}
}
}
}
return;
}
/* dynamic method added to non-dynamic image */
if (method->dynamic)
return;
mono_class_init_internal (klass);
MonoImage *klass_image = m_class_get_image (klass);
methodt = &klass_image->tables [MONO_TABLE_METHOD];
paramt = &klass_image->tables [MONO_TABLE_PARAM];
idx = mono_method_get_index (method);
if (idx > 0) {
guint32 cols [MONO_PARAM_SIZE];
guint param_index = mono_metadata_decode_row_col (methodt, idx - 1, MONO_METHOD_PARAMLIST);
if (idx < table_info_get_rows (methodt))
lastp = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
else
lastp = table_info_get_rows (paramt) + 1;
for (i = param_index; i < lastp; ++i) {
mono_metadata_decode_row (paramt, i -1, cols, MONO_PARAM_SIZE);
if (cols [MONO_PARAM_FLAGS] & PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL && cols [MONO_PARAM_SEQUENCE] <= signature->param_count) {
const char *tp;
tp = mono_metadata_get_marshal_info (klass_image, i - 1, FALSE);
g_assert (tp);
mspecs [cols [MONO_PARAM_SEQUENCE]]= mono_metadata_parse_marshal_spec (klass_image, tp);
}
}
return;
}
}
/**
* mono_method_has_marshal_info:
*/
gboolean
mono_method_has_marshal_info (MonoMethod *method)
{
int i, lastp;
MonoClass *klass = method->klass;
MonoTableInfo *methodt;
MonoTableInfo *paramt;
guint32 idx;
if (image_is_dynamic (m_class_get_image (method->klass))) {
MonoReflectionMethodAux *method_aux =
(MonoReflectionMethodAux *)g_hash_table_lookup (
((MonoDynamicImage*)m_class_get_image (method->klass))->method_aux_hash, method);
MonoMarshalSpec **dyn_specs = method_aux->param_marshall;
if (dyn_specs) {
for (i = 0; i < mono_method_signature_internal (method)->param_count + 1; ++i)
if (dyn_specs [i])
return TRUE;
}
return FALSE;
}
mono_class_init_internal (klass);
methodt = &m_class_get_image (klass)->tables [MONO_TABLE_METHOD];
paramt = &m_class_get_image (klass)->tables [MONO_TABLE_PARAM];
idx = mono_method_get_index (method);
if (idx > 0) {
guint32 cols [MONO_PARAM_SIZE];
guint param_index = mono_metadata_decode_row_col (methodt, idx - 1, MONO_METHOD_PARAMLIST);
if (idx + 1 < table_info_get_rows (methodt))
lastp = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
else
lastp = table_info_get_rows (paramt) + 1;
for (i = param_index; i < lastp; ++i) {
mono_metadata_decode_row (paramt, i -1, cols, MONO_PARAM_SIZE);
if (cols [MONO_PARAM_FLAGS] & PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL)
return TRUE;
}
return FALSE;
}
return FALSE;
}
gpointer
mono_method_get_wrapper_data (MonoMethod *method, guint32 id)
{
void **data;
g_assert (method != NULL);
g_assert (method->wrapper_type != MONO_WRAPPER_NONE);
data = (void **)((MonoMethodWrapper *)method)->method_data;
g_assert (data != NULL);
g_assert (id <= GPOINTER_TO_UINT (*data));
return data [id];
}
typedef struct {
MonoStackWalk func;
gpointer user_data;
} StackWalkUserData;
static gboolean
stack_walk_adapter (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer data)
{
StackWalkUserData *d = (StackWalkUserData *)data;
switch (frame->type) {
case FRAME_TYPE_DEBUGGER_INVOKE:
case FRAME_TYPE_MANAGED_TO_NATIVE:
case FRAME_TYPE_TRAMPOLINE:
case FRAME_TYPE_INTERP_TO_MANAGED:
case FRAME_TYPE_INTERP_TO_MANAGED_WITH_CTX:
case FRAME_TYPE_INTERP_ENTRY:
case FRAME_TYPE_JIT_ENTRY:
return FALSE;
case FRAME_TYPE_MANAGED:
case FRAME_TYPE_INTERP:
case FRAME_TYPE_IL_STATE:
g_assert (frame->ji);
return d->func (frame->actual_method, frame->native_offset, frame->il_offset, frame->managed, d->user_data);
break;
default:
g_assert_not_reached ();
return FALSE;
}
}
void
mono_stack_walk (MonoStackWalk func, gpointer user_data)
{
StackWalkUserData ud = { func, user_data };
mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (stack_walk_adapter, NULL, MONO_UNWIND_LOOKUP_ALL, &ud);
}
/**
* mono_stack_walk_no_il:
*/
void
mono_stack_walk_no_il (MonoStackWalk func, gpointer user_data)
{
StackWalkUserData ud = { func, user_data };
mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (stack_walk_adapter, NULL, MONO_UNWIND_DEFAULT, &ud);
}
typedef struct {
MonoStackWalkAsyncSafe func;
gpointer user_data;
} AsyncStackWalkUserData;
static gboolean
async_stack_walk_adapter (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer data)
{
AsyncStackWalkUserData *d = (AsyncStackWalkUserData *)data;
switch (frame->type) {
case FRAME_TYPE_DEBUGGER_INVOKE:
case FRAME_TYPE_MANAGED_TO_NATIVE:
case FRAME_TYPE_TRAMPOLINE:
case FRAME_TYPE_INTERP_TO_MANAGED:
case FRAME_TYPE_INTERP_TO_MANAGED_WITH_CTX:
return FALSE;
case FRAME_TYPE_MANAGED:
case FRAME_TYPE_INTERP:
if (!frame->ji)
return FALSE;
MonoMethod *method;
method = frame->ji->async ? NULL : frame->actual_method;
return d->func (method, mono_get_root_domain (), frame->ji->code_start, frame->native_offset, d->user_data);
default:
g_assert_not_reached ();
return FALSE;
}
}
/**
* mono_stack_walk_async_safe:
* Async safe version callable from signal handlers.
*/
void
mono_stack_walk_async_safe (MonoStackWalkAsyncSafe func, void *initial_sig_context, void *user_data)
{
MonoContext ctx;
AsyncStackWalkUserData ud = { func, user_data };
mono_sigctx_to_monoctx (initial_sig_context, &ctx);
mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (async_stack_walk_adapter, &ctx, MONO_UNWIND_SIGNAL_SAFE, &ud);
}
static gboolean
last_managed (MonoMethod *m, gint no, gint ilo, gboolean managed, gpointer data)
{
MonoMethod **dest = (MonoMethod **)data;
*dest = m;
/*g_print ("In %s::%s [%d] [%d]\n", m->klass->name, m->name, no, ilo);*/
return managed;
}
/**
* mono_method_get_last_managed:
*/
MonoMethod*
mono_method_get_last_managed (void)
{
MonoMethod *m = NULL;
mono_stack_walk_no_il (last_managed, &m);
return m;
}
/**
* mono_method_signature_checked_slow:
*
* Return the signature of the method M. On failure, returns NULL, and ERR is set.
* Call mono_method_signature_checked instead.
*/
MonoMethodSignature*
mono_method_signature_checked_slow (MonoMethod *m, MonoError *error)
{
int idx;
MonoImage* img;
const char *sig;
gboolean can_cache_signature;
MonoGenericContainer *container;
MonoMethodSignature *signature = NULL, *sig2;
guint32 sig_offset;
/* We need memory barriers below because of the double-checked locking pattern */
error_init (error);
if (m->signature)
return m->signature;
img = m_class_get_image (m->klass);
if (m->is_inflated) {
MonoMethodInflated *imethod = (MonoMethodInflated *) m;
/* the lock is recursive */
signature = mono_method_signature_internal (imethod->declaring);
signature = inflate_generic_signature_checked (m_class_get_image (imethod->declaring->klass), signature, mono_method_get_context (m), error);
if (!is_ok (error))
return NULL;
mono_atomic_fetch_add_i32 (&inflated_signatures_size, mono_metadata_signature_size (signature));
mono_image_lock (img);
mono_memory_barrier ();
if (!m->signature)
m->signature = signature;
mono_image_unlock (img);
return m->signature;
}
g_assert (mono_metadata_token_table (m->token) == MONO_TABLE_METHOD);
idx = mono_metadata_token_index (m->token);
sig = mono_metadata_blob_heap (img, sig_offset = mono_metadata_decode_row_col (&img->tables [MONO_TABLE_METHOD], idx - 1, MONO_METHOD_SIGNATURE));
g_assert (!mono_class_is_ginst (m->klass));
container = mono_method_get_generic_container (m);
if (!container)
container = mono_class_try_get_generic_container (m->klass);
/* Generic signatures depend on the container so they cannot be cached */
/* icall/pinvoke signatures cannot be cached cause we modify them below */
can_cache_signature = !(m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) && !(m->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) && !container;
/* If the method has parameter attributes, that can modify the signature */
if (mono_metadata_method_has_param_attrs (img, idx))
can_cache_signature = FALSE;
if (can_cache_signature) {
mono_image_lock (img);
signature = (MonoMethodSignature *)g_hash_table_lookup (img->method_signatures, sig);
mono_image_unlock (img);
}
if (!signature) {
const char *sig_body;
/* size = */ mono_metadata_decode_blob_size (sig, &sig_body);
signature = mono_metadata_parse_method_signature_full (img, container, idx, sig_body, NULL, error);
if (!signature)
return NULL;
if (can_cache_signature) {
mono_image_lock (img);
sig2 = (MonoMethodSignature *)g_hash_table_lookup (img->method_signatures, sig);
if (!sig2)
g_hash_table_insert (img->method_signatures, (gpointer)sig, signature);
mono_image_unlock (img);
}
mono_atomic_fetch_add_i32 (&signatures_size, mono_metadata_signature_size (signature));
}
/* Verify metadata consistency */
if (signature->generic_param_count) {
if (!container || !container->is_method) {
mono_error_set_method_missing (error, m->klass, m->name, signature, "Signature claims method has generic parameters, but generic_params table says it doesn't for method 0x%08x from image %s", idx, img->name);
return NULL;
}
if (container->type_argc != signature->generic_param_count) {
mono_error_set_method_missing (error, m->klass, m->name, signature, "Inconsistent generic parameter count. Signature says %d, generic_params table says %d for method 0x%08x from image %s", signature->generic_param_count, container->type_argc, idx, img->name);
return NULL;
}
} else if (container && container->is_method && container->type_argc) {
mono_error_set_method_missing (error, m->klass, m->name, signature, "generic_params table claims method has generic parameters, but signature says it doesn't for method 0x%08x from image %s", idx, img->name);
return NULL;
}
if (m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) {
signature->pinvoke = 1;
#ifdef TARGET_WIN32
/*
* On Windows the default pinvoke calling convention is STDCALL but
* we need CDECL since this is actually an icall.
*/
signature->call_convention = MONO_CALL_C;
#endif
} else if (m->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
MonoCallConvention conv = (MonoCallConvention)0;
MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)m;
signature->pinvoke = 1;
switch (piinfo->piflags & PINVOKE_ATTRIBUTE_CALL_CONV_MASK) {
case 0: /* no call conv, so using default */
case PINVOKE_ATTRIBUTE_CALL_CONV_WINAPI:
conv = MONO_CALL_DEFAULT;
break;
case PINVOKE_ATTRIBUTE_CALL_CONV_CDECL:
conv = MONO_CALL_C;
break;
case PINVOKE_ATTRIBUTE_CALL_CONV_STDCALL:
conv = MONO_CALL_STDCALL;
break;
case PINVOKE_ATTRIBUTE_CALL_CONV_THISCALL:
conv = MONO_CALL_THISCALL;
break;
case PINVOKE_ATTRIBUTE_CALL_CONV_FASTCALL:
conv = MONO_CALL_FASTCALL;
break;
case PINVOKE_ATTRIBUTE_CALL_CONV_GENERIC:
case PINVOKE_ATTRIBUTE_CALL_CONV_GENERICINST:
default: {
mono_error_set_method_missing (error, m->klass, m->name, signature, "Unsupported calling convention : 0x%04x for method 0x%08x from image %s", piinfo->piflags, idx, img->name);
}
return NULL;
}
signature->call_convention = conv;
}
mono_image_lock (img);
mono_memory_barrier ();
if (!m->signature)
m->signature = signature;
mono_image_unlock (img);
return m->signature;
}
/**
* mono_method_signature_internal_slow:
* \returns the signature of the method \p m. On failure, returns NULL.
* Call mono_method_signature_internal instead.
*/
MonoMethodSignature*
mono_method_signature_internal_slow (MonoMethod *m)
{
ERROR_DECL (error);
MonoMethodSignature *sig = mono_method_signature_checked (m, error);
if (sig)
return sig;
char *type_name = mono_type_get_full_name (m->klass);
g_warning ("Could not load signature of %s:%s due to: %s", type_name, m->name, mono_error_get_message (error));
g_free (type_name);
mono_error_cleanup (error);
return NULL;
}
/**
* mono_method_signature:
* \returns the signature of the method \p m. On failure, returns NULL.
*/
MonoMethodSignature*
mono_method_signature (MonoMethod *m)
{
MonoMethodSignature *sig;
MONO_ENTER_GC_UNSAFE;
sig = mono_method_signature_internal (m);
MONO_EXIT_GC_UNSAFE;
return sig;
}
/**
* mono_method_get_name:
*/
const char*
mono_method_get_name (MonoMethod *method)
{
return method->name;
}
/**
* mono_method_get_class:
*/
MonoClass*
mono_method_get_class (MonoMethod *method)
{
return method->klass;
}
/**
* mono_method_get_token:
*/
guint32
mono_method_get_token (MonoMethod *method)
{
return method->token;
}
gboolean
mono_method_has_no_body (MonoMethod *method)
{
return ((method->flags & METHOD_ATTRIBUTE_ABSTRACT) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL));
}
// FIXME Replace all internal callers of mono_method_get_header_checked with
// mono_method_get_header_internal; the difference is in error initialization.
MonoMethodHeader*
mono_method_get_header_internal (MonoMethod *method, MonoError *error)
{
int idx;
guint32 rva;
MonoImage* img;
gpointer loc = NULL;
MonoGenericContainer *container;
error_init (error);
img = m_class_get_image (method->klass);
// FIXME: for internal callers maybe it makes sense to do this check at the call site, not
// here?
if (mono_method_has_no_body (method)) {
if (mono_method_get_is_reabstracted (method))
mono_error_set_generic_error (error, "System", "EntryPointNotFoundException", "%s", method->name);
else
mono_error_set_bad_image (error, img, "Method has no body");
return NULL;
}
if (method->is_inflated) {
MonoMethodInflated *imethod = (MonoMethodInflated *) method;
MonoMethodHeader *header, *iheader;
header = mono_method_get_header_checked (imethod->declaring, error);
if (!header)
return NULL;
iheader = inflate_generic_header (header, mono_method_get_context (method), error);
mono_metadata_free_mh (header);
if (!iheader) {
return NULL;
}
return iheader;
}
if (method->wrapper_type != MONO_WRAPPER_NONE || method->sre_method) {
MonoMethodWrapper *mw = (MonoMethodWrapper *)method;
g_assert (mw->header);
return mw->header;
}
/*
* We don't need locks here: the new header is allocated from malloc memory
* and is not stored anywhere in the runtime, the user needs to free it.
*/
g_assert (mono_metadata_token_table (method->token) == MONO_TABLE_METHOD);
idx = mono_metadata_token_index (method->token);
if (G_UNLIKELY (img->has_updates))
loc = mono_metadata_update_get_updated_method_rva (img, idx);
if (!loc) {
rva = mono_metadata_decode_row_col (&img->tables [MONO_TABLE_METHOD], idx - 1, MONO_METHOD_RVA);
loc = mono_image_rva_map (img, rva);
}
if (!loc) {
mono_error_set_bad_image (error, img, "Method has zero rva");
return NULL;
}
/*
* When parsing the types of local variables, we must pass any container available
* to ensure that both VAR and MVAR will get the right owner.
*/
container = mono_method_get_generic_container (method);
if (!container)
container = mono_class_try_get_generic_container (method->klass);
return mono_metadata_parse_mh_full (img, container, (const char *)loc, error);
}
MonoMethodHeader*
mono_method_get_header_checked (MonoMethod *method, MonoError *error)
// Public function that must initialize MonoError for compatibility.
{
MONO_API_ERROR_INIT (error);
return mono_method_get_header_internal (method, error);
}
/**
* mono_method_get_header:
*/
MonoMethodHeader*
mono_method_get_header (MonoMethod *method)
{
ERROR_DECL (error);
MonoMethodHeader *header = mono_method_get_header_checked (method, error);
mono_error_cleanup (error);
return header;
}
/**
* mono_method_get_flags:
*/
guint32
mono_method_get_flags (MonoMethod *method, guint32 *iflags)
{
if (iflags)
*iflags = method->iflags;
return method->flags;
}
/**
* mono_method_get_index:
* Find the method index in the metadata \c MethodDef table.
*/
guint32
mono_method_get_index (MonoMethod *method)
{
MonoClass *klass = method->klass;
int i;
if (m_class_get_rank (klass))
/* constructed array methods are not in the MethodDef table */
return 0;
if (method->token)
return mono_metadata_token_index (method->token);
mono_class_setup_methods (klass);
if (mono_class_has_failure (klass))
return 0;
int first_idx = mono_class_get_first_method_idx (klass);
int mcount = mono_class_get_method_count (klass);
MonoMethod **klass_methods = m_class_get_methods (klass);
for (i = 0; i < mcount; ++i) {
if (method == klass_methods [i]) {
if (m_class_get_image (klass)->uncompressed_metadata)
return mono_metadata_translate_token_index (m_class_get_image (klass), MONO_TABLE_METHOD, first_idx + i + 1);
else
return first_idx + i + 1;
}
}
return 0;
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/mini/mini-windows-dllmain.c | /**
* \file
* DllMain entry point.
*
* (C) 2002-2003 Ximian, Inc.
* (C) 2003-2006 Novell, Inc.
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "mini-runtime.h"
#ifdef HOST_WIN32
#include "mini-windows.h"
#include <windows.h>
MONO_EXTERN_C
BOOL APIENTRY DllMain (HMODULE module_handle, DWORD reason, LPVOID reserved);
MONO_EXTERN_C
BOOL APIENTRY DllMain (HMODULE module_handle, DWORD reason, LPVOID reserved)
{
return mono_win32_runtime_tls_callback (module_handle, reason, reserved, MONO_WIN32_TLS_CALLBACK_TYPE_DLL);
}
#endif
| /**
* \file
* DllMain entry point.
*
* (C) 2002-2003 Ximian, Inc.
* (C) 2003-2006 Novell, Inc.
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "mini-runtime.h"
#ifdef HOST_WIN32
#include "mini-windows.h"
#include <windows.h>
MONO_EXTERN_C
BOOL APIENTRY DllMain (HMODULE module_handle, DWORD reason, LPVOID reserved);
MONO_EXTERN_C
BOOL APIENTRY DllMain (HMODULE module_handle, DWORD reason, LPVOID reserved)
{
return mono_win32_runtime_tls_callback (module_handle, reason, reserved, MONO_WIN32_TLS_CALLBACK_TYPE_DLL);
}
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/native/external/zlib/gzclose.c | /* gzclose.c -- zlib gzclose() function
* Copyright (C) 2004, 2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "gzguts.h"
/* gzclose() is in a separate file so that it is linked in only if it is used.
That way the other gzclose functions can be used instead to avoid linking in
unneeded compression or decompression routines. */
int ZEXPORT gzclose(file)
gzFile file;
{
#ifndef NO_GZCOMPRESS
gz_statep state;
if (file == NULL)
return Z_STREAM_ERROR;
state = (gz_statep)file;
return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);
#else
return gzclose_r(file);
#endif
}
| /* gzclose.c -- zlib gzclose() function
* Copyright (C) 2004, 2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "gzguts.h"
/* gzclose() is in a separate file so that it is linked in only if it is used.
That way the other gzclose functions can be used instead to avoid linking in
unneeded compression or decompression routines. */
int ZEXPORT gzclose(file)
gzFile file;
{
#ifndef NO_GZCOMPRESS
gz_statep state;
if (file == NULL)
return Z_STREAM_ERROR;
state = (gz_statep)file;
return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);
#else
return gzclose_r(file);
#endif
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/native/libs/System.Net.Security.Native/entrypoints.c | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include <minipal/entrypoints.h>
// Include System.Net.Security.Native headers
#include "pal_gssapi.h"
static const Entry s_securityNative[] =
{
DllImportEntry(NetSecurityNative_AcceptSecContext)
DllImportEntry(NetSecurityNative_AcquireAcceptorCred)
DllImportEntry(NetSecurityNative_DeleteSecContext)
DllImportEntry(NetSecurityNative_DisplayMajorStatus)
DllImportEntry(NetSecurityNative_DisplayMinorStatus)
DllImportEntry(NetSecurityNative_EnsureGssInitialized)
DllImportEntry(NetSecurityNative_GetUser)
DllImportEntry(NetSecurityNative_ImportPrincipalName)
DllImportEntry(NetSecurityNative_ImportUserName)
DllImportEntry(NetSecurityNative_InitiateCredSpNego)
DllImportEntry(NetSecurityNative_InitiateCredWithPassword)
DllImportEntry(NetSecurityNative_InitSecContext)
DllImportEntry(NetSecurityNative_InitSecContextEx)
DllImportEntry(NetSecurityNative_IsNtlmInstalled)
DllImportEntry(NetSecurityNative_ReleaseCred)
DllImportEntry(NetSecurityNative_ReleaseGssBuffer)
DllImportEntry(NetSecurityNative_ReleaseName)
DllImportEntry(NetSecurityNative_Unwrap)
DllImportEntry(NetSecurityNative_Wrap)
};
EXTERN_C const void* SecurityResolveDllImport(const char* name);
EXTERN_C const void* SecurityResolveDllImport(const char* name)
{
return minipal_resolve_dllimport(s_securityNative, ARRAY_SIZE(s_securityNative), name);
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include <minipal/entrypoints.h>
// Include System.Net.Security.Native headers
#include "pal_gssapi.h"
static const Entry s_securityNative[] =
{
DllImportEntry(NetSecurityNative_AcceptSecContext)
DllImportEntry(NetSecurityNative_AcquireAcceptorCred)
DllImportEntry(NetSecurityNative_DeleteSecContext)
DllImportEntry(NetSecurityNative_DisplayMajorStatus)
DllImportEntry(NetSecurityNative_DisplayMinorStatus)
DllImportEntry(NetSecurityNative_EnsureGssInitialized)
DllImportEntry(NetSecurityNative_GetUser)
DllImportEntry(NetSecurityNative_ImportPrincipalName)
DllImportEntry(NetSecurityNative_ImportUserName)
DllImportEntry(NetSecurityNative_InitiateCredSpNego)
DllImportEntry(NetSecurityNative_InitiateCredWithPassword)
DllImportEntry(NetSecurityNative_InitSecContext)
DllImportEntry(NetSecurityNative_InitSecContextEx)
DllImportEntry(NetSecurityNative_IsNtlmInstalled)
DllImportEntry(NetSecurityNative_ReleaseCred)
DllImportEntry(NetSecurityNative_ReleaseGssBuffer)
DllImportEntry(NetSecurityNative_ReleaseName)
DllImportEntry(NetSecurityNative_Unwrap)
DllImportEntry(NetSecurityNative_Wrap)
};
EXTERN_C const void* SecurityResolveDllImport(const char* name);
EXTERN_C const void* SecurityResolveDllImport(const char* name)
{
return minipal_resolve_dllimport(s_securityNative, ARRAY_SIZE(s_securityNative), name);
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/unit-tests/test-sgen-qsort.c | /*
* test-sgen-qsort.c: Unit test for quicksort.
*
* Copyright (C) 2013 Xamarin Inc
*
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "config.h"
#define HAVE_SGEN_GC
#include <mono/sgen/sgen-gc.h>
#include <mono/sgen/sgen-qsort.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <assert.h>
static int
compare_ints (const void *pa, const void *pb)
{
int a = *(const int*)pa;
int b = *(const int*)pb;
if (a < b)
return -1;
if (a == b)
return 0;
return 1;
}
typedef struct {
int key;
int val;
} teststruct_t;
static int
compare_teststructs (const void *pa, const void *pb)
{
int a = ((const teststruct_t*)pa)->key;
int b = ((const teststruct_t*)pb)->key;
if (a < b)
return -1;
if (a == b)
return 0;
return 1;
}
static int
compare_teststructs2 (const void *pa, const void *pb)
{
int a = (*((const teststruct_t**)pa))->key;
int b = (*((const teststruct_t**)pb))->key;
if (a < b)
return -1;
if (a == b)
return 0;
return 1;
}
DEF_QSORT_INLINE(test_struct, teststruct_t*, compare_teststructs)
static void
compare_sorts (void *base, size_t nel, size_t width, int (*compar) (const void*, const void*))
{
size_t len = nel * width;
void *b1 = malloc (len);
void *b2 = malloc (len);
memcpy (b1, base, len);
memcpy (b2, base, len);
mono_qsort (b1, nel, width, compar);
sgen_qsort (b2, nel, width, compar);
/* We can't assert that qsort and sgen_qsort produce the same results
* because qsort is not guaranteed to be stable, so they will tend to differ
* in adjacent equal elements. Instead, we assert that the array is sorted
* according to the comparator.
*/
for (size_t i = 0; i < nel - 1; ++i)
assert (compar ((char *)b2 + i * width, (char *)b2 + (i + 1) * width) <= 0);
free (b1);
free (b2);
}
static void
compare_sorts2 (void *base, size_t nel)
{
size_t width = sizeof (teststruct_t*);
size_t len = nel * width;
void *b1 = malloc (len);
void *b2 = malloc (len);
memcpy (b1, base, len);
memcpy (b2, base, len);
qsort (b1, nel, sizeof (teststruct_t*), compare_teststructs2);
qsort_test_struct ((teststruct_t **)b2, nel);
for (size_t i = 0; i < nel - 1; ++i)
assert (compare_teststructs2 ((char *)b2 + i * width, (char *)b2 + (i + 1) * width) <= 0);
free (b1);
free (b2);
}
#ifdef __cplusplus
extern "C"
#endif
int
test_sgen_qsort_main (void);
int
test_sgen_qsort_main (void)
{
int i;
for (i = 1; i < 4000; ++i) {
int a [i];
int j;
for (j = 0; j < i; ++j)
a [j] = i - j - 1;
compare_sorts (a, i, sizeof (int), compare_ints);
}
srandom (time (NULL));
for (i = 0; i < 2000; ++i) {
teststruct_t a [200];
int j;
for (j = 0; j < 200; ++j) {
a [j].key = random ();
a [j].val = random ();
}
compare_sorts (a, 200, sizeof (teststruct_t), compare_teststructs);
}
srandom (time (NULL));
for (i = 0; i < 2000; ++i) {
teststruct_t a [200];
teststruct_t *b [200];
int j;
for (j = 0; j < 200; ++j) {
a [j].key = random ();
a [j].val = random ();
b [j] = &a[j];
}
compare_sorts2 (b, 200);
}
return 0;
}
| /*
* test-sgen-qsort.c: Unit test for quicksort.
*
* Copyright (C) 2013 Xamarin Inc
*
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "config.h"
#define HAVE_SGEN_GC
#include <mono/sgen/sgen-gc.h>
#include <mono/sgen/sgen-qsort.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <assert.h>
static int
compare_ints (const void *pa, const void *pb)
{
int a = *(const int*)pa;
int b = *(const int*)pb;
if (a < b)
return -1;
if (a == b)
return 0;
return 1;
}
typedef struct {
int key;
int val;
} teststruct_t;
static int
compare_teststructs (const void *pa, const void *pb)
{
int a = ((const teststruct_t*)pa)->key;
int b = ((const teststruct_t*)pb)->key;
if (a < b)
return -1;
if (a == b)
return 0;
return 1;
}
static int
compare_teststructs2 (const void *pa, const void *pb)
{
int a = (*((const teststruct_t**)pa))->key;
int b = (*((const teststruct_t**)pb))->key;
if (a < b)
return -1;
if (a == b)
return 0;
return 1;
}
DEF_QSORT_INLINE(test_struct, teststruct_t*, compare_teststructs)
static void
compare_sorts (void *base, size_t nel, size_t width, int (*compar) (const void*, const void*))
{
size_t len = nel * width;
void *b1 = malloc (len);
void *b2 = malloc (len);
memcpy (b1, base, len);
memcpy (b2, base, len);
mono_qsort (b1, nel, width, compar);
sgen_qsort (b2, nel, width, compar);
/* We can't assert that qsort and sgen_qsort produce the same results
* because qsort is not guaranteed to be stable, so they will tend to differ
* in adjacent equal elements. Instead, we assert that the array is sorted
* according to the comparator.
*/
for (size_t i = 0; i < nel - 1; ++i)
assert (compar ((char *)b2 + i * width, (char *)b2 + (i + 1) * width) <= 0);
free (b1);
free (b2);
}
static void
compare_sorts2 (void *base, size_t nel)
{
size_t width = sizeof (teststruct_t*);
size_t len = nel * width;
void *b1 = malloc (len);
void *b2 = malloc (len);
memcpy (b1, base, len);
memcpy (b2, base, len);
qsort (b1, nel, sizeof (teststruct_t*), compare_teststructs2);
qsort_test_struct ((teststruct_t **)b2, nel);
for (size_t i = 0; i < nel - 1; ++i)
assert (compare_teststructs2 ((char *)b2 + i * width, (char *)b2 + (i + 1) * width) <= 0);
free (b1);
free (b2);
}
#ifdef __cplusplus
extern "C"
#endif
int
test_sgen_qsort_main (void);
int
test_sgen_qsort_main (void)
{
int i;
for (i = 1; i < 4000; ++i) {
int a [i];
int j;
for (j = 0; j < i; ++j)
a [j] = i - j - 1;
compare_sorts (a, i, sizeof (int), compare_ints);
}
srandom (time (NULL));
for (i = 0; i < 2000; ++i) {
teststruct_t a [200];
int j;
for (j = 0; j < 200; ++j) {
a [j].key = random ();
a [j].val = random ();
}
compare_sorts (a, 200, sizeof (teststruct_t), compare_teststructs);
}
srandom (time (NULL));
for (i = 0; i < 2000; ++i) {
teststruct_t a [200];
teststruct_t *b [200];
int j;
for (j = 0; j < 200; ++j) {
a [j].key = random ();
a [j].val = random ();
b [j] = &a[j];
}
compare_sorts2 (b, 200);
}
return 0;
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/unwind/ForcedUnwind.c | /* libunwind - a platform-independent unwind library
Copyright (C) 2003-2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind-internal.h"
_Unwind_Reason_Code
_Unwind_ForcedUnwind (struct _Unwind_Exception *exception_object,
_Unwind_Stop_Fn stop, void *stop_parameter)
{
struct _Unwind_Context context;
unw_context_t uc;
/* We check "stop" here to tell the compiler's inliner that
exception_object->private_1 isn't NULL when calling
_Unwind_Phase2(). */
if (!stop)
return _URC_FATAL_PHASE2_ERROR;
if (_Unwind_InitContext (&context, &uc) < 0)
return _URC_FATAL_PHASE2_ERROR;
exception_object->private_1 = (unsigned long) stop;
exception_object->private_2 = (unsigned long) stop_parameter;
return _Unwind_Phase2 (exception_object, &context);
}
_Unwind_Reason_Code __libunwind_Unwind_ForcedUnwind (struct _Unwind_Exception*,
_Unwind_Stop_Fn, void *)
ALIAS (_Unwind_ForcedUnwind);
| /* libunwind - a platform-independent unwind library
Copyright (C) 2003-2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind-internal.h"
_Unwind_Reason_Code
_Unwind_ForcedUnwind (struct _Unwind_Exception *exception_object,
_Unwind_Stop_Fn stop, void *stop_parameter)
{
struct _Unwind_Context context;
unw_context_t uc;
/* We check "stop" here to tell the compiler's inliner that
exception_object->private_1 isn't NULL when calling
_Unwind_Phase2(). */
if (!stop)
return _URC_FATAL_PHASE2_ERROR;
if (_Unwind_InitContext (&context, &uc) < 0)
return _URC_FATAL_PHASE2_ERROR;
exception_object->private_1 = (unsigned long) stop;
exception_object->private_2 = (unsigned long) stop_parameter;
return _Unwind_Phase2 (exception_object, &context);
}
_Unwind_Reason_Code __libunwind_Unwind_ForcedUnwind (struct _Unwind_Exception*,
_Unwind_Stop_Fn, void *)
ALIAS (_Unwind_ForcedUnwind);
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/mi/Lget_accessors.c | #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gget_accessors.c"
#endif
| #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gget_accessors.c"
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/ppc64/Linit.c | #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Ginit.c"
#endif
| #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Ginit.c"
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./docs/design/features/native-hosting.md | # Native hosting
Native hosting is the ability to host the .NET runtime in an arbitrary process, one which didn't start from .NET Core produced binaries.
#### Terminology
* "native host" - the code which uses the proposed APIs. Can be any non .NET Core application (.NET Core applications have easier ways to perform these scenarios).
* "hosting components" - shorthand for .NET Core hosting components. Typically refers to `hostfxr` and `hostpolicy`. Sometimes also referred to simply as "host".
* "host context" - state which `hostfxr` creates and maintains and represents a logical operation on the hosting components.
## Scenarios
* **Hosting managed components**
Native host which wants to load managed assembly and call into it for some functionality. Must support loading multiple such components side by side.
* **Hosting managed apps**
Native host which wants to run a managed app in-proc. Basically a different implementation of the existing .NET Core hosts (`dotnet.exe` or `apphost`). The intent is the ability to modify how the runtime starts and how the managed app is executed (and where it starts from).
* **App using other .NET Core hosting services**
App (native or .NET Core both) which needs to use some of the other services provided by the .NET Core hosting components. For example the ability to locate available SDKs and so on.
## Existing support
* **C-style ABI in `coreclr`**
`coreclr` exposes ABI to host the .NET runtime and run managed code already using C-style APIs. See this [header file](https://github.com/dotnet/runtime/blob/main/src/coreclr/hosts/inc/coreclrhost.h) for the exposed functions.
This API requires the native host to locate the runtime and to fully specify all startup parameters for the runtime. There's no inherent interoperability between these APIs and the .NET SDK.
* **COM-style ABI in `coreclr`**
`coreclr` exposes COM-style ABI to host the .NET runtime and perform a wide range of operations on it. See this [header file](https://github.com/dotnet/runtime/blob/main/src/coreclr/pal/prebuilt/inc/mscoree.h) for more details.
Similarly to the C-style ABI the COM-style ABI also requires the native host to locate the runtime and to fully specify all startup parameters.
There's no inherent interoperability between these APIs and the .NET SDK.
The COM-style ABI is deprecated and should not be used going forward.
* **`hostfxr` and `hostpolicy` APIs**
The hosting components of .NET Core already exposes some functionality as C-style ABI on either the `hostfxr` or `hostpolicy` libraries. These can execute application, determine available SDKs, determine native dependency locations, resolve component dependencies and so on.
Unlike the above `coreclr` based APIs these don't require the caller to fully specify all startup parameters, instead these APIs understand artifacts produced by .NET SDK making it much easier to consume SDK produced apps/libraries.
The native host is still required to locate the `hostfxr` or `hostpolicy` libraries. These APIs are also designed for specific narrow scenarios, any usage outside of these bounds is typically not possible.
## Scope
This document focuses on hosting which cooperates with the .NET SDK and consumes the artifacts produced by building the managed app/libraries directly. It completely ignores the COM-style ABI as it's hard to use from some programming languages.
As such the document explicitly excludes any hosting based on directly loading `coreclr`. Instead it focuses on using the existing .NET Core hosting components in new ways. For details on the .NET Core hosting components see [this document](https://github.com/dotnet/runtime/tree/main/docs/design/features/host-components.md).
## Longer term vision
This section describes how we think the hosting components should evolve. It is expected that this won't happen in any single release, but each change should fit into this picture and hopefully move us closer to this goal. It is also expected that existing APIs won't change (no breaking changes) and thus it can happen that some of the APIs don't fit nicely into the picture.
The hosting component APIs should provide functionality to cover a wide range of applications. At the same time it needs to stay in sync with what .NET Core SDK can produce so that the end-to-end experience is available.
The overall goal of hosting components is to enable loading and executing managed code, this consists of four main steps:
* **Locate and load hosting components** - How does a native host find and load the hosting components libraries.
* **Locate the managed code and all its dependencies** - Determining where the managed code comes from (application, component, ...), what frameworks it relies on (framework resolution) and what dependencies it needs (`.deps.json` processing)
* **Load the managed code into the process** - Specify the environment and settings for the runtime, locating or starting the runtime, deciding how to load the managed code into the runtime (which `AssemblyLoadContext` for example) and actually loading the managed code and its dependencies.
* **Accessing and executing managed code** - Locate the managed entry point (for example assembly entry point `Main`, or a specific method to call, or some other means to transition control to the managed code) and exposing it into the native code (function pointer, COM interface, direct execution, ...).
To achieve these we will structure the hosting components APIs into similar (but not exactly) 4 buckets.
### Locating hosting components
This means providing APIs to find and load the hosting components. The end result should be that the native host has the right version of `hostfxr` loaded and can call its APIs. The exact solution is dependent on the native host application and its tooling. Ideally we would have a solution which works great for several common environments like C/C++ apps built in VS, C/C++ apps on Mac/Linux built with CMake (or similar) and so on.
First step in this direction is the introduction of `nethost` library described below.
### Initializing host context
The end result of this step should be an initialized host context for a given managed code input which the native host can use to load the managed code and execute it. The step should not actually load any runtime or managed code into the process. Finally this step must handle both processes which don't have any runtime loaded as well as processes which already have runtime loaded.
Functionality performed by this step:
* Locating and understanding the managed code input (app/component)
* Resolving frameworks or handling self-contained
* Resolving dependencies (`.deps.json` processing)
* Populating runtime properties
The vision is to expose a set of APIs in the form of `hostfxr_initialize_for_...` which would all perform the above functionality and would differ on how the managed code is located and used. So there should be a different API for loading applications and components at the very least. Going forward we can add API which can initialize the context from in-memory configurations, or API which can initialize an "empty" context (no custom code involved, just frameworks) and so on.
First step in this direction is the introduction of these APIs as described below:
* `hostfxr_initialize_for_dotnet_command_line` - this is the initialize for an application. The API is a bit more complicated as it allows for command line parsing as well. Eventually we might want to add another "initialize app" API without the command line support.
* `hostfxr_initialize_for_runtime_config` - this is the initialize for a component (naming is not ideal, but can't be changed anymore).
After this step it should be possible for the native host to inspect and potentially modify runtime properties. APIs like `hostfxr_get_runtime_property_value` and similar described below are an example of this.
### Loading managed code
This step might be "virtual" in the sense that it's a way to setup the context for the desired functionality. In several scenarios it's not practical to be able to perform this step in separation from the "execute code" step below. The goal of this step is to determine which managed code to load, where it should be loaded into, and to setup the correct inputs so that runtime can perform the right dependency resolution.
Logically this step finds/loads the runtime and initializes it before it can load any managed code into the process.
The main flexibility this step should provide is to determine which assembly load context will be used for loading which code:
* Load all managed code into the default load context
* Load the specified custom managed code into an isolated load context
Eventually we could also add functionality for example to setup the isolated load context for unloadability and so on.
Note that there are no APIs proposed in this document which would only perform this step for now. All the APIs so far fold this step into the next one and perform both loading and executing of the managed code in one step. We should try to make this step more explicit in the future to allow for greater flexibility.
After this step it is no longer possible to modify runtime properties (inspection is still allowed) since the runtime has been loaded.
### Accessing and executing managed code
The end result of this step is either execution of the desired managed code, or returning a native callable representation of the managed code.
The different options should include at least:
* running an application (where the API takes over the thread and runs the application on behalf of the calling thread) - the `hostfxr_run_app` API described bellow is an example of this.
* getting a native function pointer to a managed method - the `hostfxr_get_runtime_delegate` and the `hdt_load_assembly_and_get_function_pointer` described below is an example of this.
* getting a native callable interface (COM) to a managed instance - the `hostfxr_get_runtime_delegate` and the `hdt_com_activation` described below is an example of this.
* and more...
### Combinations
Ideally it should be possible to combine the different types of initialization, loading and executing of managed code in any way the native host desires. In reality not all combinations are possible or practical. Few examples of combinations which we should probably NOT support (note that this may change in the future):
* running a component as an application - runtime currently makes too many assumptions on what it means to "Run an application"
* loading application into an isolated load context - for now there are too many limitations in the frameworks around secondary load contexts (several large framework features don't work well in a secondary ALC), so the hosting components should prevent this as a way to prevent users from getting into a bad situation.
* loading multiple copies of the runtime into the process - support for side-by-side loading of different .NET Core runtime in a single process is not something we want to implement (at least yet). Hosting components should not allow this to make the user experience predictable. This means that full support for loading self-contained components at all times is not supported.
Lot of other combinations will not be allowed simply as a result of shipping decisions. There's only so much functionality we can fit into any given release, so many combinations will be explicitly disabled to reduce the work necessary to actually ship this. The document below should describe which combinations are allowed in which release.
## High-level proposal
In .NET Core 3.0 the hosting components (see [here](https://github.com/dotnet/runtime/tree/main/docs/design/features/host-components.md)) ships with several hosts. These are binaries which act as the entry points to the .NET Core hosting components/runtime:
* The "muxer" (`dotnet.exe`)
* The `apphost` (`.exe` which is part of the app)
* The `comhost` (`.dll` which is part of the app and acts as COM server)
* The `ijwhost` (`.dll` consumed via `.lib` used by IJW assemblies)
Every one of these hosts serve different scenario and expose different APIs. The one thing they have in common is that their main purpose is to find the right `hostfxr`, load it and call into it to execute the desired scenario. For the most part all these hosts are basically just wrappers around functionality provided by `hostfxr`.
The proposal is to add a new host library `nethost` which can be used by native host to easily locate `hostfxr`. Going forward the library could also include easy-to-use APIs for common scenarios - basically just a simplification of the `hostfxr` API surface.
At the same time add the ability to pass additional runtime properties when starting the runtime through the hosting components APIs (starting app, loading component). This can be used by the native host to:
* Register startup hook without modifying environment variables (which are inherited by child processes)
* Introduce new runtime knobs which are only available for native hosts without the need to update the hosting components APIs every time.
*Technical note: All strings in the proposed APIs are using the `char_t` in this document for simplicity. In real implementation they are of the type `pal::char_t`. In particular:*
* *On Windows - they are `WCHAR *` using `UTF16` encoding*
* *On Linux/macOS - they are `char *` using `UTF8` encoding*
## New host binary for finding `hostfxr`
New library `nethost` which provides a way to locate the right `hostfxr`.
This is a dynamically loaded library (`.dll`, `.so`, `.dylib`). For ease of use there is a header file for C/C++ apps as well as `.lib` for easy linking on Windows.
Native hosts ship this library as part of the app. Unlike the `apphost`, `comhost` and `ijwhost`, the `nethost` will not be directly supported by the .NET SDK since it's target usage is not from .NET Core apps.
The `nethost` is part of the `Microsoft.NETCore.DotNetAppHost` package. Users are expected to either download the package directly or rely on .NET SDK to pull it down.
The binary itself should be signed by Microsoft as there will be no support for modifying the binary as part of custom application build (unlike `apphost`).
### Locate `hostfxr`
``` C++
struct get_hostfxr_parameters {
size_t size;
const char_t * assembly_path;
const char_t * dotnet_root;
};
int get_hostfxr_path(
char_t * result_buffer,
size_t * buffer_size,
const get_hostfxr_parameters * parameters);
```
This API locates the `hostfxr` library and returns its path by populating `result_buffer`.
* `result_buffer` - Buffer that will be populated with the hostfxr path, including a null terminator.
* `buffer_size` - On input this points to the size of the `result_buffer` in `char_t` units. On output this points to the number of `char_t` units used from the `result_buffer` (including the null terminator). If `result_buffer` is `NULL` the input value is ignored and only the minimum required size in `char_t` units is set on output.
* `parameters` - Optional. Additional parameters that modify the behaviour for locating the `hostfxr` library. If `NULL`, `hostfxr` is located using the environment variable or global registration
* `size` - Size of the structure. This is used for versioning and should be set to `sizeof(get_hostfxr_parameters)`.
* `assembly_path` - Optional. Path to the application or to the component's assembly.
* If specified, `hostfxr` is located as if the `assembly_path` is an application with `apphost`
* `dotnet_root` - Optional. Path to the root of a .NET Core installation (i.e. folder containing the dotnet executable).
* If specified, `hostfxr` is located as if an application is started using `dotnet app.dll`, which means it will be searched for under the `dotnet_root` path and the `assembly_path` is ignored.
`nethost` library uses the `__stdcall` calling convention.
## Improve API to run application and load components
### Goals
* All hosts should be able to use the new API (whether they will is a separate question as the old API has to be kept for backward compat reasons)
* Hide implementation details as much as possible
* Make the API generally easier to use/understand
* Give the implementation more freedom
* Allow future improvements without breaking the API
* Consider explicitly documenting types of behaviors which nobody should take dependency on (specifically failure scenarios)
* Extensible
* It should allow additional parameters to some of the operations without a need to add new exported APIs
* It should allow additional interactions with the host - for example modifying how the runtime is initialized via some new options, without a need for a completely new set of APIs
### New scenarios
The API should allow these scenarios:
* Runtime properties
* Specify additional runtime properties from the native host
* Implement conflict resolution for runtime properties
* Inspect calculated runtime properties (the ones calculated by `hostfxr`/`hostpolicy`)
* Load managed component and get native function pointer for managed method
* From native app start the runtime and load an assembly
* The assembly is loaded in isolation and with all its dependencies as directed by `.deps.json`
* The native app can get back a native function pointer which calls specified managed method
* Get native function pointer for managed method
* From native code get a native function pointer to already loaded managed method
All the proposed APIs will be exports of the `hostfxr` library and will use the same calling convention and name mangling as existing `hostfxr` exports.
### Initialize host context
All the "initialize" functions will
* Process the `.runtimeconfig.json`
* Resolve framework references and find actual frameworks
* Find the root framework (`Microsoft.NETCore.App`) and load the `hostpolicy` from it
* The `hostpolicy` will then process all relevant `.deps.json` files and produce the list of assemblies, native search paths and other artifacts needed to initialize the runtime.
The functions will NOT load the CoreCLR runtime. They just prepare everything to the point where it can be loaded.
The functions return a handle to a new host context:
* The handle must be closed via `hostfxr_close`.
* The handle is not thread safe - the consumer should only call functions on it from one thread at a time.
The `hostfxr` will also track active runtime in the process. Due to limitations (and to simplify implementation) this tracking will actually not look at the actual `coreclr` module (or try to communicate with the runtime in any way). Instead `hostfxr` itself will track the host context initialization. The first host context initialization in the process will represent the "loaded runtime". It is only possible to have one "loaded runtime" in the process. Any subsequent host context initialization will just "attach" to the "loaded runtime" instead of creating a new one.
``` C
typedef void* hostfxr_handle;
struct hostfxr_initialize_parameters
{
size_t size;
const char_t * host_path;
const char_t * dotnet_root;
};
```
The `hostfxr_initialize_parameters` structure stores parameters which are common to all forms of initialization.
* `size` - the size of the structure. This is used for versioning. Should be set to `sizeof(hostfxr_initialize_parameters)`.
* `host_path` - path to the native host (typically the `.exe`). This value is not used for anything by the hosting components. It's just passed to the CoreCLR as the path to the executable. It can point to a file which is not executable itself, if such file doesn't exist (for example in COM activation scenarios this points to the `comhost.dll`). This is used by PAL to initialize internal command line structures, process name and so on.
* `dotnet_root` - path to the root of the .NET Core installation in use. This typically points to the install location from which the `hostfxr` has been loaded. For example on Windows this would typically point to `C:\Program Files\dotnet`. The path is used to search for shared frameworks and potentially SDKs.
``` C
int hostfxr_initialize_for_dotnet_command_line(
int argc,
const char_t * argv[],
const hostfxr_initialize_parameters * parameters,
hostfxr_handle * host_context_handle
);
```
Initializes the hosting components for running a managed application.
The command line is parsed to determine the app path. The app path will be used to locate the `.runtimeconfig.json` and the `.deps.json` which will be used to load the application and its dependent frameworks.
* `argc` and `argv` - the command line for running a managed application. These represent the arguments which would have been passed to the muxer if the app was being run from the command line. These are the parameters which are valid for the runtime installation by itself - SDK/CLI commands are not supported. For example, the arguments could be `app.dll app_argument_1 app_argument_2`. This API specifically doesn't support the `dotnet run` SDK command.
* `parameters` - additional parameters - see `hostfxr_initialize_parameters` for details. (Could be made optional potentially)
* `host_context_handle` - output parameter. On success receives an opaque value which identifies the initialized host context. The handle should be closed by calling `hostfxr_close`.
This function only supports arguments for running an application as through the muxer. It does not support SDK commands.
This function can only be called once per-process. It's not supported to run multiple apps in one process (even sequentially).
This function will fail if there already is a CoreCLR running in the process as it's not possible to run two apps in a single process.
This function supports both framework-dependent and self-contained applications.
*Note: This is effectively a replacement for `hostfxr_main_startupinfo` and `hostfxr_main`. Currently it is not a goal to fully replace these APIs because they also support SDK commands which are special in lot of ways and don't fit well with the rest of the native hosting. There's no scenario right now which would require the ability to issue SDK commands from a native host. That said nothing in this proposal should block enabling even SDK commands through these APIs.*
``` C
int hostfxr_initialize_for_runtime_config(
const char_t * runtime_config_path,
const hostfxr_initialize_parameters * parameters,
hostfxr_handle * host_context_handle
);
```
This function would load the specified `.runtimeconfig.json`, resolve all frameworks, resolve all the assets from those frameworks and then prepare runtime initialization where the TPA contains only frameworks. Note that this case does NOT consume any `.deps.json` from the app/component (only processes the framework's `.deps.json`). This entry point is intended for `comhost`/`ijwhost`/`nethost` and similar scenarios.
* `runtime_config_path` - path to the `.runtimeconfig.json` file to process. Unlike with `hostfxr_initialize_for_dotnet_command_line`, any `.deps.json` from the app/component will not be processed by the hosting components during the initialize call.
* `parameters` - additional parameters - see `hostfxr_initialize_parameters` for details. (Could be made optional potentially)
* `host_context_handle` - output parameter. On success receives an opaque value which identifies the initialized host context. The handle should be closed by calling `hostfxr_close`.
This function can be called multiple times in a process.
* If it's called when no runtime is present, it will run through the steps to "initialize" the runtime (resolving frameworks and so on).
* If it's called when there already is CoreCLR in the process (loaded through the `hostfxr`, direct usage of `coreclr` is not supported), then the function determines if the specified runtime configuration is compatible with the existing runtime and frameworks. If it is, it returns a valid handle, otherwise it fails.
It needs to be possible to call this function simultaneously from multiple threads at the same time.
It also needs to be possible to call this function while there is an active host context created by `hostfxr_initialize_for_dotnet_command_line` and running inside the `hostfxr_run_app`.
The function returns specific return code for the first initialized host context, and a different one for any subsequent one. Both return codes are considered "success". If there already was initialized host context in the process then the returned host context has these limitations:
* It won't allow setting runtime properties.
* The initialization will compare the runtime properties from the `.runtimeconfig.json` specified in the `runtime_config_path` with those already set to the runtime in the process
* If all properties from the new runtime config are already set and have the exact same values (case sensitive string comparison), the initialization succeeds with no additional consequences. (Note that this is the most typical case where the runtime config have no properties in it.)
* If there are either new properties which are not set in the runtime or ones which have different values, the initialization will return a special return code - a "warning". It's not a full on failure as initialized context will be returned.
* In both cases only the properties specified by the new runtime config will be reported on the host context. This is to allow the native host to decide in the "warning" case if it's OK to let the component run or not.
* In both cases the returned host context can still be used to get a runtime delegate, the properties from the new runtime config will be ignored (as there's no way to modify those in the runtime).
The specified `.runtimeconfig.json` must be for a framework dependent component. That is it must specify at least one shared framework in its `frameworks` section. Self-contained components are not supported.
### Inspect and modify host context
#### Runtime properties
These functions allow the native host to inspect and modify runtime properties.
* If the `host_context_handle` represents the first initialized context in the process, these functions expose all properties from runtime configurations as well as those computed by the hosting components. These functions will allow modification of the properties via `hostfxr_set_runtime_property_value`.
* If the `host_context_handle` represents any other context (so not the first one), these functions expose only properties from runtime configuration. These functions won't allow modification of the properties.
It is possible to access runtime properties of the first initialized context in the process at any time (for reading only), by specifying `NULL` as the `host_context_handle`.
``` C
int hostfxr_get_runtime_property_value(
const hostfxr_handle host_context_handle,
const char_t * name,
const char_t ** value);
```
Returns the value of a runtime property specified by its name.
* `host_context_handle` - the initialized host context. If set to `NULL` the function will operate on runtime properties of the first host context in the process.
* `name` - the name of the runtime property to get. Must not be `NULL`.
* `value` - returns a pointer to a buffer with the property value. The buffer is owned by the host context. The caller should make a copy of it if it needs to store it for anything longer than immediate consumption. The lifetime is only guaranteed until any of the below happens:
* one of the "run" methods is called on the host context
* the host context is closed via `hostfxr_close`
* the value of the property is changed via `hostfxr_set_runtime_property_value`
Trying to get a property which doesn't exist is an error and will return an appropriate error code.
We're proposing a fix in `hostpolicy` which will make sure that there are no duplicates possible after initialization (see [dotnet/core-setup#5529](https://github.com/dotnet/core-setup/issues/5529)). With that `hostfxr_get_runtime_property_value` will work always (as there can only be one value).
``` C
int hostfxr_set_runtime_property_value(
const hostfxr_handle host_context_handle,
const char_t * name,
const char_t * value);
```
Sets the value of a property.
* `host_context_handle` - the initialized host context. (Must not be `NULL`)
* `name` - the name of the runtime property to set. Must not be `NULL`.
* `value` - the value of the property to set. If the property already has a value in the host context, this function will overwrite it. When set to `NULL` and if the property already has a value then the property is "unset" - removed from the runtime property collection.
Setting properties is only supported on the first host context in the process. This is really a limitation of the runtime for which the runtime properties are immutable. Once the first host context is initialized and starts a runtime there's no way to change these properties. For now we will not consider the scenario where the host context is initialized but the runtime hasn't started yet, mainly for simplicity of implementation and lack of requirements.
``` C
int hostfxr_get_runtime_properties(
const hostfxr_handle host_context_handle,
size_t * count,
const char_t **keys,
const char_t **values);
```
Returns the full set of all runtime properties for the specified host context.
* `host_context_handle` - the initialized host context. If set to `NULL` the function will operate on runtime properties of the first host context in the process.
* `count` - in/out parameter which must not be `NULL`. On input it specifies the size of the the `keys` and `values` buffers. On output it contains the number of entries used from `keys` and `values` buffers - the number of properties returned. If the size of the buffers is too small, the function returns a specific error code and fill the `count` with the number of available properties. If `keys` or `values` is `NULL` the function ignores the input value of `count` and just returns the number of properties.
* `keys` - buffer which acts as an array of pointers to buffers with keys for the runtime properties.
* `values` - buffer which acts as an array of pointer to buffers with values for the runtime properties.
`keys` and `values` store pointers to buffers which are owned by the host context. The caller should make a copy of it if it needs to store it for anything longer than immediate consumption. The lifetime is only guaranteed until any of the below happens:
* one of the "run" methods is called on the host context
* the host context is closed via `hostfxr_close`
* the value or existence of any property is changed via `hostfxr_set_runtime_property_value`
Note that `hostfxr_set_runtime_property_value` can remove or add new properties, so the number of properties returned is only valid as long as no properties were added/removed.
### Start the runtime
#### Running an application
``` C
int hostfxr_run_app(const hostfxr_handle host_context_handle);
```
Runs the application specified by the `hostfxr_initialize_for_dotnet_command_line`. It is illegal to try to use this function when the host context was initialized through any other way.
* `host_context_handle` - handle to the initialized host context.
The function will return only once the managed application exits.
`hostfxr_run_app` cannot be used in combination with any other "run" function. It can also only be called once.
#### Getting a delegate for runtime functionality
``` C
int hostfxr_get_runtime_delegate(const hostfxr_handle host_context_handle, hostfxr_delegate_type type, void ** delegate);
```
Starts the runtime and returns a function pointer to specified functionality of the runtime.
* `host_context_handle` - handle to the initialized host context.
* `type` - the type of runtime functionality requested
* `hdt_load_assembly_and_get_function_pointer` - entry point which loads an assembly (with dependencies) and returns function pointer for a specified static method. See below for details (Loading and calling managed components)
* `hdt_com_activation`, `hdt_com_register`, `hdt_com_unregister` - COM activation entry-points - see [COM activation](https://github.com/dotnet/runtime/tree/main/docs/design/features/COM-activation.md) for more details.
* `hdt_load_in_memory_assembly` - IJW entry-point - see [IJW activation](https://github.com/dotnet/runtime/tree/main/docs/design/features/IJW-activation.md) for more details.
* `hdt_winrt_activation` **[.NET 3.\* only]** - WinRT activation entry-point - see [WinRT activation](https://github.com/dotnet/runtime/tree/main/docs/design/features/WinRT-activation.md) for more details. The delegate is not supported for .NET 5 and above.
* `hdt_get_function_pointer` **[.NET 5 and above]** - entry-point which finds a managed method and returns a function pointer to it. See below for details (Calling managed function).
* `delegate` - when successful, the native function pointer to the requested runtime functionality.
In .NET Core 3.0 the function only works if `hostfxr_initialize_for_runtime_config` was used to initialize the host context.
In .NET 5 the function also works if `hostfxr_initialize_for_dotnet_command_line` was used to initialize the host context. Also for .NET 5 it will only be allowed to request `hdt_load_assembly_and_get_function_pointer` or `hdt_get_function_pointer` on a context initialized via `hostfxr_initialize_for_dotnet_command_line`, all other runtime delegates will not be supported in this case.
### Cleanup
``` C
int hostfxr_close(const hostfxr_handle host_context_handle);
```
Closes a host context.
* `host_context_handle` - handle to the initialized host context to close.
### Loading and calling managed components
To load managed components from native app directly (not using COM or WinRT) the hosting components exposes a new runtime helper/delegate `hdt_load_assembly_and_get_function_pointer`. Calling the `hostfxr_get_runtime_delegate(handle, hdt_load_assembly_and_get_function_pointer, &helper)` returns a function pointer to the runtime helper with this signature:
```C
int load_assembly_and_get_function_pointer_fn(
const char_t *assembly_path,
const char_t *type_name,
const char_t *method_name,
const char_t *delegate_type_name,
void *reserved,
/*out*/ void **delegate)
```
Calling this function will load the specified assembly in isolation (into its own `AssemblyLoadContext`) and it will use `AssemblyDependencyResolver` on it to provide dependency resolution. Once loaded it will find the specified type and method and return a native function pointer to that method. The method's signature can be specified via the delegate type name.
* `assembly_path` - Path to the assembly to load. In case of complex component, this should be the main assembly of the component (the one with the `.deps.json` next to it). Note that this does not have to be the assembly from which the `type_name` and `method_name` are.
* `type_name` - Assembly qualified type name to find
* `method_name` - Name of the method on the `type_name` to find. The method must be `static` and must match the signature of `delegate_type_name`.
* `delegate_type_name` - Assembly qualified delegate type name for the method signature, or null. If this is null, the method signature is assumed to be:
```C#
public delegate int ComponentEntryPoint(IntPtr args, int sizeBytes);
```
This maps to native signature:
```C
int component_entry_point_fn(void *arg, int32_t arg_size_in_bytes);
```
**[.NET 5 and above]** The `delegate_type_name` can be also specified as `UNMANAGEDCALLERSONLY_METHOD` (defined as `(const char_t*)-1`) which means that the managed method is marked with `UnmanagedCallersOnlyAttribute`.
* `reserved` - parameter reserved for future extensibility, currently unused and must be `NULL`.
* `delegate` - out parameter which receives the native function pointer to the requested managed method.
The helper will always load the assembly into an isolated load context. This is the case regardless if the requested assembly is also available in the default load context or not.
**[.NET 5 and above]** It is allowed to call this helper on a host context which came from `hostfxr_initialize_for_dotnet_command_line` which will make all the application assemblies available in the default load context. In such case it is recommended to only use this helper for loading plugins external to the application. Using the helper to load assembly from the application itself will lead to duplicate copies of assemblies and duplicate types.
It is allowed to call the returned runtime helper many times for different assemblies or different methods from the same assembly. It is not required to get the helper every time. The implementation of the helper will cache loaded assemblies, so requests to load the same assembly twice will load it only once and reuse it from that point onward. Ideally components should not take a dependency on this behavior, which means components should not have global state. Global state in components is typically just cause for problems. For example it may create ordering issues or unintended side effects and so on.
The returned native function pointer to managed method has the lifetime of the process and can be used to call the method many times over. Currently there's no way to unload the managed component or otherwise free the native function pointer. Such support may come in future releases.
### Calling managed function **[.NET 5 and above]**
In .NET 5 the hosting components add a new functionality which allows just getting a native function pointer for already available managed method. This is implemented in a runtime helper `hdt_get_function_pointer`. Calling the `hostfxr_get_runtime_delegate(handle, hdt_get_function_pointer, &helper)` returns a function pointer to the runtime helper with this signature:
```C
int get_function_pointer_fn(
const char_t *type_name,
const char_t *method_name,
const char_t *delegate_type_name,
void *load_context,
void *reserved,
/*out*/ void **delegate)
```
Calling this function will find the specified type in the default load context, locate the required method on it and return a native function pointer to that method. The method's signature can be specified via the delegate type name.
* `type_name` - Assembly qualified type name to find
* `method_name` - Name of the method on the `type_name` to find. The method must be `static` and must match the signature of `delegate_type_name`.
* `delegate_type_name` - Assembly qualified delegate type name for the method signature, or null. If this is null, the method signature is assumed to be:
```C#
public delegate int ComponentEntryPoint(IntPtr args, int sizeBytes);
```
This maps to native signature:
```C
int component_entry_point_fn(void *arg, int32_t arg_size_in_bytes);
```
The `delegate_type_name` can be also specified as `UNMANAGEDCALLERSONLY_METHOD` (defined as `(const char_t*)-1`) which means that the managed method is marked with `UnmanagedCallersOnlyAttribute`.
* `load_context` - eventually this parameter should support specifying which load context should be used to locate the type/method specified in previous parameters. For .NET 5 this parameter must be `NULL` and the API will only locate the type/method in the default load context.
* `reserved` - parameter reserved for future extensibility, currently unused and must be `NULL`.
* `delegate` - out parameter which receives the native function pointer to the requested managed method.
The helper will lookup the `type_name` from the default load context (`AssemblyLoadContext.Default`) and then return method on it. If the type and method lookup requires assemblies which have not been loaded by the Default ALC yet, this process will resolve them against the Default ALC and load them there (most likely from TPA). This helper will not register any additional assembly resolution logic onto the Default ALC, it will solely rely on the existing functionality of the Default ALC.
It is allowed to ask for this helper on any valid host context. Because the helper operates on default load context only it should mostly be used with context initialized via `hostfxr_initialize_for_dotnet_command_line` as in that case the default load context will have the application code available in it. Contexts initialized via `hostfxr_initialize_for_runtime_config` have only the framework assemblies available in the default load context. The `type_name` must resolve within the default load context, so in the case where only framework assemblies are loaded into the default load context it would have to come from one of the framework assemblies only.
It is allowed to call the returned runtime helper many times for different types or methods. It is not required to get the helper every time.
The returned native function pointer to managed method has the lifetime of the process and can be used to call the method many times over. Currently there's no way to "release" the native function pointer (and the respective managed delegate), this functionality may be added in a future release.
### Multiple host contexts interactions
It is important to correctly synchronize some of these operations to achieve the desired API behavior as well as thread safety requirements. The following behaviors will be used to achieve this.
#### Terminology
* `first host context` is the one which is used to load and initialize the CoreCLR runtime in the process. At any given time there can only be one `first host context`.
* `secondary host context` is any other initialized host context when `first host context` already exists in the process.
#### Synchronization
* If there's no `first host context` in the process the first call to `hostfxr_initialize_...` will create a new `first host context`. There can only be one `first host context` in existence at any point in time.
* Calling `hostfxr_initialize...` when `first host context` already exists will always return a `secondary host context`.
* The `first host context` blocks creation of any other host context until it is used to load and initialize the CoreCLR runtime. This means that `hostfxr_initialize...` and subsequently one of the "run" methods must be called on the `first host context` to unblock creation of `secondary host contexts`.
* Calling `hostfxr_initialize...` will block until the `first host context` is initialized, a "run" method is called on it and the CoreCLR is loaded and initialized. The `hostfxr_initialize...` will block potentially indefinitely. The method will block very early on. All of the operations done by the initialize will only happen once it's unblocked.
* `first host context` can fail to initialize the runtime (or anywhere up to that point). If this happens, it's marked as failed and is not considered a `first host context` anymore. This unblocks the potentially waiting `hostfxr_initialize...` calls. In this case the first `hostfxr_initialize...` after the failure will create a new `first host context`.
* `first host context` can be closed using `hostfxr_close` before it is used to initialize the CoreCLR runtime. This is similar to the failure above, the host context is marked as "closed/failed" and is not considered `first host context` anymore. This unblocks any waiting `hostfxr_initialize...` calls.
* Once the `first host context` successfully initialized the CoreCLR runtime it is permanently marked as "successful" and will remain the `first host context` for the lifetime of the process. Such host context should still be closed once not needed via `hostfxr_close`.
#### Invalid usage
* It is invalid to initialize a host context via `hostfxr_initialize...` and then never call `hostfxr_close` on it. An initialized but not closed host context is considered abandoned. Abandoned `first host context` will cause infinite blocking of any future `hostfxr_initialize...` calls.
#### Important scenarios
The above behaviors should make sure that some important scenarios are possible and work reliably.
One such scenario is a COM host on multiple threads. The app is not running any .NET Core yet (no CoreCLR loaded). On two threads in parallel COM activation is invoked which leads to two invocations into the `comhost` to active .NET Core objects. The `comhost` will use the `hostfxr_initialize...` and `hostfxr_get_runtime_delegate` APIs on two threads in parallel then. Only one of them can load and initialize the runtime (and also perform full framework resolution and determine the framework versions and assemblies to load). The other has to become a `secondary host context` and try to conform to the first one. The above behavior of `hostfxr_initialize...` blocking until the `first host context` is done initializing the runtime will make sure of the correct behavior in this case.
At the same time it gives the native app (`comhost` in this case) the ability to query and modify runtime properties in between the `hostfxr_initialize...` and `hostfxr_get_runtime_delegate` calls on the `first host context`.
### API usage
The `hostfxr` exports are defined in the [hostfxr.h](https://github.com/dotnet/runtime/blob/main/src/native/corehost/hostfxr.h) header file.
The runtime helper and method signatures for loading managed components are defined in [coreclr_delegates.h](https://github.com/dotnet/runtime/blob/main/src/native/corehost/coreclr_delegates.h) header file.
Currently we don't plan to ship these files, but it's possible to take them from the repo and use it.
### Support for older versions
Since `hostfxr` and the other hosting components are versioned independently there are several interesting cases of version mismatches:
#### muxer/`apphost` versus `hostfxr`
For muxer it should almost always match, but `apphost` can be different. That is, it's perfectly valid to use older 2.* `apphost` with a new 3.0 `hostfxr`. The opposite should be rare, but in theory can happen as well. To keep the code simple both muxer and `apphost` will keep using the existing 2.* APIs on `hostfxr` even in situation where both are 3.0 and thus could start using the new APIs.
`hostfxr` must be backward compatible and support 2.* APIs.
Potentially we could switch just `apphost` to use the new APIs (since it doesn't have the same compatibility burden as the muxer), but it's probably safer to not do that.
#### `hostfxr` versus `hostpolicy`
It should really only happen that `hostfxr` is equal or newer than `hostpolicy`. The opposite should be very rare. In any case `hostpolicy` should support existing 2.* APIs and thus the rare case will keep working anyway.
The interesting case is 3.0 `hostfxr` using 2.* `hostpolicy`. This will be very common, basically any 2.* app running on a machine with 3.0 installed will be in that situation. This case has two sub-cases:
* `hostfxr` is invoked using one of the 2.* APIs. In this case the simple solution is to keep using the 2.* `hostpolicy` APIs always.
* `hostfxr` is invoked using one of the new 3.0 APIs (like `hostfxr_initialize...`). In this case it's not possible to completely support the new APIs, since they require new functionality from `hostpolicy`. For now the `hostfxr` should simply fail.
It is in theory possible to support some kind of emulation mode where for some scenarios the new APIs would work even with old `hostpolicy`, but for simplicity it's better to start with just failing.
#### Implementation of existing 2.* APIs in `hostfxr`
The existing 2.* APIs in `hostfxr` could switch to internally use the new functionality and in turn use the new 3.0 `hostpolicy` APIs. The tricky bit here is scenario like this:
* 3.0 App is started via `apphost` or muxer which as mentioned above will keep on using the 2.* `hostfxr` APIs. This will load CoreCLR into the process.
* COM component is activated in the same process. This will go through the new 3.0 `hostfxr` APIs, and to work correctly will require the internal representation of the `first host context`.
If the 2.* `hostfxr` APIs would continue to use the old 2.* `hostpolicy` APIs even if `hostpolicy` is new, then the above scenario will be hard to achieve as there will be no `first host context`. `hostpolicy` could somehow "emulate" the `first host context`, but without `hostpolicy` cooperation this would be hard.
On the other hand switching to use the new `hostpolicy` APIs even in 2.* `hostfxr` APIs is risky for backward compatibility. This will have to be decided during implementation.
### Samples
All samples assume that the native host has found the `hostfxr`, loaded it and got the exports (possibly by using the `nethost`).
Samples in general ignore error handling.
#### Running app with additional runtime properties
``` C++
hostfxr_initialize_parameters params;
params.size = sizeof(params);
params.host_path = get_path_to_the_host_exe(); // Path to the current executable
params.dotnet_root = get_directory(get_directory(get_directory(hostfxr_path))); // Three levels up from hostfxr typically
hostfxr_handle host_context_handle;
hostfxr_initialize_for_dotnet_command_line(
_argc_,
_argv_, // For example, 'app.dll app_argument_1 app_argument_2'
¶ms,
&host_context_handle);
size_t buffer_used = 0;
if (hostfxr_get_runtime_property(host_context_handle, "TEST_PROPERTY", NULL, 0, &buffer_used) == HostApiMissingProperty)
{
hostfxr_set_runtime_property(host_context_handle, "TEST_PROPERTY", "TRUE");
}
hostfxr_run_app(host_context_handle);
hostfxr_close(host_context_handle);
```
#### Getting a function pointer to call a managed method
```C++
using load_assembly_and_get_function_pointer_fn = int (STDMETHODCALLTYPE *)(
const char_t *assembly_path,
const char_t *type_name,
const char_t *method_name,
const char_t *delegate_type_name,
void *reserved,
void **delegate);
hostfxr_handle host_context_handle;
hostfxr_initialize_for_runtime_config(config_path, NULL, &host_context_handle);
load_assembly_and_get_function_pointer_fn runtime_delegate = NULL;
hostfxr_get_runtime_delegate(
host_context_handle,
hostfxr_delegate_type::load_assembly_and_get_function_pointer,
(void **)&runtime_delegate);
using managed_entry_point_fn = int (STDMETHODCALLTYPE *)(void *arg, int argSize);
managed_entry_point_fn entry_point = NULL;
runtime_delegate(assembly_path,
type_name,
method_name,
NULL,
NULL,
(void **)&entry_point);
ArgStruct arg;
entry_point(&arg, sizeof(ArgStruct));
hostfxr_close(host_context_handle);
```
## Impact on hosting components
The exact impact on the `hostfxr`/`hostpolicy` interface needs to be investigated. The assumption is that new APIs will have to be added to `hostpolicy` to implement the proposed functionality.
Part if this investigation will also be compatibility behavior. Currently "any" version of `hostfxr` needs to be able to use "any" version of `hostpolicy`. But the proposed functionality will need both new `hostfxr` and new `hostpolicy` to work. It is likely the proposed APIs will fail if the app resolves to a framework with old `hostpolicy` without the necessary new APIs. Part of the investigation will be if it's feasible to use the new `hostpolicy` APIs to implement existing old `hostfxr` APIs.
## Incompatible with trimming
Native hosting support on managed side is disabled by default on trimmed apps. Native hosting and trimming are incompatible since the trimmer cannot analyze methods that are called by native hosts. Native hosting support for trimming can be managed through the [feature switch](https://github.com/dotnet/runtime/blob/main/docs/workflow/trimming/feature-switches.md) settings specific to each native host.
| # Native hosting
Native hosting is the ability to host the .NET runtime in an arbitrary process, one which didn't start from .NET Core produced binaries.
#### Terminology
* "native host" - the code which uses the proposed APIs. Can be any non .NET Core application (.NET Core applications have easier ways to perform these scenarios).
* "hosting components" - shorthand for .NET Core hosting components. Typically refers to `hostfxr` and `hostpolicy`. Sometimes also referred to simply as "host".
* "host context" - state which `hostfxr` creates and maintains and represents a logical operation on the hosting components.
## Scenarios
* **Hosting managed components**
Native host which wants to load managed assembly and call into it for some functionality. Must support loading multiple such components side by side.
* **Hosting managed apps**
Native host which wants to run a managed app in-proc. Basically a different implementation of the existing .NET Core hosts (`dotnet.exe` or `apphost`). The intent is the ability to modify how the runtime starts and how the managed app is executed (and where it starts from).
* **App using other .NET Core hosting services**
App (native or .NET Core both) which needs to use some of the other services provided by the .NET Core hosting components. For example the ability to locate available SDKs and so on.
## Existing support
* **C-style ABI in `coreclr`**
`coreclr` exposes ABI to host the .NET runtime and run managed code already using C-style APIs. See this [header file](https://github.com/dotnet/runtime/blob/main/src/coreclr/hosts/inc/coreclrhost.h) for the exposed functions.
This API requires the native host to locate the runtime and to fully specify all startup parameters for the runtime. There's no inherent interoperability between these APIs and the .NET SDK.
* **COM-style ABI in `coreclr`**
`coreclr` exposes COM-style ABI to host the .NET runtime and perform a wide range of operations on it. See this [header file](https://github.com/dotnet/runtime/blob/main/src/coreclr/pal/prebuilt/inc/mscoree.h) for more details.
Similarly to the C-style ABI the COM-style ABI also requires the native host to locate the runtime and to fully specify all startup parameters.
There's no inherent interoperability between these APIs and the .NET SDK.
The COM-style ABI is deprecated and should not be used going forward.
* **`hostfxr` and `hostpolicy` APIs**
The hosting components of .NET Core already exposes some functionality as C-style ABI on either the `hostfxr` or `hostpolicy` libraries. These can execute application, determine available SDKs, determine native dependency locations, resolve component dependencies and so on.
Unlike the above `coreclr` based APIs these don't require the caller to fully specify all startup parameters, instead these APIs understand artifacts produced by .NET SDK making it much easier to consume SDK produced apps/libraries.
The native host is still required to locate the `hostfxr` or `hostpolicy` libraries. These APIs are also designed for specific narrow scenarios, any usage outside of these bounds is typically not possible.
## Scope
This document focuses on hosting which cooperates with the .NET SDK and consumes the artifacts produced by building the managed app/libraries directly. It completely ignores the COM-style ABI as it's hard to use from some programming languages.
As such the document explicitly excludes any hosting based on directly loading `coreclr`. Instead it focuses on using the existing .NET Core hosting components in new ways. For details on the .NET Core hosting components see [this document](https://github.com/dotnet/runtime/tree/main/docs/design/features/host-components.md).
## Longer term vision
This section describes how we think the hosting components should evolve. It is expected that this won't happen in any single release, but each change should fit into this picture and hopefully move us closer to this goal. It is also expected that existing APIs won't change (no breaking changes) and thus it can happen that some of the APIs don't fit nicely into the picture.
The hosting component APIs should provide functionality to cover a wide range of applications. At the same time it needs to stay in sync with what .NET Core SDK can produce so that the end-to-end experience is available.
The overall goal of hosting components is to enable loading and executing managed code, this consists of four main steps:
* **Locate and load hosting components** - How does a native host find and load the hosting components libraries.
* **Locate the managed code and all its dependencies** - Determining where the managed code comes from (application, component, ...), what frameworks it relies on (framework resolution) and what dependencies it needs (`.deps.json` processing)
* **Load the managed code into the process** - Specify the environment and settings for the runtime, locating or starting the runtime, deciding how to load the managed code into the runtime (which `AssemblyLoadContext` for example) and actually loading the managed code and its dependencies.
* **Accessing and executing managed code** - Locate the managed entry point (for example assembly entry point `Main`, or a specific method to call, or some other means to transition control to the managed code) and exposing it into the native code (function pointer, COM interface, direct execution, ...).
To achieve these we will structure the hosting components APIs into similar (but not exactly) 4 buckets.
### Locating hosting components
This means providing APIs to find and load the hosting components. The end result should be that the native host has the right version of `hostfxr` loaded and can call its APIs. The exact solution is dependent on the native host application and its tooling. Ideally we would have a solution which works great for several common environments like C/C++ apps built in VS, C/C++ apps on Mac/Linux built with CMake (or similar) and so on.
First step in this direction is the introduction of `nethost` library described below.
### Initializing host context
The end result of this step should be an initialized host context for a given managed code input which the native host can use to load the managed code and execute it. The step should not actually load any runtime or managed code into the process. Finally this step must handle both processes which don't have any runtime loaded as well as processes which already have runtime loaded.
Functionality performed by this step:
* Locating and understanding the managed code input (app/component)
* Resolving frameworks or handling self-contained
* Resolving dependencies (`.deps.json` processing)
* Populating runtime properties
The vision is to expose a set of APIs in the form of `hostfxr_initialize_for_...` which would all perform the above functionality and would differ on how the managed code is located and used. So there should be a different API for loading applications and components at the very least. Going forward we can add API which can initialize the context from in-memory configurations, or API which can initialize an "empty" context (no custom code involved, just frameworks) and so on.
First step in this direction is the introduction of these APIs as described below:
* `hostfxr_initialize_for_dotnet_command_line` - this is the initialize for an application. The API is a bit more complicated as it allows for command line parsing as well. Eventually we might want to add another "initialize app" API without the command line support.
* `hostfxr_initialize_for_runtime_config` - this is the initialize for a component (naming is not ideal, but can't be changed anymore).
After this step it should be possible for the native host to inspect and potentially modify runtime properties. APIs like `hostfxr_get_runtime_property_value` and similar described below are an example of this.
### Loading managed code
This step might be "virtual" in the sense that it's a way to setup the context for the desired functionality. In several scenarios it's not practical to be able to perform this step in separation from the "execute code" step below. The goal of this step is to determine which managed code to load, where it should be loaded into, and to setup the correct inputs so that runtime can perform the right dependency resolution.
Logically this step finds/loads the runtime and initializes it before it can load any managed code into the process.
The main flexibility this step should provide is to determine which assembly load context will be used for loading which code:
* Load all managed code into the default load context
* Load the specified custom managed code into an isolated load context
Eventually we could also add functionality for example to setup the isolated load context for unloadability and so on.
Note that there are no APIs proposed in this document which would only perform this step for now. All the APIs so far fold this step into the next one and perform both loading and executing of the managed code in one step. We should try to make this step more explicit in the future to allow for greater flexibility.
After this step it is no longer possible to modify runtime properties (inspection is still allowed) since the runtime has been loaded.
### Accessing and executing managed code
The end result of this step is either execution of the desired managed code, or returning a native callable representation of the managed code.
The different options should include at least:
* running an application (where the API takes over the thread and runs the application on behalf of the calling thread) - the `hostfxr_run_app` API described bellow is an example of this.
* getting a native function pointer to a managed method - the `hostfxr_get_runtime_delegate` and the `hdt_load_assembly_and_get_function_pointer` described below is an example of this.
* getting a native callable interface (COM) to a managed instance - the `hostfxr_get_runtime_delegate` and the `hdt_com_activation` described below is an example of this.
* and more...
### Combinations
Ideally it should be possible to combine the different types of initialization, loading and executing of managed code in any way the native host desires. In reality not all combinations are possible or practical. Few examples of combinations which we should probably NOT support (note that this may change in the future):
* running a component as an application - runtime currently makes too many assumptions on what it means to "Run an application"
* loading application into an isolated load context - for now there are too many limitations in the frameworks around secondary load contexts (several large framework features don't work well in a secondary ALC), so the hosting components should prevent this as a way to prevent users from getting into a bad situation.
* loading multiple copies of the runtime into the process - support for side-by-side loading of different .NET Core runtime in a single process is not something we want to implement (at least yet). Hosting components should not allow this to make the user experience predictable. This means that full support for loading self-contained components at all times is not supported.
Lot of other combinations will not be allowed simply as a result of shipping decisions. There's only so much functionality we can fit into any given release, so many combinations will be explicitly disabled to reduce the work necessary to actually ship this. The document below should describe which combinations are allowed in which release.
## High-level proposal
In .NET Core 3.0 the hosting components (see [here](https://github.com/dotnet/runtime/tree/main/docs/design/features/host-components.md)) ships with several hosts. These are binaries which act as the entry points to the .NET Core hosting components/runtime:
* The "muxer" (`dotnet.exe`)
* The `apphost` (`.exe` which is part of the app)
* The `comhost` (`.dll` which is part of the app and acts as COM server)
* The `ijwhost` (`.dll` consumed via `.lib` used by IJW assemblies)
Every one of these hosts serve different scenario and expose different APIs. The one thing they have in common is that their main purpose is to find the right `hostfxr`, load it and call into it to execute the desired scenario. For the most part all these hosts are basically just wrappers around functionality provided by `hostfxr`.
The proposal is to add a new host library `nethost` which can be used by native host to easily locate `hostfxr`. Going forward the library could also include easy-to-use APIs for common scenarios - basically just a simplification of the `hostfxr` API surface.
At the same time add the ability to pass additional runtime properties when starting the runtime through the hosting components APIs (starting app, loading component). This can be used by the native host to:
* Register startup hook without modifying environment variables (which are inherited by child processes)
* Introduce new runtime knobs which are only available for native hosts without the need to update the hosting components APIs every time.
*Technical note: All strings in the proposed APIs are using the `char_t` in this document for simplicity. In real implementation they are of the type `pal::char_t`. In particular:*
* *On Windows - they are `WCHAR *` using `UTF16` encoding*
* *On Linux/macOS - they are `char *` using `UTF8` encoding*
## New host binary for finding `hostfxr`
New library `nethost` which provides a way to locate the right `hostfxr`.
This is a dynamically loaded library (`.dll`, `.so`, `.dylib`). For ease of use there is a header file for C/C++ apps as well as `.lib` for easy linking on Windows.
Native hosts ship this library as part of the app. Unlike the `apphost`, `comhost` and `ijwhost`, the `nethost` will not be directly supported by the .NET SDK since it's target usage is not from .NET Core apps.
The `nethost` is part of the `Microsoft.NETCore.DotNetAppHost` package. Users are expected to either download the package directly or rely on .NET SDK to pull it down.
The binary itself should be signed by Microsoft as there will be no support for modifying the binary as part of custom application build (unlike `apphost`).
### Locate `hostfxr`
``` C++
struct get_hostfxr_parameters {
size_t size;
const char_t * assembly_path;
const char_t * dotnet_root;
};
int get_hostfxr_path(
char_t * result_buffer,
size_t * buffer_size,
const get_hostfxr_parameters * parameters);
```
This API locates the `hostfxr` library and returns its path by populating `result_buffer`.
* `result_buffer` - Buffer that will be populated with the hostfxr path, including a null terminator.
* `buffer_size` - On input this points to the size of the `result_buffer` in `char_t` units. On output this points to the number of `char_t` units used from the `result_buffer` (including the null terminator). If `result_buffer` is `NULL` the input value is ignored and only the minimum required size in `char_t` units is set on output.
* `parameters` - Optional. Additional parameters that modify the behaviour for locating the `hostfxr` library. If `NULL`, `hostfxr` is located using the environment variable or global registration
* `size` - Size of the structure. This is used for versioning and should be set to `sizeof(get_hostfxr_parameters)`.
* `assembly_path` - Optional. Path to the application or to the component's assembly.
* If specified, `hostfxr` is located as if the `assembly_path` is an application with `apphost`
* `dotnet_root` - Optional. Path to the root of a .NET Core installation (i.e. folder containing the dotnet executable).
* If specified, `hostfxr` is located as if an application is started using `dotnet app.dll`, which means it will be searched for under the `dotnet_root` path and the `assembly_path` is ignored.
`nethost` library uses the `__stdcall` calling convention.
## Improve API to run application and load components
### Goals
* All hosts should be able to use the new API (whether they will is a separate question as the old API has to be kept for backward compat reasons)
* Hide implementation details as much as possible
* Make the API generally easier to use/understand
* Give the implementation more freedom
* Allow future improvements without breaking the API
* Consider explicitly documenting types of behaviors which nobody should take dependency on (specifically failure scenarios)
* Extensible
* It should allow additional parameters to some of the operations without a need to add new exported APIs
* It should allow additional interactions with the host - for example modifying how the runtime is initialized via some new options, without a need for a completely new set of APIs
### New scenarios
The API should allow these scenarios:
* Runtime properties
* Specify additional runtime properties from the native host
* Implement conflict resolution for runtime properties
* Inspect calculated runtime properties (the ones calculated by `hostfxr`/`hostpolicy`)
* Load managed component and get native function pointer for managed method
* From native app start the runtime and load an assembly
* The assembly is loaded in isolation and with all its dependencies as directed by `.deps.json`
* The native app can get back a native function pointer which calls specified managed method
* Get native function pointer for managed method
* From native code get a native function pointer to already loaded managed method
All the proposed APIs will be exports of the `hostfxr` library and will use the same calling convention and name mangling as existing `hostfxr` exports.
### Initialize host context
All the "initialize" functions will
* Process the `.runtimeconfig.json`
* Resolve framework references and find actual frameworks
* Find the root framework (`Microsoft.NETCore.App`) and load the `hostpolicy` from it
* The `hostpolicy` will then process all relevant `.deps.json` files and produce the list of assemblies, native search paths and other artifacts needed to initialize the runtime.
The functions will NOT load the CoreCLR runtime. They just prepare everything to the point where it can be loaded.
The functions return a handle to a new host context:
* The handle must be closed via `hostfxr_close`.
* The handle is not thread safe - the consumer should only call functions on it from one thread at a time.
The `hostfxr` will also track active runtime in the process. Due to limitations (and to simplify implementation) this tracking will actually not look at the actual `coreclr` module (or try to communicate with the runtime in any way). Instead `hostfxr` itself will track the host context initialization. The first host context initialization in the process will represent the "loaded runtime". It is only possible to have one "loaded runtime" in the process. Any subsequent host context initialization will just "attach" to the "loaded runtime" instead of creating a new one.
``` C
typedef void* hostfxr_handle;
struct hostfxr_initialize_parameters
{
size_t size;
const char_t * host_path;
const char_t * dotnet_root;
};
```
The `hostfxr_initialize_parameters` structure stores parameters which are common to all forms of initialization.
* `size` - the size of the structure. This is used for versioning. Should be set to `sizeof(hostfxr_initialize_parameters)`.
* `host_path` - path to the native host (typically the `.exe`). This value is not used for anything by the hosting components. It's just passed to the CoreCLR as the path to the executable. It can point to a file which is not executable itself, if such file doesn't exist (for example in COM activation scenarios this points to the `comhost.dll`). This is used by PAL to initialize internal command line structures, process name and so on.
* `dotnet_root` - path to the root of the .NET Core installation in use. This typically points to the install location from which the `hostfxr` has been loaded. For example on Windows this would typically point to `C:\Program Files\dotnet`. The path is used to search for shared frameworks and potentially SDKs.
``` C
int hostfxr_initialize_for_dotnet_command_line(
int argc,
const char_t * argv[],
const hostfxr_initialize_parameters * parameters,
hostfxr_handle * host_context_handle
);
```
Initializes the hosting components for running a managed application.
The command line is parsed to determine the app path. The app path will be used to locate the `.runtimeconfig.json` and the `.deps.json` which will be used to load the application and its dependent frameworks.
* `argc` and `argv` - the command line for running a managed application. These represent the arguments which would have been passed to the muxer if the app was being run from the command line. These are the parameters which are valid for the runtime installation by itself - SDK/CLI commands are not supported. For example, the arguments could be `app.dll app_argument_1 app_argument_2`. This API specifically doesn't support the `dotnet run` SDK command.
* `parameters` - additional parameters - see `hostfxr_initialize_parameters` for details. (Could be made optional potentially)
* `host_context_handle` - output parameter. On success receives an opaque value which identifies the initialized host context. The handle should be closed by calling `hostfxr_close`.
This function only supports arguments for running an application as through the muxer. It does not support SDK commands.
This function can only be called once per-process. It's not supported to run multiple apps in one process (even sequentially).
This function will fail if there already is a CoreCLR running in the process as it's not possible to run two apps in a single process.
This function supports both framework-dependent and self-contained applications.
*Note: This is effectively a replacement for `hostfxr_main_startupinfo` and `hostfxr_main`. Currently it is not a goal to fully replace these APIs because they also support SDK commands which are special in lot of ways and don't fit well with the rest of the native hosting. There's no scenario right now which would require the ability to issue SDK commands from a native host. That said nothing in this proposal should block enabling even SDK commands through these APIs.*
``` C
int hostfxr_initialize_for_runtime_config(
const char_t * runtime_config_path,
const hostfxr_initialize_parameters * parameters,
hostfxr_handle * host_context_handle
);
```
This function would load the specified `.runtimeconfig.json`, resolve all frameworks, resolve all the assets from those frameworks and then prepare runtime initialization where the TPA contains only frameworks. Note that this case does NOT consume any `.deps.json` from the app/component (only processes the framework's `.deps.json`). This entry point is intended for `comhost`/`ijwhost`/`nethost` and similar scenarios.
* `runtime_config_path` - path to the `.runtimeconfig.json` file to process. Unlike with `hostfxr_initialize_for_dotnet_command_line`, any `.deps.json` from the app/component will not be processed by the hosting components during the initialize call.
* `parameters` - additional parameters - see `hostfxr_initialize_parameters` for details. (Could be made optional potentially)
* `host_context_handle` - output parameter. On success receives an opaque value which identifies the initialized host context. The handle should be closed by calling `hostfxr_close`.
This function can be called multiple times in a process.
* If it's called when no runtime is present, it will run through the steps to "initialize" the runtime (resolving frameworks and so on).
* If it's called when there already is CoreCLR in the process (loaded through the `hostfxr`, direct usage of `coreclr` is not supported), then the function determines if the specified runtime configuration is compatible with the existing runtime and frameworks. If it is, it returns a valid handle, otherwise it fails.
It needs to be possible to call this function simultaneously from multiple threads at the same time.
It also needs to be possible to call this function while there is an active host context created by `hostfxr_initialize_for_dotnet_command_line` and running inside the `hostfxr_run_app`.
The function returns specific return code for the first initialized host context, and a different one for any subsequent one. Both return codes are considered "success". If there already was initialized host context in the process then the returned host context has these limitations:
* It won't allow setting runtime properties.
* The initialization will compare the runtime properties from the `.runtimeconfig.json` specified in the `runtime_config_path` with those already set to the runtime in the process
* If all properties from the new runtime config are already set and have the exact same values (case sensitive string comparison), the initialization succeeds with no additional consequences. (Note that this is the most typical case where the runtime config have no properties in it.)
* If there are either new properties which are not set in the runtime or ones which have different values, the initialization will return a special return code - a "warning". It's not a full on failure as initialized context will be returned.
* In both cases only the properties specified by the new runtime config will be reported on the host context. This is to allow the native host to decide in the "warning" case if it's OK to let the component run or not.
* In both cases the returned host context can still be used to get a runtime delegate, the properties from the new runtime config will be ignored (as there's no way to modify those in the runtime).
The specified `.runtimeconfig.json` must be for a framework dependent component. That is it must specify at least one shared framework in its `frameworks` section. Self-contained components are not supported.
### Inspect and modify host context
#### Runtime properties
These functions allow the native host to inspect and modify runtime properties.
* If the `host_context_handle` represents the first initialized context in the process, these functions expose all properties from runtime configurations as well as those computed by the hosting components. These functions will allow modification of the properties via `hostfxr_set_runtime_property_value`.
* If the `host_context_handle` represents any other context (so not the first one), these functions expose only properties from runtime configuration. These functions won't allow modification of the properties.
It is possible to access runtime properties of the first initialized context in the process at any time (for reading only), by specifying `NULL` as the `host_context_handle`.
``` C
int hostfxr_get_runtime_property_value(
const hostfxr_handle host_context_handle,
const char_t * name,
const char_t ** value);
```
Returns the value of a runtime property specified by its name.
* `host_context_handle` - the initialized host context. If set to `NULL` the function will operate on runtime properties of the first host context in the process.
* `name` - the name of the runtime property to get. Must not be `NULL`.
* `value` - returns a pointer to a buffer with the property value. The buffer is owned by the host context. The caller should make a copy of it if it needs to store it for anything longer than immediate consumption. The lifetime is only guaranteed until any of the below happens:
* one of the "run" methods is called on the host context
* the host context is closed via `hostfxr_close`
* the value of the property is changed via `hostfxr_set_runtime_property_value`
Trying to get a property which doesn't exist is an error and will return an appropriate error code.
We're proposing a fix in `hostpolicy` which will make sure that there are no duplicates possible after initialization (see [dotnet/core-setup#5529](https://github.com/dotnet/core-setup/issues/5529)). With that `hostfxr_get_runtime_property_value` will work always (as there can only be one value).
``` C
int hostfxr_set_runtime_property_value(
const hostfxr_handle host_context_handle,
const char_t * name,
const char_t * value);
```
Sets the value of a property.
* `host_context_handle` - the initialized host context. (Must not be `NULL`)
* `name` - the name of the runtime property to set. Must not be `NULL`.
* `value` - the value of the property to set. If the property already has a value in the host context, this function will overwrite it. When set to `NULL` and if the property already has a value then the property is "unset" - removed from the runtime property collection.
Setting properties is only supported on the first host context in the process. This is really a limitation of the runtime for which the runtime properties are immutable. Once the first host context is initialized and starts a runtime there's no way to change these properties. For now we will not consider the scenario where the host context is initialized but the runtime hasn't started yet, mainly for simplicity of implementation and lack of requirements.
``` C
int hostfxr_get_runtime_properties(
const hostfxr_handle host_context_handle,
size_t * count,
const char_t **keys,
const char_t **values);
```
Returns the full set of all runtime properties for the specified host context.
* `host_context_handle` - the initialized host context. If set to `NULL` the function will operate on runtime properties of the first host context in the process.
* `count` - in/out parameter which must not be `NULL`. On input it specifies the size of the the `keys` and `values` buffers. On output it contains the number of entries used from `keys` and `values` buffers - the number of properties returned. If the size of the buffers is too small, the function returns a specific error code and fill the `count` with the number of available properties. If `keys` or `values` is `NULL` the function ignores the input value of `count` and just returns the number of properties.
* `keys` - buffer which acts as an array of pointers to buffers with keys for the runtime properties.
* `values` - buffer which acts as an array of pointer to buffers with values for the runtime properties.
`keys` and `values` store pointers to buffers which are owned by the host context. The caller should make a copy of it if it needs to store it for anything longer than immediate consumption. The lifetime is only guaranteed until any of the below happens:
* one of the "run" methods is called on the host context
* the host context is closed via `hostfxr_close`
* the value or existence of any property is changed via `hostfxr_set_runtime_property_value`
Note that `hostfxr_set_runtime_property_value` can remove or add new properties, so the number of properties returned is only valid as long as no properties were added/removed.
### Start the runtime
#### Running an application
``` C
int hostfxr_run_app(const hostfxr_handle host_context_handle);
```
Runs the application specified by the `hostfxr_initialize_for_dotnet_command_line`. It is illegal to try to use this function when the host context was initialized through any other way.
* `host_context_handle` - handle to the initialized host context.
The function will return only once the managed application exits.
`hostfxr_run_app` cannot be used in combination with any other "run" function. It can also only be called once.
#### Getting a delegate for runtime functionality
``` C
int hostfxr_get_runtime_delegate(const hostfxr_handle host_context_handle, hostfxr_delegate_type type, void ** delegate);
```
Starts the runtime and returns a function pointer to specified functionality of the runtime.
* `host_context_handle` - handle to the initialized host context.
* `type` - the type of runtime functionality requested
* `hdt_load_assembly_and_get_function_pointer` - entry point which loads an assembly (with dependencies) and returns function pointer for a specified static method. See below for details (Loading and calling managed components)
* `hdt_com_activation`, `hdt_com_register`, `hdt_com_unregister` - COM activation entry-points - see [COM activation](https://github.com/dotnet/runtime/tree/main/docs/design/features/COM-activation.md) for more details.
* `hdt_load_in_memory_assembly` - IJW entry-point - see [IJW activation](https://github.com/dotnet/runtime/tree/main/docs/design/features/IJW-activation.md) for more details.
* `hdt_winrt_activation` **[.NET 3.\* only]** - WinRT activation entry-point - see [WinRT activation](https://github.com/dotnet/runtime/tree/main/docs/design/features/WinRT-activation.md) for more details. The delegate is not supported for .NET 5 and above.
* `hdt_get_function_pointer` **[.NET 5 and above]** - entry-point which finds a managed method and returns a function pointer to it. See below for details (Calling managed function).
* `delegate` - when successful, the native function pointer to the requested runtime functionality.
In .NET Core 3.0 the function only works if `hostfxr_initialize_for_runtime_config` was used to initialize the host context.
In .NET 5 the function also works if `hostfxr_initialize_for_dotnet_command_line` was used to initialize the host context. Also for .NET 5 it will only be allowed to request `hdt_load_assembly_and_get_function_pointer` or `hdt_get_function_pointer` on a context initialized via `hostfxr_initialize_for_dotnet_command_line`, all other runtime delegates will not be supported in this case.
### Cleanup
``` C
int hostfxr_close(const hostfxr_handle host_context_handle);
```
Closes a host context.
* `host_context_handle` - handle to the initialized host context to close.
### Loading and calling managed components
To load managed components from native app directly (not using COM or WinRT) the hosting components exposes a new runtime helper/delegate `hdt_load_assembly_and_get_function_pointer`. Calling the `hostfxr_get_runtime_delegate(handle, hdt_load_assembly_and_get_function_pointer, &helper)` returns a function pointer to the runtime helper with this signature:
```C
int load_assembly_and_get_function_pointer_fn(
const char_t *assembly_path,
const char_t *type_name,
const char_t *method_name,
const char_t *delegate_type_name,
void *reserved,
/*out*/ void **delegate)
```
Calling this function will load the specified assembly in isolation (into its own `AssemblyLoadContext`) and it will use `AssemblyDependencyResolver` on it to provide dependency resolution. Once loaded it will find the specified type and method and return a native function pointer to that method. The method's signature can be specified via the delegate type name.
* `assembly_path` - Path to the assembly to load. In case of complex component, this should be the main assembly of the component (the one with the `.deps.json` next to it). Note that this does not have to be the assembly from which the `type_name` and `method_name` are.
* `type_name` - Assembly qualified type name to find
* `method_name` - Name of the method on the `type_name` to find. The method must be `static` and must match the signature of `delegate_type_name`.
* `delegate_type_name` - Assembly qualified delegate type name for the method signature, or null. If this is null, the method signature is assumed to be:
```C#
public delegate int ComponentEntryPoint(IntPtr args, int sizeBytes);
```
This maps to native signature:
```C
int component_entry_point_fn(void *arg, int32_t arg_size_in_bytes);
```
**[.NET 5 and above]** The `delegate_type_name` can be also specified as `UNMANAGEDCALLERSONLY_METHOD` (defined as `(const char_t*)-1`) which means that the managed method is marked with `UnmanagedCallersOnlyAttribute`.
* `reserved` - parameter reserved for future extensibility, currently unused and must be `NULL`.
* `delegate` - out parameter which receives the native function pointer to the requested managed method.
The helper will always load the assembly into an isolated load context. This is the case regardless if the requested assembly is also available in the default load context or not.
**[.NET 5 and above]** It is allowed to call this helper on a host context which came from `hostfxr_initialize_for_dotnet_command_line` which will make all the application assemblies available in the default load context. In such case it is recommended to only use this helper for loading plugins external to the application. Using the helper to load assembly from the application itself will lead to duplicate copies of assemblies and duplicate types.
It is allowed to call the returned runtime helper many times for different assemblies or different methods from the same assembly. It is not required to get the helper every time. The implementation of the helper will cache loaded assemblies, so requests to load the same assembly twice will load it only once and reuse it from that point onward. Ideally components should not take a dependency on this behavior, which means components should not have global state. Global state in components is typically just cause for problems. For example it may create ordering issues or unintended side effects and so on.
The returned native function pointer to managed method has the lifetime of the process and can be used to call the method many times over. Currently there's no way to unload the managed component or otherwise free the native function pointer. Such support may come in future releases.
### Calling managed function **[.NET 5 and above]**
In .NET 5 the hosting components add a new functionality which allows just getting a native function pointer for already available managed method. This is implemented in a runtime helper `hdt_get_function_pointer`. Calling the `hostfxr_get_runtime_delegate(handle, hdt_get_function_pointer, &helper)` returns a function pointer to the runtime helper with this signature:
```C
int get_function_pointer_fn(
const char_t *type_name,
const char_t *method_name,
const char_t *delegate_type_name,
void *load_context,
void *reserved,
/*out*/ void **delegate)
```
Calling this function will find the specified type in the default load context, locate the required method on it and return a native function pointer to that method. The method's signature can be specified via the delegate type name.
* `type_name` - Assembly qualified type name to find
* `method_name` - Name of the method on the `type_name` to find. The method must be `static` and must match the signature of `delegate_type_name`.
* `delegate_type_name` - Assembly qualified delegate type name for the method signature, or null. If this is null, the method signature is assumed to be:
```C#
public delegate int ComponentEntryPoint(IntPtr args, int sizeBytes);
```
This maps to native signature:
```C
int component_entry_point_fn(void *arg, int32_t arg_size_in_bytes);
```
The `delegate_type_name` can be also specified as `UNMANAGEDCALLERSONLY_METHOD` (defined as `(const char_t*)-1`) which means that the managed method is marked with `UnmanagedCallersOnlyAttribute`.
* `load_context` - eventually this parameter should support specifying which load context should be used to locate the type/method specified in previous parameters. For .NET 5 this parameter must be `NULL` and the API will only locate the type/method in the default load context.
* `reserved` - parameter reserved for future extensibility, currently unused and must be `NULL`.
* `delegate` - out parameter which receives the native function pointer to the requested managed method.
The helper will lookup the `type_name` from the default load context (`AssemblyLoadContext.Default`) and then return method on it. If the type and method lookup requires assemblies which have not been loaded by the Default ALC yet, this process will resolve them against the Default ALC and load them there (most likely from TPA). This helper will not register any additional assembly resolution logic onto the Default ALC, it will solely rely on the existing functionality of the Default ALC.
It is allowed to ask for this helper on any valid host context. Because the helper operates on default load context only it should mostly be used with context initialized via `hostfxr_initialize_for_dotnet_command_line` as in that case the default load context will have the application code available in it. Contexts initialized via `hostfxr_initialize_for_runtime_config` have only the framework assemblies available in the default load context. The `type_name` must resolve within the default load context, so in the case where only framework assemblies are loaded into the default load context it would have to come from one of the framework assemblies only.
It is allowed to call the returned runtime helper many times for different types or methods. It is not required to get the helper every time.
The returned native function pointer to managed method has the lifetime of the process and can be used to call the method many times over. Currently there's no way to "release" the native function pointer (and the respective managed delegate), this functionality may be added in a future release.
### Multiple host contexts interactions
It is important to correctly synchronize some of these operations to achieve the desired API behavior as well as thread safety requirements. The following behaviors will be used to achieve this.
#### Terminology
* `first host context` is the one which is used to load and initialize the CoreCLR runtime in the process. At any given time there can only be one `first host context`.
* `secondary host context` is any other initialized host context when `first host context` already exists in the process.
#### Synchronization
* If there's no `first host context` in the process the first call to `hostfxr_initialize_...` will create a new `first host context`. There can only be one `first host context` in existence at any point in time.
* Calling `hostfxr_initialize...` when `first host context` already exists will always return a `secondary host context`.
* The `first host context` blocks creation of any other host context until it is used to load and initialize the CoreCLR runtime. This means that `hostfxr_initialize...` and subsequently one of the "run" methods must be called on the `first host context` to unblock creation of `secondary host contexts`.
* Calling `hostfxr_initialize...` will block until the `first host context` is initialized, a "run" method is called on it and the CoreCLR is loaded and initialized. The `hostfxr_initialize...` will block potentially indefinitely. The method will block very early on. All of the operations done by the initialize will only happen once it's unblocked.
* `first host context` can fail to initialize the runtime (or anywhere up to that point). If this happens, it's marked as failed and is not considered a `first host context` anymore. This unblocks the potentially waiting `hostfxr_initialize...` calls. In this case the first `hostfxr_initialize...` after the failure will create a new `first host context`.
* `first host context` can be closed using `hostfxr_close` before it is used to initialize the CoreCLR runtime. This is similar to the failure above, the host context is marked as "closed/failed" and is not considered `first host context` anymore. This unblocks any waiting `hostfxr_initialize...` calls.
* Once the `first host context` successfully initialized the CoreCLR runtime it is permanently marked as "successful" and will remain the `first host context` for the lifetime of the process. Such host context should still be closed once not needed via `hostfxr_close`.
#### Invalid usage
* It is invalid to initialize a host context via `hostfxr_initialize...` and then never call `hostfxr_close` on it. An initialized but not closed host context is considered abandoned. Abandoned `first host context` will cause infinite blocking of any future `hostfxr_initialize...` calls.
#### Important scenarios
The above behaviors should make sure that some important scenarios are possible and work reliably.
One such scenario is a COM host on multiple threads. The app is not running any .NET Core yet (no CoreCLR loaded). On two threads in parallel COM activation is invoked which leads to two invocations into the `comhost` to active .NET Core objects. The `comhost` will use the `hostfxr_initialize...` and `hostfxr_get_runtime_delegate` APIs on two threads in parallel then. Only one of them can load and initialize the runtime (and also perform full framework resolution and determine the framework versions and assemblies to load). The other has to become a `secondary host context` and try to conform to the first one. The above behavior of `hostfxr_initialize...` blocking until the `first host context` is done initializing the runtime will make sure of the correct behavior in this case.
At the same time it gives the native app (`comhost` in this case) the ability to query and modify runtime properties in between the `hostfxr_initialize...` and `hostfxr_get_runtime_delegate` calls on the `first host context`.
### API usage
The `hostfxr` exports are defined in the [hostfxr.h](https://github.com/dotnet/runtime/blob/main/src/native/corehost/hostfxr.h) header file.
The runtime helper and method signatures for loading managed components are defined in [coreclr_delegates.h](https://github.com/dotnet/runtime/blob/main/src/native/corehost/coreclr_delegates.h) header file.
Currently we don't plan to ship these files, but it's possible to take them from the repo and use it.
### Support for older versions
Since `hostfxr` and the other hosting components are versioned independently there are several interesting cases of version mismatches:
#### muxer/`apphost` versus `hostfxr`
For muxer it should almost always match, but `apphost` can be different. That is, it's perfectly valid to use older 2.* `apphost` with a new 3.0 `hostfxr`. The opposite should be rare, but in theory can happen as well. To keep the code simple both muxer and `apphost` will keep using the existing 2.* APIs on `hostfxr` even in situation where both are 3.0 and thus could start using the new APIs.
`hostfxr` must be backward compatible and support 2.* APIs.
Potentially we could switch just `apphost` to use the new APIs (since it doesn't have the same compatibility burden as the muxer), but it's probably safer to not do that.
#### `hostfxr` versus `hostpolicy`
It should really only happen that `hostfxr` is equal or newer than `hostpolicy`. The opposite should be very rare. In any case `hostpolicy` should support existing 2.* APIs and thus the rare case will keep working anyway.
The interesting case is 3.0 `hostfxr` using 2.* `hostpolicy`. This will be very common, basically any 2.* app running on a machine with 3.0 installed will be in that situation. This case has two sub-cases:
* `hostfxr` is invoked using one of the 2.* APIs. In this case the simple solution is to keep using the 2.* `hostpolicy` APIs always.
* `hostfxr` is invoked using one of the new 3.0 APIs (like `hostfxr_initialize...`). In this case it's not possible to completely support the new APIs, since they require new functionality from `hostpolicy`. For now the `hostfxr` should simply fail.
It is in theory possible to support some kind of emulation mode where for some scenarios the new APIs would work even with old `hostpolicy`, but for simplicity it's better to start with just failing.
#### Implementation of existing 2.* APIs in `hostfxr`
The existing 2.* APIs in `hostfxr` could switch to internally use the new functionality and in turn use the new 3.0 `hostpolicy` APIs. The tricky bit here is scenario like this:
* 3.0 App is started via `apphost` or muxer which as mentioned above will keep on using the 2.* `hostfxr` APIs. This will load CoreCLR into the process.
* COM component is activated in the same process. This will go through the new 3.0 `hostfxr` APIs, and to work correctly will require the internal representation of the `first host context`.
If the 2.* `hostfxr` APIs would continue to use the old 2.* `hostpolicy` APIs even if `hostpolicy` is new, then the above scenario will be hard to achieve as there will be no `first host context`. `hostpolicy` could somehow "emulate" the `first host context`, but without `hostpolicy` cooperation this would be hard.
On the other hand switching to use the new `hostpolicy` APIs even in 2.* `hostfxr` APIs is risky for backward compatibility. This will have to be decided during implementation.
### Samples
All samples assume that the native host has found the `hostfxr`, loaded it and got the exports (possibly by using the `nethost`).
Samples in general ignore error handling.
#### Running app with additional runtime properties
``` C++
hostfxr_initialize_parameters params;
params.size = sizeof(params);
params.host_path = get_path_to_the_host_exe(); // Path to the current executable
params.dotnet_root = get_directory(get_directory(get_directory(hostfxr_path))); // Three levels up from hostfxr typically
hostfxr_handle host_context_handle;
hostfxr_initialize_for_dotnet_command_line(
_argc_,
_argv_, // For example, 'app.dll app_argument_1 app_argument_2'
¶ms,
&host_context_handle);
size_t buffer_used = 0;
if (hostfxr_get_runtime_property(host_context_handle, "TEST_PROPERTY", NULL, 0, &buffer_used) == HostApiMissingProperty)
{
hostfxr_set_runtime_property(host_context_handle, "TEST_PROPERTY", "TRUE");
}
hostfxr_run_app(host_context_handle);
hostfxr_close(host_context_handle);
```
#### Getting a function pointer to call a managed method
```C++
using load_assembly_and_get_function_pointer_fn = int (STDMETHODCALLTYPE *)(
const char_t *assembly_path,
const char_t *type_name,
const char_t *method_name,
const char_t *delegate_type_name,
void *reserved,
void **delegate);
hostfxr_handle host_context_handle;
hostfxr_initialize_for_runtime_config(config_path, NULL, &host_context_handle);
load_assembly_and_get_function_pointer_fn runtime_delegate = NULL;
hostfxr_get_runtime_delegate(
host_context_handle,
hostfxr_delegate_type::load_assembly_and_get_function_pointer,
(void **)&runtime_delegate);
using managed_entry_point_fn = int (STDMETHODCALLTYPE *)(void *arg, int argSize);
managed_entry_point_fn entry_point = NULL;
runtime_delegate(assembly_path,
type_name,
method_name,
NULL,
NULL,
(void **)&entry_point);
ArgStruct arg;
entry_point(&arg, sizeof(ArgStruct));
hostfxr_close(host_context_handle);
```
## Impact on hosting components
The exact impact on the `hostfxr`/`hostpolicy` interface needs to be investigated. The assumption is that new APIs will have to be added to `hostpolicy` to implement the proposed functionality.
Part if this investigation will also be compatibility behavior. Currently "any" version of `hostfxr` needs to be able to use "any" version of `hostpolicy`. But the proposed functionality will need both new `hostfxr` and new `hostpolicy` to work. It is likely the proposed APIs will fail if the app resolves to a framework with old `hostpolicy` without the necessary new APIs. Part of the investigation will be if it's feasible to use the new `hostpolicy` APIs to implement existing old `hostfxr` APIs.
## Incompatible with trimming
Native hosting support on managed side is disabled by default on trimmed apps. Native hosting and trimming are incompatible since the trimmer cannot analyze methods that are called by native hosts. Native hosting support for trimming can be managed through the [feature switch](https://github.com/dotnet/runtime/blob/main/docs/workflow/trimming/feature-switches.md) settings specific to each native host.
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/mini/mini-windows-tls-callback.c | /**
* Copyright 2019 Microsoft Corporation
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "mini-runtime.h"
#if defined(HOST_WIN32)
#include "mini-windows.h"
#include <windows.h>
/* Only reset by initial callback from OS loader with reason DLL_PROCESS_ATTACH */
/* both for DLL and LIB callbacks, so no need to protect this variable. */
static MonoWin32TLSCallbackType mono_win32_tls_callback_type = MONO_WIN32_TLS_CALLBACK_TYPE_NONE;
/* NOTE, this function needs to be in this source file to make sure linker */
/* resolve this symbol from mini-windows.c, picking up callback and */
/* included it in TLS Directory PE header. Function makes sure we only activate */
/* one of the supported mono callback types at runtime (if multiple one has been used) */
gboolean
mono_win32_handle_tls_callback_type (MonoWin32TLSCallbackType callback_type)
{
/* Makes sure our tls callback doesn't get optimized away. */
extern const PIMAGE_TLS_CALLBACK __mono_win32_tls_callback;
const volatile PIMAGE_TLS_CALLBACK __tls_callback = __mono_win32_tls_callback;
if (mono_win32_tls_callback_type == MONO_WIN32_TLS_CALLBACK_TYPE_NONE)
mono_win32_tls_callback_type = callback_type;
if (callback_type != mono_win32_tls_callback_type)
return FALSE;
return TRUE;
}
VOID NTAPI mono_win32_tls_callback (PVOID module_handle, DWORD reason, PVOID reserved);
VOID NTAPI mono_win32_tls_callback (PVOID module_handle, DWORD reason, PVOID reserved)
{
mono_win32_runtime_tls_callback ((HMODULE)module_handle, reason, reserved, MONO_WIN32_TLS_CALLBACK_TYPE_LIB);
}
/* If we are building a static library that won't have access to DllMain we can't */
/* correctly detach a thread before it terminates. The MSVC linker + runtime (also applies to MINGW) */
/* uses a set of predefined segments/sections where callbacks can be stored and called */
/* by OS loader (part of TLS Directory PE header), regardless if runtime is used */
/* as a static or dynamic library. */
#if (_MSC_VER >= 1400)
#pragma const_seg (".CRT$XLX")
extern const PIMAGE_TLS_CALLBACK __mono_win32_tls_callback = mono_win32_tls_callback;
#pragma const_seg ()
#elif defined(__MINGW64__) || (__MINGW32__)
extern const PIMAGE_TLS_CALLBACK __mono_win32_tls_callback __attribute__ ((section (".CRT$XLX"))) = mono_win32_tls_callback;
#else
#pragma message ("TLS callback support not included in .CRT$XLX segment. Static linked runtime won't add callback into PE header.")
#endif
#endif
| /**
* Copyright 2019 Microsoft Corporation
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "mini-runtime.h"
#if defined(HOST_WIN32)
#include "mini-windows.h"
#include <windows.h>
/* Only reset by initial callback from OS loader with reason DLL_PROCESS_ATTACH */
/* both for DLL and LIB callbacks, so no need to protect this variable. */
static MonoWin32TLSCallbackType mono_win32_tls_callback_type = MONO_WIN32_TLS_CALLBACK_TYPE_NONE;
/* NOTE, this function needs to be in this source file to make sure linker */
/* resolve this symbol from mini-windows.c, picking up callback and */
/* included it in TLS Directory PE header. Function makes sure we only activate */
/* one of the supported mono callback types at runtime (if multiple one has been used) */
gboolean
mono_win32_handle_tls_callback_type (MonoWin32TLSCallbackType callback_type)
{
/* Makes sure our tls callback doesn't get optimized away. */
extern const PIMAGE_TLS_CALLBACK __mono_win32_tls_callback;
const volatile PIMAGE_TLS_CALLBACK __tls_callback = __mono_win32_tls_callback;
if (mono_win32_tls_callback_type == MONO_WIN32_TLS_CALLBACK_TYPE_NONE)
mono_win32_tls_callback_type = callback_type;
if (callback_type != mono_win32_tls_callback_type)
return FALSE;
return TRUE;
}
VOID NTAPI mono_win32_tls_callback (PVOID module_handle, DWORD reason, PVOID reserved);
VOID NTAPI mono_win32_tls_callback (PVOID module_handle, DWORD reason, PVOID reserved)
{
mono_win32_runtime_tls_callback ((HMODULE)module_handle, reason, reserved, MONO_WIN32_TLS_CALLBACK_TYPE_LIB);
}
/* If we are building a static library that won't have access to DllMain we can't */
/* correctly detach a thread before it terminates. The MSVC linker + runtime (also applies to MINGW) */
/* uses a set of predefined segments/sections where callbacks can be stored and called */
/* by OS loader (part of TLS Directory PE header), regardless if runtime is used */
/* as a static or dynamic library. */
#if (_MSC_VER >= 1400)
#pragma const_seg (".CRT$XLX")
extern const PIMAGE_TLS_CALLBACK __mono_win32_tls_callback = mono_win32_tls_callback;
#pragma const_seg ()
#elif defined(__MINGW64__) || (__MINGW32__)
extern const PIMAGE_TLS_CALLBACK __mono_win32_tls_callback __attribute__ ((section (".CRT$XLX"))) = mono_win32_tls_callback;
#else
#pragma message ("TLS callback support not included in .CRT$XLX segment. Static linked runtime won't add callback into PE header.")
#endif
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/ia64/Gget_proc_info.c | /* libunwind - a platform-independent unwind library
Copyright (C) 2002 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
int
unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi)
{
struct cursor *c = (struct cursor *) cursor;
int ret;
if ((ret = ia64_make_proc_info (c)) < 0)
return ret;
*pi = c->pi;
return 0;
}
| /* libunwind - a platform-independent unwind library
Copyright (C) 2002 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
int
unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi)
{
struct cursor *c = (struct cursor *) cursor;
int ret;
if ((ret = ia64_make_proc_info (c)) < 0)
return ret;
*pi = c->pi;
return 0;
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/wasm/runtime/modularize-dotnet.md | # Linked javascript files
They are emcc way how to extend the dotnet.js script during linking, by appending the scripts.
See https://emscripten.org/docs/tools_reference/emcc.html#emcc-pre-js
There are `-extern-pre-js`,`-pre-js`, `-post-js`, `-extern-post-js`.
In `src\mono\wasm\build\WasmApp.Native.targets` we apply them by file naming convention as: `*.extpre.js`,`*.pre.js`, `*.post.js`, `*.extpost.js`
- For ES6 with `WasmEnableES6 == true` from `src/es6`folder
- For CommonJS with `WasmEnableES6 == false` from `src/cjs`folder
In `src\mono\wasm\runtime\CMakeLists.txt` which links only in-tree, we use same mapping explicitly. Right now CommonJS is default.
# dotnet.cjs.extpost.js
- Is at the end of file but is executed first (1)
- Applied only when linking CommonJS
- If `globalThis.Module` exist it takes it and start runtime with it.
- Otherwise user could still use the `createDotnetRuntime` export or `globalThis.createDotnetRuntime` if it was loaded into global namespace.
# dotnet.cjs.pre.js
- Executed second (2)
- Applied only when linking CommonJS
- Will try to see if it was executed with `globalThis.Module` and if so, it would use it's instance as `Module`. It would preserve emscripten's `Module.ready`
- Otherwise it would load it would assume it was called via `createDotnetRuntime` export same as described for `dotnet.es6.pre.js` below.
# dotnet.es6.pre.js
- Executed second (2)
- Applied only when linking ES6
- Will check that it was passed `moduleFactory` callback. Because of emscripten reasons it has confusing `createDotnetRuntime` name here.
- Will validate `Module.ready` is left un-overriden.
# runtime.*.iffe.js
- Executed third (3)
- this is produced from `*.ts` files in this directory by rollupJS.
# dotnet.*.post.js
- Executed last (4)
- When `onRuntimeInitialized` is overriden it would wait for emscriptens `Module.ready`
- Otherwise it would wait for for MonoVM to load all assets and assemblies.
- It would pass on the API exports
# About new API
The signature is
```
function createDotnetRuntime(moduleFactory: (api: DotnetPublicAPI) => DotnetModuleConfig): Promise<DotNetExports>
```
Simplest intended usage looks like this in ES6:
```
import createDotnetRuntime from './dotnet.js'
await createDotnetRuntime(() => ({
configSrc: "./mono-config.json",
}));
```
More complex scenario with using APIs, commented
```
import createDotnetRuntime from './dotnet.js'
export const { MONO, BINDING } = await createDotnetRuntime(({ MONO, BINDING, Module }) =>
// this is callback with no statement, the APIs are only empty shells here and are populated later.
({
disableDotnet6Compatibility: true,
configSrc: "./mono-config.json",
onConfigLoaded: () => {
// This is called during emscripten `preInit` event, after we fetched config.
// Module.config is loaded and could be tweaked before application
Module.config.environment_variables["MONO_LOG_LEVEL"]="debug"
// here we could use API passed into this callback
// call some early available functions
MONO.mono_wasm_setenv("HELLO", "WORLD);
}
onDotnetReady: () => {
// Only when there is no `onRuntimeInitialized` override.
// This is called after all assets are loaded , mapping to legacy `config.loaded_cb`.
// It happens during emscripten `onRuntimeInitialized` after monoVm init + globalization + assemblies.
// This also matches when the top level promise is resolved.
// The original emscripten `Module.ready` promise is replaced with this.
// at this point both emscripten and monoVM are fully initialized.
Module.FS.chdir(processedArguments.working_dir);
},
onAbort: (error) => {
set_exit_code(1, error);
},
}));
// at this point both emscripten and monoVM are fully initialized.
// we could use the APIs returned and resolved from createDotnetRuntime promise
// both API exports are receiving the same API object instances, i.e. same `MONO` instance.
const run_all = BINDING.bind_static_method ("[debugger-test] DebuggerTest:run_all");
run_all();
```
| # Linked javascript files
They are emcc way how to extend the dotnet.js script during linking, by appending the scripts.
See https://emscripten.org/docs/tools_reference/emcc.html#emcc-pre-js
There are `-extern-pre-js`,`-pre-js`, `-post-js`, `-extern-post-js`.
In `src\mono\wasm\build\WasmApp.Native.targets` we apply them by file naming convention as: `*.extpre.js`,`*.pre.js`, `*.post.js`, `*.extpost.js`
- For ES6 with `WasmEnableES6 == true` from `src/es6`folder
- For CommonJS with `WasmEnableES6 == false` from `src/cjs`folder
In `src\mono\wasm\runtime\CMakeLists.txt` which links only in-tree, we use same mapping explicitly. Right now CommonJS is default.
# dotnet.cjs.extpost.js
- Is at the end of file but is executed first (1)
- Applied only when linking CommonJS
- If `globalThis.Module` exist it takes it and start runtime with it.
- Otherwise user could still use the `createDotnetRuntime` export or `globalThis.createDotnetRuntime` if it was loaded into global namespace.
# dotnet.cjs.pre.js
- Executed second (2)
- Applied only when linking CommonJS
- Will try to see if it was executed with `globalThis.Module` and if so, it would use it's instance as `Module`. It would preserve emscripten's `Module.ready`
- Otherwise it would load it would assume it was called via `createDotnetRuntime` export same as described for `dotnet.es6.pre.js` below.
# dotnet.es6.pre.js
- Executed second (2)
- Applied only when linking ES6
- Will check that it was passed `moduleFactory` callback. Because of emscripten reasons it has confusing `createDotnetRuntime` name here.
- Will validate `Module.ready` is left un-overriden.
# runtime.*.iffe.js
- Executed third (3)
- this is produced from `*.ts` files in this directory by rollupJS.
# dotnet.*.post.js
- Executed last (4)
- When `onRuntimeInitialized` is overriden it would wait for emscriptens `Module.ready`
- Otherwise it would wait for for MonoVM to load all assets and assemblies.
- It would pass on the API exports
# About new API
The signature is
```
function createDotnetRuntime(moduleFactory: (api: DotnetPublicAPI) => DotnetModuleConfig): Promise<DotNetExports>
```
Simplest intended usage looks like this in ES6:
```
import createDotnetRuntime from './dotnet.js'
await createDotnetRuntime(() => ({
configSrc: "./mono-config.json",
}));
```
More complex scenario with using APIs, commented
```
import createDotnetRuntime from './dotnet.js'
export const { MONO, BINDING } = await createDotnetRuntime(({ MONO, BINDING, Module }) =>
// this is callback with no statement, the APIs are only empty shells here and are populated later.
({
disableDotnet6Compatibility: true,
configSrc: "./mono-config.json",
onConfigLoaded: () => {
// This is called during emscripten `preInit` event, after we fetched config.
// Module.config is loaded and could be tweaked before application
Module.config.environment_variables["MONO_LOG_LEVEL"]="debug"
// here we could use API passed into this callback
// call some early available functions
MONO.mono_wasm_setenv("HELLO", "WORLD);
}
onDotnetReady: () => {
// Only when there is no `onRuntimeInitialized` override.
// This is called after all assets are loaded , mapping to legacy `config.loaded_cb`.
// It happens during emscripten `onRuntimeInitialized` after monoVm init + globalization + assemblies.
// This also matches when the top level promise is resolved.
// The original emscripten `Module.ready` promise is replaced with this.
// at this point both emscripten and monoVM are fully initialized.
Module.FS.chdir(processedArguments.working_dir);
},
onAbort: (error) => {
set_exit_code(1, error);
},
}));
// at this point both emscripten and monoVM are fully initialized.
// we could use the APIs returned and resolved from createDotnetRuntime promise
// both API exports are receiving the same API object instances, i.e. same `MONO` instance.
const run_all = BINDING.bind_static_method ("[debugger-test] DebuggerTest:run_all");
run_all();
```
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/metadata/w32process-unix-default.c | /**
* \file
*/
#include "w32process.h"
#include "w32process-unix-internals.h"
#ifdef USE_DEFAULT_BACKEND
#include <unistd.h>
#ifdef HOST_SOLARIS
/* procfs.h cannot be included if this define is set, but it seems to work fine if it is undefined */
#if _FILE_OFFSET_BITS == 64
#undef _FILE_OFFSET_BITS
#include <procfs.h>
#define _FILE_OFFSET_BITS 64
#else
#include <procfs.h>
#endif
#endif
#ifdef _AIX
/* like solaris, just different */
#include <sys/procfs.h>
/* fallback for procfs-less i */
#include <procinfo.h>
#include <sys/types.h>
#endif
/* makedev() macro */
#ifdef MAJOR_IN_MKDEV
#include <sys/mkdev.h>
#elif defined MAJOR_IN_SYSMACROS
#include <sys/sysmacros.h>
#endif
#include "utils/mono-logger-internals.h"
#include "icall-decl.h"
#ifndef MAXPATHLEN
#define MAXPATHLEN 242
#endif
/* XXX: why don't we just use proclib? */
gchar*
mono_w32process_get_name (pid_t pid)
{
FILE *fp;
gchar *filename;
gchar *ret = NULL;
#if defined(HOST_SOLARIS) || (defined(_AIX) && !defined(__PASE__))
filename = g_strdup_printf ("/proc/%d/psinfo", pid);
if ((fp = fopen (filename, "r")) != NULL) {
struct psinfo info;
int nread;
nread = fread (&info, sizeof (info), 1, fp);
if (nread == 1) {
ret = g_strdup (info.pr_fname);
}
fclose (fp);
}
g_free (filename);
#elif defined(__PASE__)
/* AIX has a procfs, but it's not available on i */
struct procentry64 proc;
pid_t newpid;
newpid = pid;
if (getprocs64(&proc, sizeof (proc), NULL, NULL, &newpid, 1) == 1) {
ret = g_strdup (proc.pi_comm);
}
#else
gchar buf[256];
memset (buf, '\0', sizeof(buf));
filename = g_strdup_printf ("/proc/%d/exe", pid);
#if defined(HAVE_READLINK)
if (readlink (filename, buf, 255) > 0) {
ret = g_strdup (buf);
}
#endif
g_free (filename);
if (ret != NULL) {
return(ret);
}
filename = g_strdup_printf ("/proc/%d/cmdline", pid);
if ((fp = fopen (filename, "r")) != NULL) {
if (fgets (buf, 256, fp) != NULL) {
ret = g_strdup (buf);
}
fclose (fp);
}
g_free (filename);
if (ret != NULL) {
return(ret);
}
filename = g_strdup_printf ("/proc/%d/stat", pid);
if ((fp = fopen (filename, "r")) != NULL) {
if (fgets (buf, 256, fp) != NULL) {
char *start, *end;
start = strchr (buf, '(');
if (start != NULL) {
end = strchr (start + 1, ')');
if (end != NULL) {
ret = g_strndup (start + 1,
end - start - 1);
}
}
}
fclose (fp);
}
g_free (filename);
#endif
return ret;
}
gchar*
mono_w32process_get_path (pid_t pid)
{
return mono_w32process_get_name (pid);
}
#else
MONO_EMPTY_SOURCE_FILE (w32process_unix_default);
#endif
| /**
* \file
*/
#include "w32process.h"
#include "w32process-unix-internals.h"
#ifdef USE_DEFAULT_BACKEND
#include <unistd.h>
#ifdef HOST_SOLARIS
/* procfs.h cannot be included if this define is set, but it seems to work fine if it is undefined */
#if _FILE_OFFSET_BITS == 64
#undef _FILE_OFFSET_BITS
#include <procfs.h>
#define _FILE_OFFSET_BITS 64
#else
#include <procfs.h>
#endif
#endif
#ifdef _AIX
/* like solaris, just different */
#include <sys/procfs.h>
/* fallback for procfs-less i */
#include <procinfo.h>
#include <sys/types.h>
#endif
/* makedev() macro */
#ifdef MAJOR_IN_MKDEV
#include <sys/mkdev.h>
#elif defined MAJOR_IN_SYSMACROS
#include <sys/sysmacros.h>
#endif
#include "utils/mono-logger-internals.h"
#include "icall-decl.h"
#ifndef MAXPATHLEN
#define MAXPATHLEN 242
#endif
/* XXX: why don't we just use proclib? */
gchar*
mono_w32process_get_name (pid_t pid)
{
FILE *fp;
gchar *filename;
gchar *ret = NULL;
#if defined(HOST_SOLARIS) || (defined(_AIX) && !defined(__PASE__))
filename = g_strdup_printf ("/proc/%d/psinfo", pid);
if ((fp = fopen (filename, "r")) != NULL) {
struct psinfo info;
int nread;
nread = fread (&info, sizeof (info), 1, fp);
if (nread == 1) {
ret = g_strdup (info.pr_fname);
}
fclose (fp);
}
g_free (filename);
#elif defined(__PASE__)
/* AIX has a procfs, but it's not available on i */
struct procentry64 proc;
pid_t newpid;
newpid = pid;
if (getprocs64(&proc, sizeof (proc), NULL, NULL, &newpid, 1) == 1) {
ret = g_strdup (proc.pi_comm);
}
#else
gchar buf[256];
memset (buf, '\0', sizeof(buf));
filename = g_strdup_printf ("/proc/%d/exe", pid);
#if defined(HAVE_READLINK)
if (readlink (filename, buf, 255) > 0) {
ret = g_strdup (buf);
}
#endif
g_free (filename);
if (ret != NULL) {
return(ret);
}
filename = g_strdup_printf ("/proc/%d/cmdline", pid);
if ((fp = fopen (filename, "r")) != NULL) {
if (fgets (buf, 256, fp) != NULL) {
ret = g_strdup (buf);
}
fclose (fp);
}
g_free (filename);
if (ret != NULL) {
return(ret);
}
filename = g_strdup_printf ("/proc/%d/stat", pid);
if ((fp = fopen (filename, "r")) != NULL) {
if (fgets (buf, 256, fp) != NULL) {
char *start, *end;
start = strchr (buf, '(');
if (start != NULL) {
end = strchr (start + 1, ')');
if (end != NULL) {
ret = g_strndup (start + 1,
end - start - 1);
}
}
}
fclose (fp);
}
g_free (filename);
#endif
return ret;
}
gchar*
mono_w32process_get_path (pid_t pid)
{
return mono_w32process_get_name (pid);
}
#else
MONO_EMPTY_SOURCE_FILE (w32process_unix_default);
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/win/pal-single-threaded.c | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// This is minimal implementation of posix functions files required to cross compile
// libunwind on a Windows host for UNW_REMOTE_ONLY application.
// This a completely thread unsafe implementation
// It is likely sufficient for a single thread's usage of UNW_REMOTE_ONLY debugging of
// a read-only dump.
#include <pthread.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include "libunwind_i.h"
#include "compiler.h"
int getpagesize(void)
{
// 4096 is truth for most targets
// Unlikely to matter in dump debugging
return 4096;
}
void* mmap(void *addr, size_t length, int prot, int flags, int fd, size_t offset)
{
// We shouldn't be doing anything other than anonymous mappings
if ((flags & MAP_ANONYMOUS) == 0)
return MAP_FAILED;
return calloc(1, length);
}
int munmap(void *addr, size_t length)
{
free(addr);
return 0;
}
int pthread_key_create(pthread_key_t *key, void (*destroy)(void*))
{
// We are not implementing pthread_getspecific so this sholdn't matter much
return 0;
}
int pthread_setspecific(pthread_key_t key, const void *value)
{
// We are not implementing pthread_getspecific so this sholdn't matter much
return 0;
}
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
{
// For dump debugging we don't need locking
// We expect to run in a single thread
return 0;
}
int pthread_mutex_lock(pthread_mutex_t *mutex)
{
// For dump debugging we don't need locking
// We expect to run in a single thread
return 0;
}
int pthread_mutex_unlock(pthread_mutex_t *mutex)
{
// For dump debugging we don't need locking
// We expect to run in a single thread
return 0;
}
int pthread_once(pthread_once_t *control, void (*init)(void))
{
if (control == 0)
return -1;
// We expect to run in a single thread
// We don't need atomics here
if (*control != PTHREAD_ONCE_INIT)
{
(*init)();
*control = ~PTHREAD_ONCE_INIT;
}
return 0;
}
int sigfillset(sigset_t *set)
{
return 0;
}
ssize_t read(int fd, void *buf, size_t count)
{
// For dump debugging we shouldn't need to open files
// Especially since we didn't implement open()
return -1;
}
int close(int fd)
{
// For dump debugging we shouldn't need to open files
// Especially since we didn't implement open()
return -1;
}
// ALIAS(x) is nop. We need this alias to link properly
unw_accessors_t * unw_get_accessors_int (unw_addr_space_t as)
{
return unw_get_accessors(as);
}
int stat(const char *path, struct stat *buf)
{
return 0;
}
int fstat(int fd, struct stat *buf)
{
return 0;
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// This is minimal implementation of posix functions files required to cross compile
// libunwind on a Windows host for UNW_REMOTE_ONLY application.
// This a completely thread unsafe implementation
// It is likely sufficient for a single thread's usage of UNW_REMOTE_ONLY debugging of
// a read-only dump.
#include <pthread.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include "libunwind_i.h"
#include "compiler.h"
int getpagesize(void)
{
// 4096 is truth for most targets
// Unlikely to matter in dump debugging
return 4096;
}
void* mmap(void *addr, size_t length, int prot, int flags, int fd, size_t offset)
{
// We shouldn't be doing anything other than anonymous mappings
if ((flags & MAP_ANONYMOUS) == 0)
return MAP_FAILED;
return calloc(1, length);
}
int munmap(void *addr, size_t length)
{
free(addr);
return 0;
}
int pthread_key_create(pthread_key_t *key, void (*destroy)(void*))
{
// We are not implementing pthread_getspecific so this sholdn't matter much
return 0;
}
int pthread_setspecific(pthread_key_t key, const void *value)
{
// We are not implementing pthread_getspecific so this sholdn't matter much
return 0;
}
int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
{
// For dump debugging we don't need locking
// We expect to run in a single thread
return 0;
}
int pthread_mutex_lock(pthread_mutex_t *mutex)
{
// For dump debugging we don't need locking
// We expect to run in a single thread
return 0;
}
int pthread_mutex_unlock(pthread_mutex_t *mutex)
{
// For dump debugging we don't need locking
// We expect to run in a single thread
return 0;
}
int pthread_once(pthread_once_t *control, void (*init)(void))
{
if (control == 0)
return -1;
// We expect to run in a single thread
// We don't need atomics here
if (*control != PTHREAD_ONCE_INIT)
{
(*init)();
*control = ~PTHREAD_ONCE_INIT;
}
return 0;
}
int sigfillset(sigset_t *set)
{
return 0;
}
ssize_t read(int fd, void *buf, size_t count)
{
// For dump debugging we shouldn't need to open files
// Especially since we didn't implement open()
return -1;
}
int close(int fd)
{
// For dump debugging we shouldn't need to open files
// Especially since we didn't implement open()
return -1;
}
// ALIAS(x) is nop. We need this alias to link properly
unw_accessors_t * unw_get_accessors_int (unw_addr_space_t as)
{
return unw_get_accessors(as);
}
int stat(const char *path, struct stat *buf)
{
return 0;
}
int fstat(int fd, struct stat *buf)
{
return 0;
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/utils/mono-mmap-windows.c | /**
* \file
* Windows support for mapping code into the process address space
*
* Author:
* Mono Team ([email protected])
*
* Copyright 2001-2008 Novell, Inc.
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#include <glib.h>
#if defined(HOST_WIN32)
#include <io.h>
#include <windows.h>
#include <mono/utils/mono-counters.h>
#include "mono/utils/mono-mmap.h"
#include "mono/utils/mono-mmap-internals.h"
#include <mono/utils/w32subset.h>
static void *malloced_shared_area;
int
mono_pagesize (void)
{
SYSTEM_INFO info;
static int saved_pagesize = 0;
if (saved_pagesize)
return saved_pagesize;
GetSystemInfo (&info);
saved_pagesize = info.dwPageSize;
return saved_pagesize;
}
int
mono_valloc_granule (void)
{
SYSTEM_INFO info;
static int saved_valloc_granule = 0;
if (saved_valloc_granule)
return saved_valloc_granule;
GetSystemInfo (&info);
saved_valloc_granule = info.dwAllocationGranularity;
return saved_valloc_granule;
}
int
mono_mmap_win_prot_from_flags (int flags)
{
int prot = flags & (MONO_MMAP_READ|MONO_MMAP_WRITE|MONO_MMAP_EXEC);
switch (prot) {
case 0: prot = PAGE_NOACCESS; break;
case MONO_MMAP_READ: prot = PAGE_READONLY; break;
case MONO_MMAP_READ|MONO_MMAP_EXEC: prot = PAGE_EXECUTE_READ; break;
case MONO_MMAP_READ|MONO_MMAP_WRITE: prot = PAGE_READWRITE; break;
case MONO_MMAP_READ|MONO_MMAP_WRITE|MONO_MMAP_EXEC: prot = PAGE_EXECUTE_READWRITE; break;
case MONO_MMAP_WRITE: prot = PAGE_READWRITE; break;
case MONO_MMAP_WRITE|MONO_MMAP_EXEC: prot = PAGE_EXECUTE_READWRITE; break;
case MONO_MMAP_EXEC: prot = PAGE_EXECUTE; break;
default:
g_assert_not_reached ();
}
return prot;
}
/**
* mono_setmmapjit:
* \param flag indicating whether to enable or disable the use of MAP_JIT in mmap
*
* Call this method to enable or disable the use of MAP_JIT to create the pages
* for the JIT to use. This is only needed for scenarios where Mono is bundled
* as an App in MacOS
*/
void
mono_setmmapjit (int flag)
{
/* Ignored on HOST_WIN32 */
}
void*
mono_valloc (void *addr, size_t length, int flags, MonoMemAccountType type)
{
if (!mono_valloc_can_alloc (length))
return NULL;
void *ptr;
int mflags = MEM_RESERVE|MEM_COMMIT;
int prot = mono_mmap_win_prot_from_flags (flags);
/* translate the flags */
ptr = VirtualAlloc (addr, length, mflags, prot);
mono_account_mem (type, (ssize_t)length);
return ptr;
}
void*
mono_valloc_aligned (size_t length, size_t alignment, int flags, MonoMemAccountType type)
{
int prot = mono_mmap_win_prot_from_flags (flags);
char *mem = (char*)VirtualAlloc (NULL, length + alignment, MEM_RESERVE, prot);
char *aligned;
if (!mem)
return NULL;
if (!mono_valloc_can_alloc (length))
return NULL;
aligned = mono_aligned_address (mem, length, alignment);
aligned = (char*)VirtualAlloc (aligned, length, MEM_COMMIT, prot);
g_assert (aligned);
mono_account_mem (type, (ssize_t)length);
return aligned;
}
int
mono_vfree (void *addr, size_t length, MonoMemAccountType type)
{
MEMORY_BASIC_INFORMATION mbi;
SIZE_T query_result = VirtualQuery (addr, &mbi, sizeof (mbi));
BOOL res;
g_assert (query_result);
res = VirtualFree (mbi.AllocationBase, 0, MEM_RELEASE);
g_assert (res);
mono_account_mem (type, -(ssize_t)length);
return 0;
}
#if HAVE_API_SUPPORT_WIN32_FILE_MAPPING || HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP
static void
remove_trailing_whitespace_utf8 (gchar *s)
{
glong length = g_utf8_strlen (s, -1);
glong const original_length = length;
while (length > 0 && g_ascii_isspace (s [length - 1]))
--length;
if (length != original_length)
s [length] = 0;
}
#if HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE
gchar *
format_win32_error_string (gint32 win32_error)
{
gchar *ret = NULL;
#if HAVE_API_SUPPORT_WIN32_LOCAL_ALLOC_FREE
PWSTR buf = NULL;
if (FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
win32_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (PWSTR)&buf, 0, NULL)) {
ret = u16to8 (buf);
LocalFree (buf);
}
#else
WCHAR local_buf [1024];
if (!FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
win32_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), local_buf, STRING_LENGTH (local_buf), NULL) )
local_buf [0] = TEXT('\0');
ret = u16to8 (local_buf)
#endif
if (ret)
remove_trailing_whitespace_utf8 (ret);
return ret;
}
#elif !HAVE_EXTERN_DEFINED_WIN32_FORMAT_MESSAGE
gchar *
format_win32_error_string (gint32 error_code)
{
return g_strdup_printf ("GetLastError=%d. FormatMessage not supported.", GetLastError ());
}
#endif /* HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE */
void*
mono_file_map_error (size_t length, int flags, int fd, guint64 offset, void **ret_handle,
const char *filepath, char **error_message)
{
void *ptr = NULL;
HANDLE mapping = NULL;
int const prot = mono_mmap_win_prot_from_flags (flags);
/* translate the flags */
/*if (flags & MONO_MMAP_PRIVATE)
mflags |= MAP_PRIVATE;
if (flags & MONO_MMAP_SHARED)
mflags |= MAP_SHARED;
if (flags & MONO_MMAP_ANON)
mflags |= MAP_ANONYMOUS;
if (flags & MONO_MMAP_FIXED)
mflags |= MAP_FIXED;
if (flags & MONO_MMAP_32BIT)
mflags |= MAP_32BIT;*/
int const mflags = (flags & MONO_MMAP_WRITE) ? FILE_MAP_COPY : FILE_MAP_READ;
HANDLE const file = (HANDLE)_get_osfhandle (fd);
const char *failed_function = NULL;
// The size of the mapping is the maximum file offset to map.
//
// It is not, as you might expect, the maximum view size to be mapped from it.
//
// If it were the maximum view size, the size parameter would have just
// been one DWORD in 32bit Windows, expanded to SIZE_T in 64bit Windows.
// It is 64bits even on 32bit Windows to allow large files.
//
// See https://docs.microsoft.com/en-us/windows/desktop/Memory/creating-a-file-mapping-object.
const guint64 mapping_length = offset + length;
#if HAVE_API_SUPPORT_WIN32_FILE_MAPPING
failed_function = "CreateFileMapping";
mapping = CreateFileMappingW (file, NULL, prot, (DWORD)(mapping_length >> 32), (DWORD)mapping_length, NULL);
if (mapping == NULL)
goto exit;
failed_function = "MapViewOfFile";
ptr = MapViewOfFile (mapping, mflags, (DWORD)(offset >> 32), (DWORD)offset, length);
if (ptr == NULL)
goto exit;
#elif HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP
failed_function = "CreateFileMappingFromApp";
mapping = CreateFileMappingFromApp (file, NULL, prot, mapping_length, NULL);
if (mapping == NULL)
goto exit;
failed_function = "MapViewOfFileFromApp";
ptr = MapViewOfFileFromApp (mapping, mflags, offset, length);
if (ptr == NULL)
goto exit;
#else
#error unknown Windows variant
#endif
exit:
if (!ptr && (mapping || error_message)) {
int const win32_error = GetLastError ();
if (mapping)
CloseHandle (mapping);
if (error_message) {
gchar *win32_error_string = format_win32_error_string (win32_error);
*error_message = g_strdup_printf ("%s failed file:%s length:0x%IX offset:0x%I64X function:%s error:%s(0x%X)\n",
__func__, filepath ? filepath : "", length, offset, failed_function, win32_error_string, win32_error);
g_free (win32_error_string);
}
SetLastError (win32_error);
}
*ret_handle = mapping;
return ptr;
}
int
mono_file_unmap (void *addr, void *handle)
{
UnmapViewOfFile (addr);
CloseHandle (handle);
return 0;
}
#elif !HAVE_EXTERN_DEFINED_WIN32_FILE_MAPPING && !HAVE_EXTERN_DEFINED_WIN32_FILE_MAPPING_FROM_APP
void*
mono_file_map_error (size_t length, int flags, int fd, guint64 offset, void **ret_handle,
const char *filepath, char **error_message)
{
g_unsupported_api ("CreateFileMapping");
*ret_handle = NULL;
SetLastError (ERROR_NOT_SUPPORTED);
return NULL;
}
int
mono_file_unmap (void *addr, void *handle)
{
g_unsupported_api ("UnmapViewOfFile");
SetLastError (ERROR_NOT_SUPPORTED);
return 0;
}
#endif /* HAVE_API_SUPPORT_WIN32_FILE_MAPPING || HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP */
void*
mono_file_map (size_t length, int flags, int fd, guint64 offset, void **ret_handle)
{
return mono_file_map_error (length, flags, fd, offset, ret_handle, NULL, NULL);
}
int
mono_mprotect (void *addr, size_t length, int flags)
{
DWORD oldprot;
int prot = mono_mmap_win_prot_from_flags (flags);
if (flags & MONO_MMAP_DISCARD) {
VirtualFree (addr, length, MEM_DECOMMIT);
VirtualAlloc (addr, length, MEM_COMMIT, prot);
return 0;
}
return VirtualProtect (addr, length, prot, &oldprot) == 0;
}
void*
mono_shared_area (void)
{
if (!malloced_shared_area)
malloced_shared_area = mono_malloc_shared_area (0);
/* get the pid here */
return malloced_shared_area;
}
void
mono_shared_area_remove (void)
{
if (malloced_shared_area)
g_free (malloced_shared_area);
malloced_shared_area = NULL;
}
void*
mono_shared_area_for_pid (void *pid)
{
return NULL;
}
void
mono_shared_area_unload (void *area)
{
}
int
mono_shared_area_instances (void **array, int count)
{
return 0;
}
#else
#include <mono/utils/mono-compiler.h>
MONO_EMPTY_SOURCE_FILE (mono_mmap_windows);
#endif // HOST_WIN32
| /**
* \file
* Windows support for mapping code into the process address space
*
* Author:
* Mono Team ([email protected])
*
* Copyright 2001-2008 Novell, Inc.
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#include <glib.h>
#if defined(HOST_WIN32)
#include <io.h>
#include <windows.h>
#include <mono/utils/mono-counters.h>
#include "mono/utils/mono-mmap.h"
#include "mono/utils/mono-mmap-internals.h"
#include <mono/utils/w32subset.h>
static void *malloced_shared_area;
int
mono_pagesize (void)
{
SYSTEM_INFO info;
static int saved_pagesize = 0;
if (saved_pagesize)
return saved_pagesize;
GetSystemInfo (&info);
saved_pagesize = info.dwPageSize;
return saved_pagesize;
}
int
mono_valloc_granule (void)
{
SYSTEM_INFO info;
static int saved_valloc_granule = 0;
if (saved_valloc_granule)
return saved_valloc_granule;
GetSystemInfo (&info);
saved_valloc_granule = info.dwAllocationGranularity;
return saved_valloc_granule;
}
int
mono_mmap_win_prot_from_flags (int flags)
{
int prot = flags & (MONO_MMAP_READ|MONO_MMAP_WRITE|MONO_MMAP_EXEC);
switch (prot) {
case 0: prot = PAGE_NOACCESS; break;
case MONO_MMAP_READ: prot = PAGE_READONLY; break;
case MONO_MMAP_READ|MONO_MMAP_EXEC: prot = PAGE_EXECUTE_READ; break;
case MONO_MMAP_READ|MONO_MMAP_WRITE: prot = PAGE_READWRITE; break;
case MONO_MMAP_READ|MONO_MMAP_WRITE|MONO_MMAP_EXEC: prot = PAGE_EXECUTE_READWRITE; break;
case MONO_MMAP_WRITE: prot = PAGE_READWRITE; break;
case MONO_MMAP_WRITE|MONO_MMAP_EXEC: prot = PAGE_EXECUTE_READWRITE; break;
case MONO_MMAP_EXEC: prot = PAGE_EXECUTE; break;
default:
g_assert_not_reached ();
}
return prot;
}
/**
* mono_setmmapjit:
* \param flag indicating whether to enable or disable the use of MAP_JIT in mmap
*
* Call this method to enable or disable the use of MAP_JIT to create the pages
* for the JIT to use. This is only needed for scenarios where Mono is bundled
* as an App in MacOS
*/
void
mono_setmmapjit (int flag)
{
/* Ignored on HOST_WIN32 */
}
void*
mono_valloc (void *addr, size_t length, int flags, MonoMemAccountType type)
{
if (!mono_valloc_can_alloc (length))
return NULL;
void *ptr;
int mflags = MEM_RESERVE|MEM_COMMIT;
int prot = mono_mmap_win_prot_from_flags (flags);
/* translate the flags */
ptr = VirtualAlloc (addr, length, mflags, prot);
mono_account_mem (type, (ssize_t)length);
return ptr;
}
void*
mono_valloc_aligned (size_t length, size_t alignment, int flags, MonoMemAccountType type)
{
int prot = mono_mmap_win_prot_from_flags (flags);
char *mem = (char*)VirtualAlloc (NULL, length + alignment, MEM_RESERVE, prot);
char *aligned;
if (!mem)
return NULL;
if (!mono_valloc_can_alloc (length))
return NULL;
aligned = mono_aligned_address (mem, length, alignment);
aligned = (char*)VirtualAlloc (aligned, length, MEM_COMMIT, prot);
g_assert (aligned);
mono_account_mem (type, (ssize_t)length);
return aligned;
}
int
mono_vfree (void *addr, size_t length, MonoMemAccountType type)
{
MEMORY_BASIC_INFORMATION mbi;
SIZE_T query_result = VirtualQuery (addr, &mbi, sizeof (mbi));
BOOL res;
g_assert (query_result);
res = VirtualFree (mbi.AllocationBase, 0, MEM_RELEASE);
g_assert (res);
mono_account_mem (type, -(ssize_t)length);
return 0;
}
#if HAVE_API_SUPPORT_WIN32_FILE_MAPPING || HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP
static void
remove_trailing_whitespace_utf8 (gchar *s)
{
glong length = g_utf8_strlen (s, -1);
glong const original_length = length;
while (length > 0 && g_ascii_isspace (s [length - 1]))
--length;
if (length != original_length)
s [length] = 0;
}
#if HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE
gchar *
format_win32_error_string (gint32 win32_error)
{
gchar *ret = NULL;
#if HAVE_API_SUPPORT_WIN32_LOCAL_ALLOC_FREE
PWSTR buf = NULL;
if (FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
win32_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (PWSTR)&buf, 0, NULL)) {
ret = u16to8 (buf);
LocalFree (buf);
}
#else
WCHAR local_buf [1024];
if (!FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
win32_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), local_buf, STRING_LENGTH (local_buf), NULL) )
local_buf [0] = TEXT('\0');
ret = u16to8 (local_buf)
#endif
if (ret)
remove_trailing_whitespace_utf8 (ret);
return ret;
}
#elif !HAVE_EXTERN_DEFINED_WIN32_FORMAT_MESSAGE
gchar *
format_win32_error_string (gint32 error_code)
{
return g_strdup_printf ("GetLastError=%d. FormatMessage not supported.", GetLastError ());
}
#endif /* HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE */
void*
mono_file_map_error (size_t length, int flags, int fd, guint64 offset, void **ret_handle,
const char *filepath, char **error_message)
{
void *ptr = NULL;
HANDLE mapping = NULL;
int const prot = mono_mmap_win_prot_from_flags (flags);
/* translate the flags */
/*if (flags & MONO_MMAP_PRIVATE)
mflags |= MAP_PRIVATE;
if (flags & MONO_MMAP_SHARED)
mflags |= MAP_SHARED;
if (flags & MONO_MMAP_ANON)
mflags |= MAP_ANONYMOUS;
if (flags & MONO_MMAP_FIXED)
mflags |= MAP_FIXED;
if (flags & MONO_MMAP_32BIT)
mflags |= MAP_32BIT;*/
int const mflags = (flags & MONO_MMAP_WRITE) ? FILE_MAP_COPY : FILE_MAP_READ;
HANDLE const file = (HANDLE)_get_osfhandle (fd);
const char *failed_function = NULL;
// The size of the mapping is the maximum file offset to map.
//
// It is not, as you might expect, the maximum view size to be mapped from it.
//
// If it were the maximum view size, the size parameter would have just
// been one DWORD in 32bit Windows, expanded to SIZE_T in 64bit Windows.
// It is 64bits even on 32bit Windows to allow large files.
//
// See https://docs.microsoft.com/en-us/windows/desktop/Memory/creating-a-file-mapping-object.
const guint64 mapping_length = offset + length;
#if HAVE_API_SUPPORT_WIN32_FILE_MAPPING
failed_function = "CreateFileMapping";
mapping = CreateFileMappingW (file, NULL, prot, (DWORD)(mapping_length >> 32), (DWORD)mapping_length, NULL);
if (mapping == NULL)
goto exit;
failed_function = "MapViewOfFile";
ptr = MapViewOfFile (mapping, mflags, (DWORD)(offset >> 32), (DWORD)offset, length);
if (ptr == NULL)
goto exit;
#elif HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP
failed_function = "CreateFileMappingFromApp";
mapping = CreateFileMappingFromApp (file, NULL, prot, mapping_length, NULL);
if (mapping == NULL)
goto exit;
failed_function = "MapViewOfFileFromApp";
ptr = MapViewOfFileFromApp (mapping, mflags, offset, length);
if (ptr == NULL)
goto exit;
#else
#error unknown Windows variant
#endif
exit:
if (!ptr && (mapping || error_message)) {
int const win32_error = GetLastError ();
if (mapping)
CloseHandle (mapping);
if (error_message) {
gchar *win32_error_string = format_win32_error_string (win32_error);
*error_message = g_strdup_printf ("%s failed file:%s length:0x%IX offset:0x%I64X function:%s error:%s(0x%X)\n",
__func__, filepath ? filepath : "", length, offset, failed_function, win32_error_string, win32_error);
g_free (win32_error_string);
}
SetLastError (win32_error);
}
*ret_handle = mapping;
return ptr;
}
int
mono_file_unmap (void *addr, void *handle)
{
UnmapViewOfFile (addr);
CloseHandle (handle);
return 0;
}
#elif !HAVE_EXTERN_DEFINED_WIN32_FILE_MAPPING && !HAVE_EXTERN_DEFINED_WIN32_FILE_MAPPING_FROM_APP
void*
mono_file_map_error (size_t length, int flags, int fd, guint64 offset, void **ret_handle,
const char *filepath, char **error_message)
{
g_unsupported_api ("CreateFileMapping");
*ret_handle = NULL;
SetLastError (ERROR_NOT_SUPPORTED);
return NULL;
}
int
mono_file_unmap (void *addr, void *handle)
{
g_unsupported_api ("UnmapViewOfFile");
SetLastError (ERROR_NOT_SUPPORTED);
return 0;
}
#endif /* HAVE_API_SUPPORT_WIN32_FILE_MAPPING || HAVE_API_SUPPORT_WIN32_FILE_MAPPING_FROM_APP */
void*
mono_file_map (size_t length, int flags, int fd, guint64 offset, void **ret_handle)
{
return mono_file_map_error (length, flags, fd, offset, ret_handle, NULL, NULL);
}
int
mono_mprotect (void *addr, size_t length, int flags)
{
DWORD oldprot;
int prot = mono_mmap_win_prot_from_flags (flags);
if (flags & MONO_MMAP_DISCARD) {
VirtualFree (addr, length, MEM_DECOMMIT);
VirtualAlloc (addr, length, MEM_COMMIT, prot);
return 0;
}
return VirtualProtect (addr, length, prot, &oldprot) == 0;
}
void*
mono_shared_area (void)
{
if (!malloced_shared_area)
malloced_shared_area = mono_malloc_shared_area (0);
/* get the pid here */
return malloced_shared_area;
}
void
mono_shared_area_remove (void)
{
if (malloced_shared_area)
g_free (malloced_shared_area);
malloced_shared_area = NULL;
}
void*
mono_shared_area_for_pid (void *pid)
{
return NULL;
}
void
mono_shared_area_unload (void *area)
{
}
int
mono_shared_area_instances (void **array, int count)
{
return 0;
}
#else
#include <mono/utils/mono-compiler.h>
MONO_EMPTY_SOURCE_FILE (mono_mmap_windows);
#endif // HOST_WIN32
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/mini/tramp-riscv.c | /*
* Licensed to the .NET Foundation under one or more agreements.
* The .NET Foundation licenses this file to you under the MIT license.
*/
#include "mini-runtime.h"
#include <mono/metadata/abi-details.h>
void
mono_arch_patch_callsite (guint8 *method_start, guint8 *code_ptr, guint8 *addr)
{
NOT_IMPLEMENTED;
}
void
mono_arch_patch_plt_entry (guint8 *code, gpointer *got, host_mgreg_t *regs, guint8 *addr)
{
NOT_IMPLEMENTED;
}
guint8 *
mono_arch_get_call_target (guint8 *code)
{
NOT_IMPLEMENTED;
return NULL;
}
guint32
mono_arch_get_plt_info_offset (guint8 *plt_entry, host_mgreg_t *regs, guint8 *code)
{
NOT_IMPLEMENTED;
return 0;
}
GSList *
mono_arch_get_delegate_invoke_impls (void)
{
NOT_IMPLEMENTED;
return NULL;
}
gpointer
mono_arch_get_delegate_invoke_impl (MonoMethodSignature *sig, gboolean has_target)
{
NOT_IMPLEMENTED;
return NULL;
}
gpointer
mono_arch_get_delegate_virtual_invoke_impl (MonoMethodSignature *sig,
MonoMethod *method, int offset,
gboolean load_imt_reg)
{
NOT_IMPLEMENTED;
return NULL;
}
#ifndef DISABLE_JIT
guchar *
mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInfo **info,
gboolean aot)
{
if (aot)
NOT_IMPLEMENTED;
guint8 *buf = mono_global_codeman_reserve (1024), *code = buf;
if (info) {
const char *name = mono_get_generic_trampoline_name (tramp_type);
*info = mono_tramp_info_create (name, buf, code - buf, NULL, NULL);
}
return buf;
}
gpointer
mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type,
MonoMemoryManager *mem_manager, guint32 *code_len)
{
guint8 *buf = mono_mem_manager_code_reserve (mem_manager, 64), *code = buf;
guint8 *tramp = mono_get_trampoline_code (tramp_type);
// Pass the argument in scratch t0.
code = mono_riscv_emit_imm (code, RISCV_T0, (gsize) arg1);
code = mono_riscv_emit_imm (code, RISCV_T1, (gsize) tramp);
riscv_jalr (code, RISCV_ZERO, RISCV_T1, 0);
mono_arch_flush_icache (buf, code - buf);
if (code_len)
*code_len = code - buf;
return buf;
}
gpointer
mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr)
{
MonoMemoryManager *mem_manager = m_method_get_mem_manager (m);
guint8 *buf = mono_mem_manager_code_reserve (mem_manager, 64), *code = buf;
// Pass the argument in a0.
code = mono_riscv_emit_imm (code, RISCV_A0, sizeof (MonoObject));
code = mono_riscv_emit_imm (code, RISCV_T0, (gsize) addr);
riscv_jalr (code, RISCV_ZERO, RISCV_T0, 0);
mono_arch_flush_icache (buf, code - buf);
return buf;
}
gpointer
mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoIMTCheckItem **imt_entries, int count,
gpointer fail_tramp)
{
NOT_IMPLEMENTED;
return NULL;
}
gpointer
mono_arch_get_static_rgctx_trampoline (MonoMemoryManager *mem_manager, gpointer arg, gpointer addr)
{
guint8 *buf = mono_mem_manager_code_reserve (mem_manager, 64), *code = buf;
// Pass the argument in the RGCTX register.
code = mono_riscv_emit_imm (code, MONO_ARCH_RGCTX_REG, (gsize) arg);
code = mono_riscv_emit_imm (code, RISCV_T0, (gsize) addr);
riscv_jalr (code, RISCV_ZERO, RISCV_T0, 0);
mono_arch_flush_icache (buf, code - buf);
return buf;
}
gpointer
mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info,
gboolean aot)
{
if (aot)
NOT_IMPLEMENTED;
gboolean is_mrgctx = MONO_RGCTX_SLOT_IS_MRGCTX (slot);
int index = MONO_RGCTX_SLOT_INDEX (slot);
if (is_mrgctx)
index += MONO_SIZEOF_METHOD_RUNTIME_GENERIC_CONTEXT / sizeof (target_mgreg_t);
int depth;
for (depth = 0; ; depth++) {
int size = mono_class_rgctx_get_array_size (depth, is_mrgctx);
if (index < size - 1)
break;
index -= size - 1;
}
guint8 *buf = mono_global_codeman_reserve (128 * depth), *code = buf;
guint8 **null_jumps = g_malloc0 (sizeof (guint8 *) * (depth + 2));
if (!is_mrgctx) {
} else
riscv_addi (code, RISCV_T1, RISCV_A0, 0);
mono_arch_flush_icache (buf, code - buf);
if (info) {
char *name = mono_get_rgctx_fetch_trampoline_name (slot);
*info = mono_tramp_info_create (name, buf, code - buf, NULL, NULL);
g_free (name);
}
return buf;
}
gpointer
mono_arch_create_general_rgctx_lazy_fetch_trampoline (MonoTrampInfo **info, gboolean aot)
{
if (aot)
NOT_IMPLEMENTED;
guint8 *buf = mono_global_codeman_reserve (64), *code = buf;
/*
* The RGCTX register holds a pointer to a <slot, trampoline address> pair.
* Load the trampoline address and branch to it. a0 holds the actual
* (M)RGCTX or VTable.
*/
code = mono_riscv_emit_load (code, RISCV_T0, MONO_ARCH_RGCTX_REG, sizeof (target_mgreg_t));
riscv_jalr (code, RISCV_ZERO, RISCV_T0, 0);
mono_arch_flush_icache (buf, code - buf);
if (info)
*info = mono_tramp_info_create ("rgctx_fetch_trampoline_general", buf, code - buf, NULL, NULL);
return buf;
}
guint8 *
mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gboolean aot)
{
NOT_IMPLEMENTED;
return NULL;
}
gpointer
mono_arch_get_interp_to_native_trampoline (MonoTrampInfo **info)
{
NOT_IMPLEMENTED;
return NULL;
}
gpointer
mono_arch_get_native_to_interp_trampoline (MonoTrampInfo **info)
{
NOT_IMPLEMENTED;
return NULL;
}
#else
guchar *
mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInfo **info,
gboolean aot)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type,
MonoMemoryManager *mem_manager, guint32 *code_len)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoIMTCheckItem **imt_entries, int count,
gpointer fail_tramp)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_get_static_rgctx_trampoline (MonoMemoryManager *mem_manager, gpointer arg, gpointer addr)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info,
gboolean aot)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_create_general_rgctx_lazy_fetch_trampoline (MonoTrampInfo **info, gboolean aot)
{
g_assert_not_reached ();
return NULL;
}
guint8 *
mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gboolean aot)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_get_interp_to_native_trampoline (MonoTrampInfo **info)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_get_native_to_interp_trampoline (MonoTrampInfo **info)
{
g_assert_not_reached ();
return NULL;
}
#endif
| /*
* Licensed to the .NET Foundation under one or more agreements.
* The .NET Foundation licenses this file to you under the MIT license.
*/
#include "mini-runtime.h"
#include <mono/metadata/abi-details.h>
void
mono_arch_patch_callsite (guint8 *method_start, guint8 *code_ptr, guint8 *addr)
{
NOT_IMPLEMENTED;
}
void
mono_arch_patch_plt_entry (guint8 *code, gpointer *got, host_mgreg_t *regs, guint8 *addr)
{
NOT_IMPLEMENTED;
}
guint8 *
mono_arch_get_call_target (guint8 *code)
{
NOT_IMPLEMENTED;
return NULL;
}
guint32
mono_arch_get_plt_info_offset (guint8 *plt_entry, host_mgreg_t *regs, guint8 *code)
{
NOT_IMPLEMENTED;
return 0;
}
GSList *
mono_arch_get_delegate_invoke_impls (void)
{
NOT_IMPLEMENTED;
return NULL;
}
gpointer
mono_arch_get_delegate_invoke_impl (MonoMethodSignature *sig, gboolean has_target)
{
NOT_IMPLEMENTED;
return NULL;
}
gpointer
mono_arch_get_delegate_virtual_invoke_impl (MonoMethodSignature *sig,
MonoMethod *method, int offset,
gboolean load_imt_reg)
{
NOT_IMPLEMENTED;
return NULL;
}
#ifndef DISABLE_JIT
guchar *
mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInfo **info,
gboolean aot)
{
if (aot)
NOT_IMPLEMENTED;
guint8 *buf = mono_global_codeman_reserve (1024), *code = buf;
if (info) {
const char *name = mono_get_generic_trampoline_name (tramp_type);
*info = mono_tramp_info_create (name, buf, code - buf, NULL, NULL);
}
return buf;
}
gpointer
mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type,
MonoMemoryManager *mem_manager, guint32 *code_len)
{
guint8 *buf = mono_mem_manager_code_reserve (mem_manager, 64), *code = buf;
guint8 *tramp = mono_get_trampoline_code (tramp_type);
// Pass the argument in scratch t0.
code = mono_riscv_emit_imm (code, RISCV_T0, (gsize) arg1);
code = mono_riscv_emit_imm (code, RISCV_T1, (gsize) tramp);
riscv_jalr (code, RISCV_ZERO, RISCV_T1, 0);
mono_arch_flush_icache (buf, code - buf);
if (code_len)
*code_len = code - buf;
return buf;
}
gpointer
mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr)
{
MonoMemoryManager *mem_manager = m_method_get_mem_manager (m);
guint8 *buf = mono_mem_manager_code_reserve (mem_manager, 64), *code = buf;
// Pass the argument in a0.
code = mono_riscv_emit_imm (code, RISCV_A0, sizeof (MonoObject));
code = mono_riscv_emit_imm (code, RISCV_T0, (gsize) addr);
riscv_jalr (code, RISCV_ZERO, RISCV_T0, 0);
mono_arch_flush_icache (buf, code - buf);
return buf;
}
gpointer
mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoIMTCheckItem **imt_entries, int count,
gpointer fail_tramp)
{
NOT_IMPLEMENTED;
return NULL;
}
gpointer
mono_arch_get_static_rgctx_trampoline (MonoMemoryManager *mem_manager, gpointer arg, gpointer addr)
{
guint8 *buf = mono_mem_manager_code_reserve (mem_manager, 64), *code = buf;
// Pass the argument in the RGCTX register.
code = mono_riscv_emit_imm (code, MONO_ARCH_RGCTX_REG, (gsize) arg);
code = mono_riscv_emit_imm (code, RISCV_T0, (gsize) addr);
riscv_jalr (code, RISCV_ZERO, RISCV_T0, 0);
mono_arch_flush_icache (buf, code - buf);
return buf;
}
gpointer
mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info,
gboolean aot)
{
if (aot)
NOT_IMPLEMENTED;
gboolean is_mrgctx = MONO_RGCTX_SLOT_IS_MRGCTX (slot);
int index = MONO_RGCTX_SLOT_INDEX (slot);
if (is_mrgctx)
index += MONO_SIZEOF_METHOD_RUNTIME_GENERIC_CONTEXT / sizeof (target_mgreg_t);
int depth;
for (depth = 0; ; depth++) {
int size = mono_class_rgctx_get_array_size (depth, is_mrgctx);
if (index < size - 1)
break;
index -= size - 1;
}
guint8 *buf = mono_global_codeman_reserve (128 * depth), *code = buf;
guint8 **null_jumps = g_malloc0 (sizeof (guint8 *) * (depth + 2));
if (!is_mrgctx) {
} else
riscv_addi (code, RISCV_T1, RISCV_A0, 0);
mono_arch_flush_icache (buf, code - buf);
if (info) {
char *name = mono_get_rgctx_fetch_trampoline_name (slot);
*info = mono_tramp_info_create (name, buf, code - buf, NULL, NULL);
g_free (name);
}
return buf;
}
gpointer
mono_arch_create_general_rgctx_lazy_fetch_trampoline (MonoTrampInfo **info, gboolean aot)
{
if (aot)
NOT_IMPLEMENTED;
guint8 *buf = mono_global_codeman_reserve (64), *code = buf;
/*
* The RGCTX register holds a pointer to a <slot, trampoline address> pair.
* Load the trampoline address and branch to it. a0 holds the actual
* (M)RGCTX or VTable.
*/
code = mono_riscv_emit_load (code, RISCV_T0, MONO_ARCH_RGCTX_REG, sizeof (target_mgreg_t));
riscv_jalr (code, RISCV_ZERO, RISCV_T0, 0);
mono_arch_flush_icache (buf, code - buf);
if (info)
*info = mono_tramp_info_create ("rgctx_fetch_trampoline_general", buf, code - buf, NULL, NULL);
return buf;
}
guint8 *
mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gboolean aot)
{
NOT_IMPLEMENTED;
return NULL;
}
gpointer
mono_arch_get_interp_to_native_trampoline (MonoTrampInfo **info)
{
NOT_IMPLEMENTED;
return NULL;
}
gpointer
mono_arch_get_native_to_interp_trampoline (MonoTrampInfo **info)
{
NOT_IMPLEMENTED;
return NULL;
}
#else
guchar *
mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInfo **info,
gboolean aot)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type,
MonoMemoryManager *mem_manager, guint32 *code_len)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoIMTCheckItem **imt_entries, int count,
gpointer fail_tramp)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_get_static_rgctx_trampoline (MonoMemoryManager *mem_manager, gpointer arg, gpointer addr)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info,
gboolean aot)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_create_general_rgctx_lazy_fetch_trampoline (MonoTrampInfo **info, gboolean aot)
{
g_assert_not_reached ();
return NULL;
}
guint8 *
mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gboolean aot)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_get_interp_to_native_trampoline (MonoTrampInfo **info)
{
g_assert_not_reached ();
return NULL;
}
gpointer
mono_arch_get_native_to_interp_trampoline (MonoTrampInfo **info)
{
g_assert_not_reached ();
return NULL;
}
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/riscv/Lcreate_addr_space.c | #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gcreate_addr_space.c"
#endif
| #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gcreate_addr_space.c"
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./docs/design/coreclr/botr/ilc-architecture.md | # ILC Compiler Architecture
Author: Michal Strehovsky ([@MichalStrehovsky](https://github.com/MichalStrehovsky)) - 2018
ILC (IL Compiler) is an ahead of time compiler that transforms programs in CIL (Common Intermediate Language) into a target language or instruction set to be executed on a stripped down CoreCLR runtime. The input to ILC is the common instruction format generated by popular managed language compilers such as C#, VB.NET, or F#. The output of ILC is native code for the target platform, along with data structures required to support executing the code on the target runtime. With a bit of stretch, one could say that ILC is an ahead of time native compiler for C#.
Traditionally, CIL has been compiled "just in time" (JIT). What this means is that the translation from CIL to the instruction set executable on the target runtime environment happened on an as-needed basis when the native code became necessary to continue execution of the program (e.g. on a first call to a CIL method). An ahead of time compiler tries to prepare the code and data structures in advance - before the program starts executing. The major advantages of having native code and data structures required for the code to execute available in advance are significant improvements to program startup time and working set.
In a fully ahead of time compiled environment, the compiler is responsible for generating code and data structures for everything that might be needed at runtime - the presence of the original CIL instructions or program metadata (names of methods and their signature, for example) is no longer necessary after compilation. One important aspect to keep in mind is that ahead of time compilation does not preclude just in time compilation: one could imagine mixed modes of execution where some parts of the application are compiled ahead of time, while others are compiled just in time, or interpreted. ILC needs to support such modes of operations, since both have their advantages and disadvantages. We have prototyped such modes of execution in the past.
## Goals
* Compile CIL and produce native code for the target platform
* Generate essential data structures that the runtime requires to execute managed native code (exception handling and GC information for methods, data structures describing types, their GC layout and vtables, interface dispatch maps, etc.)
* Generate optional data structures the base class libraries require to provide rich managed APIs to user code (data structures that support reflection, interop, textual stack trace information, type loading at runtime, etc.)
* Support optional inputs from a whole program analysis step to influence compilation
* Support generating executable files and static/dynamic libraries (with a flat C-style public API surface)
* Support multiple modes of compilation:
* Single-file output:
* All input assemblies merged into a single object file generated by ILC (merging managed assemblies happens in ILC). This mode allows maximum optimization.
* Generating multiple object files that are merged using a platform linker into a single executable (merging happens in the native linker after ILC runs). This mode allows incremental compilation at the cost of inhibiting optimizations in ILC.
* Multi-file output (one or more input assemblies generating one or more dynamic libraries that link against each other dynamically). This mode allows code/data sharing among several executables or dynamic libraries, but inhibits many optimizations.
* Multi-threaded compilation
* Generate native debug information for the target platform to allow debugging with native debuggers
* Generate outputs in the platform's native object file format (`.obj` and `.o` files)
* Have a defined behavior when input is incomplete (e.g. assemblies missing, or an assembly version mismatch)
## ILC composition
ILC is composed of roughly 3 parts: the compilation driver, the compiler, and the code generation backends.
### Compilation driver
The role of the compilation driver is to parse command line arguments, set up the compiler, and run the compilation. The process of setting up the compiler involves configuring a `CompilationBuilder`. The compilation builder exposes methods that let the driver configure and compose various pieces of the compiler as directed by the command line arguments. These components influence what gets compiled and how the compilation happens. Eventually the driver constructs a `Compilation` object that provides methods to run the compilation, inspect the results of the compilation, and write the outputs to a file on disk.
Related classes: `CompilationBuilder`, `ICompilation`
### Compiler
Compiler is the core component that the rest of the document is going to talk about. It's responsible for running the compilation process and generating data structures for the target runtime and target base class libraries.
The compiler tries to stay policy free as to what to compile, what data structures to generate, and how to do the compilation. The specific policies are supplied by the compilation driver as part of configuring the compilation.
### Code generation backends
ILC is designed to support multiple code generation backends that target the same runtime. What this means is that we have a model where there are common parts within the compiler (determining what needs to be compiled, generating data structures for the underlying runtime), and parts that are specific for a target environment. The common parts (the data structure layout) are not target specific - the target specific differences are limited to general questions, such as "does the target have representation for relative pointers?", but the basic shape of the data structures is the same, no matter the target platform.
ILC currently supports following codegen backends (with varying levels of completeness):
* **RyuJIT**: native code generator also used as the JIT compiler in CoreCLR. This backend supports x64, arm64, arm32 on Windows, Linux, macOS, and BSD.
* **LLVM**: the LLVM backend is currently used to generate WebAssembly code in connection with Emscripten. Lives in [NativeAOT-LLVM branch](https://github.com/dotnet/runtimelab/tree/feature/NativeAOT-LLVM).
This document describes the common parts of the compiler that are applicable to all codegen backends.
In the past, ILC supported following backends:
* **CppCodegen**: a portable code generator that translates CIL into C++ code. This supports rapid platform bringup (instead of having to build a code generator for a new CPU architecture, it relies on the C++ compiler the platform likely already has). Portability comes at certain costs. This codegen backend wasn't [brought over](https://github.com/dotnet/corert/tree/master/src/ILCompiler.CppCodeGen/src) from the now archived CoreRT repo.
Related project files: ILCompiler.LLVM.csproj, ILCompiler.RyuJit.csproj
## Dependency analysis
The core concept driving the compilation in ILC is dependency analysis. Dependency analysis is the process of determining the set of runtime artifacts (method code bodies and various data structures) that need to be generated into the output object file. Dependency analysis builds a graph where each vertex either
* represents an artifact that will be part of the output file (such as "compiled method body" or "data structure describing a type at runtime") - this is an "object node", or
* captures certain abstract characteristic of the compiled program (such as "the program contains a virtual call to the `Object.GetHashCode` method") - a general "dependency node". General dependency nodes do not physically manifest themselves as bytes in the output, but they usually have edges that (transitively) lead to object nodes that do form parts of the output.
The edges of the graph represent a "requires" relationship. The compilation process corresponds to building this graph and determining what nodes are part of the graph.
Related classes: `DependencyNodeCore<>`, `ObjectNode`
Related project files: ILCompiler.DependencyAnalysisFramework.csproj
### Dependency expansion process
The compilation starts with a set of nodes in the dependency graph called compilation roots. The roots are specified by the compilation driver and typically contain the `Main()` method, but the exact set of roots depends on the compilation mode: the set of roots will be different when we're e.g. building a library, or when we're doing a multi-file compilation, or when we're building a single file app.
The process begins by looking at the list of the root nodes and establishing their dependencies (dependent nodes). Once the dependencies are known, the compilation moves on to inspecting the dependencies of the dependencies, and so on, until all dependencies are known and marked within the dependency graph. When that happens, the compilation is done.
The expansion of the graph is required to stay within the limits of a compilation group. Compilation group is a component that controls how the dependency graph is expanded. The role of it is best illustrated by contrasting a multifile and single file compilation: in a single file compilation, all methods and types that are statically reachable from the roots become part of the dependency graph, irrespective of the input assembly that defines them. In a multi-file compilation, some of the compilation happens as part of a different unit of work: the methods and types that are not part of the current unit of work shouldn't have their dependencies examined and they should not be a part of the dependency graph.
The advantage of having the two abstractions (compilation roots, and a class that controls how the dependency graph is expanded) is that the core compilation process can be completely unaware of the specific compilation mode (e.g. whether we're building a library, or whether we're doing a multi-file compilation). The details are fully wrapped behind the two abstractions and give us a great expressive power for defining or experimenting with new compilation modes, while keeping all the logic in a single place. For example, we support a single method compilation mode where we compile only one method. This mode is useful for troubleshooting code generation. The compilation driver can define additional compilation modes (e.g. a mode that compiles a single type and all the associated methods) without having to change the compiler itself.
Related classes: `ICompilationRootProvider`, `CompilationModuleGroup`
### Dependency types
The dependency graph analysis can work with several kinds of dependencies between the nodes:
* **Static dependencies**: these are the most common. If node A is part of the dependency graph and it declares it requires node B, node B also becomes part of the dependency graph.
* **Conditional dependencies**: Node A declares that it depends on node B, but only if node C is part of the graph. If that's the case, node B will become part of the graph if both A and C are in the graph.
* **Dynamic dependencies**: These are quite expensive to have in the system, so we only use them rarely. They let the node inspect other nodes within the graph and inject nodes based on their presence. They are pretty much only used for analysis of generic virtual methods.
To show how the dependency graph looks like in real life let's look at an example of how an (optional) optimization within the compiler around virtual method usage tracking works:
```csharp
abstract class Foo
{
public abstract void VirtualMethod();
public virtual void UnusedVirtualMethod() { }
}
class Bar : Foo
{
public override void VirtualMethod() { }
public override void UnusedVirtualMethod() { }
}
class Baz : Foo
{
public override void VirtualMethod() { }
}
class Program
{
static int Main()
{
Foo f = new Bar();
f.VirtualMethod();
return f is Baz ? 0 : 100;
}
}
```
The dependency graph for the above program would look something like this:

The rectangle-shaped nodes represent method bodies, the oval-shaped nodes represent types, the dashed rectangles represent virtual method use, and the dotted oval-shaped node is an unconstructed type.
The dashed edges are conditional dependencies, with the condition marked on the label.
* `Program::Main` creates a new instance of `Bar`. For that, it will allocate an object on the GC heap and call a constructor to initialize it. Therefore, it needs the data structure that represents the `Bar` type and `Bar`'s default constructor. The method then calls `VirtualMethod`. Even though from this simple example we know what specific method body this will end up calling (we can devirtualize the call in our head), we can't know in general, so we say `Program::Main` also depends on "Virtual method use of Foo::VirtualMethod". The last line of the program performs a type check. To do the type check, the generated code needs to reference a data structure that represents type `Baz`. The interesting thing about a type check is that we don't need to generate a full data structure describing the type, only enough to be able to tell if the cast succeeds. So we say `Program::Main` also depends on "unconstructed type data structure" for `Baz`.
* The data structure that represents type `Bar` has two important kinds of dependencies. It depends on its base type (`Foo`) - a pointer to it is required to make casting work - and it also contains the vtable. The entries in the vtable are conditional - if a virtual method is never called, we don't need to place it in the vtable. As a result of the situation in the graph, the method body for `Bar::VirtualMethod` is going to be part of the graph, but `Bar::UnusedVirtualMethod` will not, because it's conditioned on a node that is not present in the graph.
* The data structure that represents `Baz` is a bit different from `Bar`. We call this an "unconstructed type" structure. Unconstructed type structures don't contain a vtable, and therefore `Baz` is missing a virtual method use dependency for `Baz::VirtualMethod` conditioned on the use of `Foo::VirtualMethod`.
Notice how using conditional dependencies helped us avoid compiling method bodies for `Foo::UnusedVirtualMethod` and `Bar::UnusedVirtualMethod` because the virtual method is never used. We also avoided generating `Baz::VirtualMethod`, because `Baz` was never allocated within the program. We generated the data structure that represents `Baz`, but because the data structure was only generated for the purposes of casting, it doesn't have a vtable that would pull `Baz::VirtualMethod` into the dependency graph.
Note that while "constructed" and "unconstructed" type nodes are modelled separately in the dependency graph, at the object writing time they get coalesced into one. If the graph has a type in both the unconstructed and constructed form, only the constructed form will be emitted into the executable and places referring to the unconstructed form will be redirected to the constructed form, to maintain type identity.
Related compiler switches: `--dgmllog` serializes the dependency graph into an XML file. The XML file captures all the nodes in the graph, but only captures the first edge leading to the node (knowing the first edge is enough for most purposes). `--fulllog` generates an even bigger XML file that captures all the edges.
Related tools: [Dependency analysis viewer](../how-to-debug-compiler-dependency-analysis.md) is a tool that listens to ETW events generated by all the ILC compiler processes on the machine and lets you interactively explore the graph.
## Object writing
The final phase of compilation is writing out the outputs. The output of the compilation depends on the target environment but will typically be some sort of object file. An object file typically consists of blobs of code or data with links (or relocations) between them, and symbols: named locations within a blob. The relocations point to symbols, either defined within the same object file, or in a different module.
While the object file format is highly target specific, the compiler represents dependency nodes that have object data associated with them the same way irrespective of the target - with the `ObjectNode` class. `ObjectNode` class allows its children to specify the section where to place their data (code, read only data, uninitialized data, etc.), and crucially, the data itself (represented by the `ObjectData` class returned from `GetObjectData` method).
On a high level, the role of the object writer is to go over all the marked `ObjectNode`s in the graph, retrieve their data, defined symbols, and relocations to other symbols, and store them in the object file.
NativeAOT compiler contains multiple object writers:
* Native object writer based on LLVM that is capable of producing Windows PE, Linux ELF, and macOS Mach-O file formats
* Native object writer based on LLVM for WebAssembly
* Ready to run object writer that generates mixed CIL/native executables in the ready to run format for CoreCLR
Related command line arguments: `--map` produces a map of all the object nodes that were emitted into the object file.
## Optimization pluggability
An advantage of a fully ahead of time compiled environment is that the compiler can make closed world assumptions about the code being compiled. For example: lacking the ability to load arbitrary CIL at runtime (either through `Assembly.Load`, or `Reflection.Emit`), if the compiler sees that there's only one type implementing an interface, it can replace all the interface calls in the program with direct calls, and apply additional optimizations enabled by it, such as inlining. If the target environment allowed dynamic code, such optimization would be invalid.
The compiler is structured to allow such optimizations, but remains policy-free as to when the optimization should be applied. This allow both fully AOT compiled and mixed (JIT/interpreted) code execution strategies. The policies are always captured in an abstract class or an interface, the implementation of which is selected by the compilation driver and passed to the compilation builder. This allows a great degree of flexibility and gives a lot of power to influence the compilation from the compilation driver, without hardcoding the conditions when the optimization is applicable into the compiler.
An example of such policy is the virtual method table (vtable) generation policy. The compiler can build vtables two ways: lazily, or by reading the type's metadata and generating a vtable slot for every new virtual method present in the type's method list. The depenceny analysis example graph a couple sections above was describing how conditional dependencies can be used to track what vtable slots and virtual method bodies we need to generate for a program to work. This is an example of an optimization that requires closed world assumptions. The policy is captured in a `VTableSliceProvider` class and allows the driver to select the vtable generation policy per type. This allows the compilation driver a great degree of control to fine tune when the optimization is allowed to happen (e.g. even in the presence of a JIT, we could still allow this optimization to happen on types that are not visible/accessible from the non-AOT compiled parts of the program or through reflection).
The policies that can be configured in the driver span a wide range of areas: generation of reflection metadata, devirtualization, generation of vtables, generation of stack trace metadata for `Exception.ToString`, generation of debug information, the source of IL for method bodies, etc.
## IL scanning
Another component of ILC is the IL scanner. IL scanning is an optional step that can be executed before the compilation. In many ways, the IL scanning acts as another compilation with a null/dummy code generation backend. The IL scanner scans the IL of all the method bodies that become part of the dependency graph starting from the roots and expands their dependencies. The IL scanner ends up building the same dependency graph a code generation backend would, but the nodes in the graph that represent method bodies don't have any machine code instructions associated with them. This process is relatively fast since there's no code generation involved, but the resulting graph contains a lot of valuable insights into the compiled program. The dependency graph built by the IL scanner is a strict superset of the graph built by a real compilation since the IL scanner doesn't model optimizations such as inlining and devirtualization.
The results of the IL scanner are input into the subsequent compilation process. For example, the IL scanner can use the lazy vtable generation policy to build vtables with just the slots needed, and assign slot numbers to each slot in the vtable at the end of scanning. The vtable layouts computed lazily during scanning can then be used by the real compilation process to inline vtable lookups at the callsites. Inlining the vtable lookup at the callsite would not be possible with a lazy vtable generation policy because the exact slot assignments of lazy vtables aren't stable until the compilation is done.
The IL scanning process is optional and the compilation driver can skip it if compilation throughput is more important than runtime code quality.
Related classes: `ILScanner`
## Coupling with the base class libraries
The compiler has a certain level of coupling with the underlying base class library (the `System.Private.*` libraries within the repo). The coupling is twofold:
* Binary format of the generated data structures
* Expectations about the existence of certain methods within the core library
Examples of the binary formats generated by the compiler and used by the base class libraries would be the format of the data structure that represents a type at runtime (`MethodTable`), or the blob of bytes that describes non-essential information about the type (such as the type name, or a list of methods). These data structures form a contract and allow the managed code in the base class library to provide rich services to user code through library APIs at runtime (such as the reflection APIs). Generation of some of these data structures is optional, but for some it's mandatory because they're required to execute any managed code.
The compiler also needs to call into some well-known entrypoints within the base class library to support the generated code. The base class library needs to define these methods. Examples of such entrypoints would be various helpers to throw `OverflowException` during mathematical operations, `IndexOutOfRangeException` during array access, or various helpers to aid in generating p/invoke marshalling code (e.g. converting a UTF-16 string to ANSI and back before/after invoking the native method).
One interesting thing to point out is that the coupling of the compiler with the base class libraries is relatively loose (there are only few mandatory parts). This allows different base class libraries to be used with ILC. Such base class libraries could look quite different from what regular .NET developers are used to (e.g. a `System.Object` that doesn't have a `ToString` method) but could allow using type safe code in environments where regular .NET would be considered "too heavy". Various experiments with such lightweight code have been done in the past, and some of them even shipped as part of the Windows operating system.
Example of such alternative base class library is [Test.CoreLib](../../../../src/coreclr/nativeaot/Test.CoreLib/). The `Test.CoreLib` library provides a very minimal API surface. This, coupled with the fact that it requires almost no initialization, makes it a great assistant in bringing NativeAOT to new platforms.
## Compiler-generated method bodies
Besides compiling the code provided by the user in the form of input assemblies, the compiler also needs to compile various helpers generated within the compiler. The helpers are used to lower some of the higher-level .NET constructs into concepts that the underlying code generation backend understands. These helpers are emitted as IL code on the fly, without being physically backed by IL in an assembly on disk. Having the higher level concepts expressed as regular IL helps avoid having to implement the higher-level concept in each code generation backend (we only must do it once because IL is the thing all backends understand).
The helpers serve various purposes such as:
* Helpers to support invoking delegates
* Helpers that support marshalling parameters and return values for P/Invoke
* Helpers that support `ValueType.GetHashCode` and `ValueType.Equals`
* Helpers that support reflection: e.g. `Assembly.GetExecutingAssembly`
Related classes: `ILEmitter`, `ILStubMethod`
Related ILC command line switches: `--ildump` to dump all generated IL into a file and map debug information to it (allows source stepping through the generated IL at runtime).
| # ILC Compiler Architecture
Author: Michal Strehovsky ([@MichalStrehovsky](https://github.com/MichalStrehovsky)) - 2018
ILC (IL Compiler) is an ahead of time compiler that transforms programs in CIL (Common Intermediate Language) into a target language or instruction set to be executed on a stripped down CoreCLR runtime. The input to ILC is the common instruction format generated by popular managed language compilers such as C#, VB.NET, or F#. The output of ILC is native code for the target platform, along with data structures required to support executing the code on the target runtime. With a bit of stretch, one could say that ILC is an ahead of time native compiler for C#.
Traditionally, CIL has been compiled "just in time" (JIT). What this means is that the translation from CIL to the instruction set executable on the target runtime environment happened on an as-needed basis when the native code became necessary to continue execution of the program (e.g. on a first call to a CIL method). An ahead of time compiler tries to prepare the code and data structures in advance - before the program starts executing. The major advantages of having native code and data structures required for the code to execute available in advance are significant improvements to program startup time and working set.
In a fully ahead of time compiled environment, the compiler is responsible for generating code and data structures for everything that might be needed at runtime - the presence of the original CIL instructions or program metadata (names of methods and their signature, for example) is no longer necessary after compilation. One important aspect to keep in mind is that ahead of time compilation does not preclude just in time compilation: one could imagine mixed modes of execution where some parts of the application are compiled ahead of time, while others are compiled just in time, or interpreted. ILC needs to support such modes of operations, since both have their advantages and disadvantages. We have prototyped such modes of execution in the past.
## Goals
* Compile CIL and produce native code for the target platform
* Generate essential data structures that the runtime requires to execute managed native code (exception handling and GC information for methods, data structures describing types, their GC layout and vtables, interface dispatch maps, etc.)
* Generate optional data structures the base class libraries require to provide rich managed APIs to user code (data structures that support reflection, interop, textual stack trace information, type loading at runtime, etc.)
* Support optional inputs from a whole program analysis step to influence compilation
* Support generating executable files and static/dynamic libraries (with a flat C-style public API surface)
* Support multiple modes of compilation:
* Single-file output:
* All input assemblies merged into a single object file generated by ILC (merging managed assemblies happens in ILC). This mode allows maximum optimization.
* Generating multiple object files that are merged using a platform linker into a single executable (merging happens in the native linker after ILC runs). This mode allows incremental compilation at the cost of inhibiting optimizations in ILC.
* Multi-file output (one or more input assemblies generating one or more dynamic libraries that link against each other dynamically). This mode allows code/data sharing among several executables or dynamic libraries, but inhibits many optimizations.
* Multi-threaded compilation
* Generate native debug information for the target platform to allow debugging with native debuggers
* Generate outputs in the platform's native object file format (`.obj` and `.o` files)
* Have a defined behavior when input is incomplete (e.g. assemblies missing, or an assembly version mismatch)
## ILC composition
ILC is composed of roughly 3 parts: the compilation driver, the compiler, and the code generation backends.
### Compilation driver
The role of the compilation driver is to parse command line arguments, set up the compiler, and run the compilation. The process of setting up the compiler involves configuring a `CompilationBuilder`. The compilation builder exposes methods that let the driver configure and compose various pieces of the compiler as directed by the command line arguments. These components influence what gets compiled and how the compilation happens. Eventually the driver constructs a `Compilation` object that provides methods to run the compilation, inspect the results of the compilation, and write the outputs to a file on disk.
Related classes: `CompilationBuilder`, `ICompilation`
### Compiler
Compiler is the core component that the rest of the document is going to talk about. It's responsible for running the compilation process and generating data structures for the target runtime and target base class libraries.
The compiler tries to stay policy free as to what to compile, what data structures to generate, and how to do the compilation. The specific policies are supplied by the compilation driver as part of configuring the compilation.
### Code generation backends
ILC is designed to support multiple code generation backends that target the same runtime. What this means is that we have a model where there are common parts within the compiler (determining what needs to be compiled, generating data structures for the underlying runtime), and parts that are specific for a target environment. The common parts (the data structure layout) are not target specific - the target specific differences are limited to general questions, such as "does the target have representation for relative pointers?", but the basic shape of the data structures is the same, no matter the target platform.
ILC currently supports following codegen backends (with varying levels of completeness):
* **RyuJIT**: native code generator also used as the JIT compiler in CoreCLR. This backend supports x64, arm64, arm32 on Windows, Linux, macOS, and BSD.
* **LLVM**: the LLVM backend is currently used to generate WebAssembly code in connection with Emscripten. Lives in [NativeAOT-LLVM branch](https://github.com/dotnet/runtimelab/tree/feature/NativeAOT-LLVM).
This document describes the common parts of the compiler that are applicable to all codegen backends.
In the past, ILC supported following backends:
* **CppCodegen**: a portable code generator that translates CIL into C++ code. This supports rapid platform bringup (instead of having to build a code generator for a new CPU architecture, it relies on the C++ compiler the platform likely already has). Portability comes at certain costs. This codegen backend wasn't [brought over](https://github.com/dotnet/corert/tree/master/src/ILCompiler.CppCodeGen/src) from the now archived CoreRT repo.
Related project files: ILCompiler.LLVM.csproj, ILCompiler.RyuJit.csproj
## Dependency analysis
The core concept driving the compilation in ILC is dependency analysis. Dependency analysis is the process of determining the set of runtime artifacts (method code bodies and various data structures) that need to be generated into the output object file. Dependency analysis builds a graph where each vertex either
* represents an artifact that will be part of the output file (such as "compiled method body" or "data structure describing a type at runtime") - this is an "object node", or
* captures certain abstract characteristic of the compiled program (such as "the program contains a virtual call to the `Object.GetHashCode` method") - a general "dependency node". General dependency nodes do not physically manifest themselves as bytes in the output, but they usually have edges that (transitively) lead to object nodes that do form parts of the output.
The edges of the graph represent a "requires" relationship. The compilation process corresponds to building this graph and determining what nodes are part of the graph.
Related classes: `DependencyNodeCore<>`, `ObjectNode`
Related project files: ILCompiler.DependencyAnalysisFramework.csproj
### Dependency expansion process
The compilation starts with a set of nodes in the dependency graph called compilation roots. The roots are specified by the compilation driver and typically contain the `Main()` method, but the exact set of roots depends on the compilation mode: the set of roots will be different when we're e.g. building a library, or when we're doing a multi-file compilation, or when we're building a single file app.
The process begins by looking at the list of the root nodes and establishing their dependencies (dependent nodes). Once the dependencies are known, the compilation moves on to inspecting the dependencies of the dependencies, and so on, until all dependencies are known and marked within the dependency graph. When that happens, the compilation is done.
The expansion of the graph is required to stay within the limits of a compilation group. Compilation group is a component that controls how the dependency graph is expanded. The role of it is best illustrated by contrasting a multifile and single file compilation: in a single file compilation, all methods and types that are statically reachable from the roots become part of the dependency graph, irrespective of the input assembly that defines them. In a multi-file compilation, some of the compilation happens as part of a different unit of work: the methods and types that are not part of the current unit of work shouldn't have their dependencies examined and they should not be a part of the dependency graph.
The advantage of having the two abstractions (compilation roots, and a class that controls how the dependency graph is expanded) is that the core compilation process can be completely unaware of the specific compilation mode (e.g. whether we're building a library, or whether we're doing a multi-file compilation). The details are fully wrapped behind the two abstractions and give us a great expressive power for defining or experimenting with new compilation modes, while keeping all the logic in a single place. For example, we support a single method compilation mode where we compile only one method. This mode is useful for troubleshooting code generation. The compilation driver can define additional compilation modes (e.g. a mode that compiles a single type and all the associated methods) without having to change the compiler itself.
Related classes: `ICompilationRootProvider`, `CompilationModuleGroup`
### Dependency types
The dependency graph analysis can work with several kinds of dependencies between the nodes:
* **Static dependencies**: these are the most common. If node A is part of the dependency graph and it declares it requires node B, node B also becomes part of the dependency graph.
* **Conditional dependencies**: Node A declares that it depends on node B, but only if node C is part of the graph. If that's the case, node B will become part of the graph if both A and C are in the graph.
* **Dynamic dependencies**: These are quite expensive to have in the system, so we only use them rarely. They let the node inspect other nodes within the graph and inject nodes based on their presence. They are pretty much only used for analysis of generic virtual methods.
To show how the dependency graph looks like in real life let's look at an example of how an (optional) optimization within the compiler around virtual method usage tracking works:
```csharp
abstract class Foo
{
public abstract void VirtualMethod();
public virtual void UnusedVirtualMethod() { }
}
class Bar : Foo
{
public override void VirtualMethod() { }
public override void UnusedVirtualMethod() { }
}
class Baz : Foo
{
public override void VirtualMethod() { }
}
class Program
{
static int Main()
{
Foo f = new Bar();
f.VirtualMethod();
return f is Baz ? 0 : 100;
}
}
```
The dependency graph for the above program would look something like this:

The rectangle-shaped nodes represent method bodies, the oval-shaped nodes represent types, the dashed rectangles represent virtual method use, and the dotted oval-shaped node is an unconstructed type.
The dashed edges are conditional dependencies, with the condition marked on the label.
* `Program::Main` creates a new instance of `Bar`. For that, it will allocate an object on the GC heap and call a constructor to initialize it. Therefore, it needs the data structure that represents the `Bar` type and `Bar`'s default constructor. The method then calls `VirtualMethod`. Even though from this simple example we know what specific method body this will end up calling (we can devirtualize the call in our head), we can't know in general, so we say `Program::Main` also depends on "Virtual method use of Foo::VirtualMethod". The last line of the program performs a type check. To do the type check, the generated code needs to reference a data structure that represents type `Baz`. The interesting thing about a type check is that we don't need to generate a full data structure describing the type, only enough to be able to tell if the cast succeeds. So we say `Program::Main` also depends on "unconstructed type data structure" for `Baz`.
* The data structure that represents type `Bar` has two important kinds of dependencies. It depends on its base type (`Foo`) - a pointer to it is required to make casting work - and it also contains the vtable. The entries in the vtable are conditional - if a virtual method is never called, we don't need to place it in the vtable. As a result of the situation in the graph, the method body for `Bar::VirtualMethod` is going to be part of the graph, but `Bar::UnusedVirtualMethod` will not, because it's conditioned on a node that is not present in the graph.
* The data structure that represents `Baz` is a bit different from `Bar`. We call this an "unconstructed type" structure. Unconstructed type structures don't contain a vtable, and therefore `Baz` is missing a virtual method use dependency for `Baz::VirtualMethod` conditioned on the use of `Foo::VirtualMethod`.
Notice how using conditional dependencies helped us avoid compiling method bodies for `Foo::UnusedVirtualMethod` and `Bar::UnusedVirtualMethod` because the virtual method is never used. We also avoided generating `Baz::VirtualMethod`, because `Baz` was never allocated within the program. We generated the data structure that represents `Baz`, but because the data structure was only generated for the purposes of casting, it doesn't have a vtable that would pull `Baz::VirtualMethod` into the dependency graph.
Note that while "constructed" and "unconstructed" type nodes are modelled separately in the dependency graph, at the object writing time they get coalesced into one. If the graph has a type in both the unconstructed and constructed form, only the constructed form will be emitted into the executable and places referring to the unconstructed form will be redirected to the constructed form, to maintain type identity.
Related compiler switches: `--dgmllog` serializes the dependency graph into an XML file. The XML file captures all the nodes in the graph, but only captures the first edge leading to the node (knowing the first edge is enough for most purposes). `--fulllog` generates an even bigger XML file that captures all the edges.
Related tools: [Dependency analysis viewer](../how-to-debug-compiler-dependency-analysis.md) is a tool that listens to ETW events generated by all the ILC compiler processes on the machine and lets you interactively explore the graph.
## Object writing
The final phase of compilation is writing out the outputs. The output of the compilation depends on the target environment but will typically be some sort of object file. An object file typically consists of blobs of code or data with links (or relocations) between them, and symbols: named locations within a blob. The relocations point to symbols, either defined within the same object file, or in a different module.
While the object file format is highly target specific, the compiler represents dependency nodes that have object data associated with them the same way irrespective of the target - with the `ObjectNode` class. `ObjectNode` class allows its children to specify the section where to place their data (code, read only data, uninitialized data, etc.), and crucially, the data itself (represented by the `ObjectData` class returned from `GetObjectData` method).
On a high level, the role of the object writer is to go over all the marked `ObjectNode`s in the graph, retrieve their data, defined symbols, and relocations to other symbols, and store them in the object file.
NativeAOT compiler contains multiple object writers:
* Native object writer based on LLVM that is capable of producing Windows PE, Linux ELF, and macOS Mach-O file formats
* Native object writer based on LLVM for WebAssembly
* Ready to run object writer that generates mixed CIL/native executables in the ready to run format for CoreCLR
Related command line arguments: `--map` produces a map of all the object nodes that were emitted into the object file.
## Optimization pluggability
An advantage of a fully ahead of time compiled environment is that the compiler can make closed world assumptions about the code being compiled. For example: lacking the ability to load arbitrary CIL at runtime (either through `Assembly.Load`, or `Reflection.Emit`), if the compiler sees that there's only one type implementing an interface, it can replace all the interface calls in the program with direct calls, and apply additional optimizations enabled by it, such as inlining. If the target environment allowed dynamic code, such optimization would be invalid.
The compiler is structured to allow such optimizations, but remains policy-free as to when the optimization should be applied. This allow both fully AOT compiled and mixed (JIT/interpreted) code execution strategies. The policies are always captured in an abstract class or an interface, the implementation of which is selected by the compilation driver and passed to the compilation builder. This allows a great degree of flexibility and gives a lot of power to influence the compilation from the compilation driver, without hardcoding the conditions when the optimization is applicable into the compiler.
An example of such policy is the virtual method table (vtable) generation policy. The compiler can build vtables two ways: lazily, or by reading the type's metadata and generating a vtable slot for every new virtual method present in the type's method list. The depenceny analysis example graph a couple sections above was describing how conditional dependencies can be used to track what vtable slots and virtual method bodies we need to generate for a program to work. This is an example of an optimization that requires closed world assumptions. The policy is captured in a `VTableSliceProvider` class and allows the driver to select the vtable generation policy per type. This allows the compilation driver a great degree of control to fine tune when the optimization is allowed to happen (e.g. even in the presence of a JIT, we could still allow this optimization to happen on types that are not visible/accessible from the non-AOT compiled parts of the program or through reflection).
The policies that can be configured in the driver span a wide range of areas: generation of reflection metadata, devirtualization, generation of vtables, generation of stack trace metadata for `Exception.ToString`, generation of debug information, the source of IL for method bodies, etc.
## IL scanning
Another component of ILC is the IL scanner. IL scanning is an optional step that can be executed before the compilation. In many ways, the IL scanning acts as another compilation with a null/dummy code generation backend. The IL scanner scans the IL of all the method bodies that become part of the dependency graph starting from the roots and expands their dependencies. The IL scanner ends up building the same dependency graph a code generation backend would, but the nodes in the graph that represent method bodies don't have any machine code instructions associated with them. This process is relatively fast since there's no code generation involved, but the resulting graph contains a lot of valuable insights into the compiled program. The dependency graph built by the IL scanner is a strict superset of the graph built by a real compilation since the IL scanner doesn't model optimizations such as inlining and devirtualization.
The results of the IL scanner are input into the subsequent compilation process. For example, the IL scanner can use the lazy vtable generation policy to build vtables with just the slots needed, and assign slot numbers to each slot in the vtable at the end of scanning. The vtable layouts computed lazily during scanning can then be used by the real compilation process to inline vtable lookups at the callsites. Inlining the vtable lookup at the callsite would not be possible with a lazy vtable generation policy because the exact slot assignments of lazy vtables aren't stable until the compilation is done.
The IL scanning process is optional and the compilation driver can skip it if compilation throughput is more important than runtime code quality.
Related classes: `ILScanner`
## Coupling with the base class libraries
The compiler has a certain level of coupling with the underlying base class library (the `System.Private.*` libraries within the repo). The coupling is twofold:
* Binary format of the generated data structures
* Expectations about the existence of certain methods within the core library
Examples of the binary formats generated by the compiler and used by the base class libraries would be the format of the data structure that represents a type at runtime (`MethodTable`), or the blob of bytes that describes non-essential information about the type (such as the type name, or a list of methods). These data structures form a contract and allow the managed code in the base class library to provide rich services to user code through library APIs at runtime (such as the reflection APIs). Generation of some of these data structures is optional, but for some it's mandatory because they're required to execute any managed code.
The compiler also needs to call into some well-known entrypoints within the base class library to support the generated code. The base class library needs to define these methods. Examples of such entrypoints would be various helpers to throw `OverflowException` during mathematical operations, `IndexOutOfRangeException` during array access, or various helpers to aid in generating p/invoke marshalling code (e.g. converting a UTF-16 string to ANSI and back before/after invoking the native method).
One interesting thing to point out is that the coupling of the compiler with the base class libraries is relatively loose (there are only few mandatory parts). This allows different base class libraries to be used with ILC. Such base class libraries could look quite different from what regular .NET developers are used to (e.g. a `System.Object` that doesn't have a `ToString` method) but could allow using type safe code in environments where regular .NET would be considered "too heavy". Various experiments with such lightweight code have been done in the past, and some of them even shipped as part of the Windows operating system.
Example of such alternative base class library is [Test.CoreLib](../../../../src/coreclr/nativeaot/Test.CoreLib/). The `Test.CoreLib` library provides a very minimal API surface. This, coupled with the fact that it requires almost no initialization, makes it a great assistant in bringing NativeAOT to new platforms.
## Compiler-generated method bodies
Besides compiling the code provided by the user in the form of input assemblies, the compiler also needs to compile various helpers generated within the compiler. The helpers are used to lower some of the higher-level .NET constructs into concepts that the underlying code generation backend understands. These helpers are emitted as IL code on the fly, without being physically backed by IL in an assembly on disk. Having the higher level concepts expressed as regular IL helps avoid having to implement the higher-level concept in each code generation backend (we only must do it once because IL is the thing all backends understand).
The helpers serve various purposes such as:
* Helpers to support invoking delegates
* Helpers that support marshalling parameters and return values for P/Invoke
* Helpers that support `ValueType.GetHashCode` and `ValueType.Equals`
* Helpers that support reflection: e.g. `Assembly.GetExecutingAssembly`
Related classes: `ILEmitter`, `ILStubMethod`
Related ILC command line switches: `--ildump` to dump all generated IL into a file and map debug information to it (allows source stepping through the generated IL at runtime).
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./docs/design/coreclr/jit/arm64-jit-frame-layout.md | # ARM64 JIT frame layout
NOTE: This document was written before the code was written, and hasn't been
verified to match existing code. It refers to some documents that might not be
open source.
This document describes the frame layout constraints and options for the ARM64
JIT compiler.
These frame layouts were taken from the "Windows ARM64 Exception Data"
specification, and expanded for use by the JIT.
We will generate chained frames in most case (where we save the frame pointer on
the stack, and point the frame pointer (x29) at the saved frame pointer),
including all non-leaf frames, to support ETW stack walks. This is recommended
by the "Windows ARM64 ABI" document. See `ETW_EBP_FRAMED` in the JIT code. (We
currently don’t set `ETW_EBP_FRAMED` for ARM64.)
For frames with alloca (dynamic stack allocation), we must use a frame pointer
that is fixed after the prolog (and before any alloca), so the stack pointer can
vary. The frame pointer will be used to access locals, parameters, etc., in the
fixed part of the frame.
For non-alloca frames, the stack pointer is set and not changed at the end of
the prolog. In this case, the stack pointer can be used for all frame member
access. If a frame pointer is also created, the frame pointer can optionally be
used to access frame members if it gives an encoding advantage.
We require a frame pointer for several cases: (1) functions with exception
handling establish a frame pointer so handler funclets can use the frame pointer
to access parent function locals, (2) for functions with P/Invoke, (3) for
certain GC encoding limitations or requirements, (4) for varargs functions, (5)
for Edit & Continue functions, (6) for debuggable code, and (7) for MinOpts.
This list might not be exhaustive.
On ARM64, the stack pointer must remain 16 byte aligned at all times.
The immediate offset addressing modes for various instructions have different
offset ranges. We want the frames to be designed to efficiently use the
available instruction encodings. Some important offset ranges for immediate
offset addressing include:
* ldrb /ldrsb / strb, unsigned offset: 0 to 4095
* ldrh /ldrsh / strh, unsigned offset: 0 to 8190, multiples of 2 (aligned halfwords)
* ldr / str (32-bit variant) / ldrsw, unsigned offset: 0 to 16380, multiple of 4 (aligned words)
* ldr / str (64-bit variant), unsigned offset: 0 to 32760, multiple of 8 (aligned doublewords)
* ldp / stp (32-bit variant), pre-indexed, post-indexed, and signed offset: -256 to 252, multiple of 4
* ldp / stp (64-bit variant), pre-indexed, post-indexed, and signed offset: -512 to 504, multiple of 8
* ldurb / ldursb / ldurh / ldursb / ldur (32-bit and 64-bit variants) / ldursw / sturb / sturh / stur (32-bit and 64-bit variants): -256 to 255
* ldr / ldrh / ldrb / ldrsw / ldrsh / ldrsb / str / strh / strb pre-indexed/post-indexed: -256 to 255 (unscaled)
* add / sub (immediate): 0 to 4095, or with 12 bit left shift: 4096 to 16777215 (multiples of 4096).
* Thus, to construct a frame larger than 4095 using `sub`, we could use one "small" sub, or one "large" / shifted sub followed by a single "small" / unshifted sub. The reverse applies for tearing down the frame.
* Note that we need to probe the stack for stack overflow when allocating large frames.
Most of the offset modes (that aren't pre-indexed or post-indexed) are unsigned.
Thus, we want the frame pointer, if it exists, to be at a lower address than the
objects on the frame (with the small caveat that we could use the limited
negative offset addressing capability of the `ldu*` / `stu*` unscaled modes).
The stack pointer will point to the first slot of the outgoing stack argument
area, if any, even for alloca functions (thus, the alloca operation needs to
"move" the outgoing stack argument space down), so filling the outgoing stack
argument space will always use SP.
For extremely large frames (e.g., frames larger than 32760, certainly, but
probably for any frame larger than 4095), we need to globally reserve and use an
additional register to construct an offset, and then use a register offset mode
(see `compRsvdRegCheck()`). It is unlikely we could accurately allocate a
register for this purpose at all points where it will be actually necessary.
In general, we want to put objects close to the stack or frame pointer, to take
advantage of the limited addressing offsets described above, especially if we
use the ldp/stp instructions. If we do end up using ldp/stp, we will want to
consider pointing the frame pointer somewhere in the middle of the locals (or
other objects) in the frame, to maximize the limited, but signed, offset range.
For example, saved callee-saved registers should be far from the frame/stack
pointer, since they are going to be saved once and loaded once, whereas
locals/temps are expected to be used more frequently.
For variadic (varargs) functions, and possibly for functions with incoming
struct register arguments, it is easier to put the arguments on the stack in the
prolog such that the entire argument list is contiguous in memory, including
both the register and stack arguments. On ARM32, we used the "prespill" concept,
where we used a register mask "push" instruction for the "prespilled" registers.
Note that on ARM32, structs could be split between incoming argument registers
and the stack. On ARM64, this is not true. A struct <=16 bytes is passed in one
or two consecutive registers, or entirely on the stack. Structs >16 bytes are
passed by reference (the caller allocates space for the struct in its frame,
copies the output struct value there, and passes a pointer to that space). On
ARM64, instead of prespill we can instead just allocate the appropriate stack
space, and use `str` or `stp` to save the incoming register arguments to the
reserved space.
To support GC "return address hijacking", we need to, for all functions, save
the return address to the stack in the prolog, and load it from the stack in the
epilog before returning. We must do this so the VM can change the return address
stored on the stack to cause the function to return to a special location to
support suspension.
Below are some sample frame layouts. In these examples, `#localsz` is the byte
size of the locals/temps area (everything except callee-saved registers and the
outgoing argument space, but including space to save FP and SP), `#outsz` is the
outgoing stack parameter size, and `#framesz` is the size of the entire stack
(meaning `#localsz` + `#outsz` + callee-saved register size, but not including
any alloca size).
Note that in these frame layouts, the saved `<fp,lr>` pair is not contiguous
with the rest of the callee-saved registers. This is because for chained
functions, the frame pointer must point at the saved frame pointer. Also, if we
are to use the positive immediate offset addressing modes, we need the frame
pointer to be lowest on the stack. In addition, we want the callee-saved
registers to be "far away", especially for large frames where an immediate
offset addressing mode won’t be able to reach them, as we want locals to be
closer than the callee-saved registers.
To maintain 16 byte stack alignment, we may need to add alignment padding bytes.
Ideally we design the frame such that we only need at most 15 alignment bytes.
Since our frame objects are minimally 4 bytes (or maybe even 8 bytes?) in size,
we should only need maximally 12 (or 8?) alignment bytes. Note that every time
the stack pointer is changed, it needs to be by 16 bytes, so every time we
adjust the stack might require alignment. (Technically, it might be the case
that you can change the stack pointer by values not a multiple of 16, but you
certainly can’t load or store from non-16-byte-aligned SP values. Also, the
ARM64 unwind code `alloc_s` is 8 byte scaled, so it can only handle multiple of
8 byte changes to SP.) Note that ldp/stp can be given an 8-byte aligned address
when reading/writing 8-byte register pairs, even though the total data transfer
for the instruction is 16 bytes.
## 1. chained, `#framesz <= 512`, `#outsz = 0`
```
stp fp,lr,[sp,-#framesz]! // pre-indexed, save <fp,lr> at bottom of frame
mov fp,sp // fp points to bottom of stack
stp r19,r20,[sp,#framesz - 96] // save INT pair
stp d8,d9,[sp,#framesz - 80] // save FP pair
stp r0,r1,[sp,#framesz - 64] // home params (optional)
stp r2,r3,[sp,#framesz - 48]
stp r4,r5,[sp,#framesz - 32]
stp r6,r7,[sp,#framesz - 16]
```
8 instructions (for this set of registers saves, used in most examples given
here). There is a single SP adjustment, that is folded into the `<fp,lr>`
register pair store. Works with alloca. Frame access is via SP or FP.
We will use this for most frames with no outgoing stack arguments (which is
likely to be the 99% case, since we have 8 integer register arguments and 8
floating-point register arguments).
Here is a similar example, but with an odd number of saved registers:
```
stp fp,lr,[sp,-#framesz]! // pre-indexed, save <fp,lr> at bottom of frame
mov fp,sp // fp points to bottom of stack
stp r19,r20,[sp,#framesz - 24] // save INT pair
str r21,[sp,#framesz - 8] // save INT reg
```
Note that the saved registers are "packed" against the "caller SP" value (that
is, they are at the "top" of the downward-growing stack). Any alignment is lower
than the callee-saved registers.
For leaf functions, we don't need to save the callee-save registers, so we will
have, for chained function (such as functions with alloca):
```
stp fp,lr,[sp,-#framesz]! // pre-indexed, save <fp,lr> at bottom of frame
mov fp,sp // fp points to bottom of stack
```
## 2. chained, `#framesz - 16 <= 512`, `#outsz != 0`
```
sub sp,sp,#framesz
stp fp,lr,[sp,#outsz] // pre-indexed, save <fp,lr>
add fp,sp,#outsz // fp points to bottom of local area
stp r19,r20,[sp,#framez - 96] // save INT pair
stp d8,d9,[sp,#framesz - 80] // save FP pair
stp r0,r1,[sp,#framesz - 64] // home params (optional)
stp r2,r3,[sp,#framesz - 48]
stp r4,r5,[sp,#framesz - 32]
stp r6,r7,[sp,#framesz - 16]
```
9 instructions. There is a single SP adjustment. It isn’t folded into the
`<fp,lr>` register pair store because the SP adjustment points the new SP at the
outgoing argument space, and the `<fp,lr>` pair needs to be stored above that.
Works with alloca. Frame access is via SP or FP.
We will use this for most non-leaf frames with outgoing argument stack space.
As for #1, if there is an odd number of callee-save registers, they can easily
be put adjacent to the caller SP (at the "top" of the stack), so any alignment
bytes will be in the locals area.
## 3. chained, `(#framesz - #outsz) <= 512`, `#outsz != 0`.
Different from #2, as `#framesz` is too big. Might be useful for `#framesz >
512` but `(#framesz - #outsz) <= 512`.
```
stp fp,lr,[sp,-(#localsz + 96)]! // pre-indexed, save <fp,lr> above outgoing argument space
mov fp,sp // fp points to bottom of stack
stp r19,r20,[sp,#localsz + 80] // save INT pair
stp d8,d9,[sp,#localsz + 64] // save FP pair
stp r0,r1,[sp,#localsz + 48] // home params (optional)
stp r2,r3,[sp,#localsz + 32]
stp r4,r5,[sp,#localsz + 16]
stp r6,r7,[sp,#localsz]
sub sp,sp,#outsz
```
9 instructions. There are 2 SP adjustments. Works with alloca. Frame access is
via SP or FP.
We will not use this.
## 4. chained, `#localsz <= 512`
```
stp r19,r20,[sp,#-96]! // pre-indexed, save incoming 1st FP/INT pair
stp d8,d9,[sp,#16] // save incoming floating-point regs (optional)
stp r0,r1,[sp,#32] // home params (optional)
stp r2,r3,[sp,#48]
stp r4,r5,[sp,#64]
stp r6,r7,[sp,#80]
stp fp,lr,[sp,-#localsz]! // save <fp,lr> at bottom of local area
mov fp,sp // fp points to bottom of local area
sub sp,sp,#outsz // if #outsz != 0
```
9 instructions. There are 3 SP adjustments: to set SP for saving callee-saved
registers, for allocating the local space (and storing `<fp,lr>`), and for
allocating the outgoing argument space. Works with alloca. Frame access is via
SP or FP.
We likely will not use this. Instead, we will use #2 or #5/#6.
## 5. chained, `#localsz > 512`, `#outsz <= 512`.
Another case with an unlikely mix of sizes.
```
stp r19,r20,[sp,#-96]! // pre-indexed, save incoming 1st FP/INT pair
stp d8,d9,[sp,#16] // save in FP regs (optional)
stp r0,r1,[sp,#32] // home params (optional)
stp r2,r3,[sp,#48]
stp r4,r5,[sp,#64]
stp r6,r7,[sp,#80]
sub sp,sp,#localsz+#outsz // allocate remaining frame
stp fp,lr,[sp,#outsz] // save <fp,lr> at bottom of local area
add fp,sp,#outsz // fp points to the bottom of local area
```
9 instructions. There are 2 SP adjustments. Works with alloca. Frame access is
via SP or FP.
We will use this.
To handle an odd number of callee-saved registers with this layout, we would
need to insert alignment bytes higher in the stack. E.g.:
```
str r19,[sp,#-16]! // pre-indexed, save incoming 1st INT reg
sub sp,sp,#localsz + #outsz // allocate remaining frame
stp fp,lr,[sp,#outsz] // save <fp,lr> at bottom of local area
add fp,sp,#outsz // fp points to the bottom of local area
```
This is not ideal, since if `#localsz + #outsz` is not 16 byte aligned, it would
need to be padded, and we would end up with two different paddings that might
not be necessary. An alternative would be:
```
sub sp,sp,#16
str r19,[sp,#8] // Save register at the top
sub sp,sp,#localsz + #outsz // allocate remaining frame. Note that there are 8 bytes of padding from the first "sub sp" that can be subtracted from "#localsz + #outsz" before padding them up to 16.
stp fp,lr,[sp,#outsz] // save <fp,lr> at bottom of local area
add fp,sp,#outsz // fp points to the bottom of local area
```
## 6. chained, `#localsz > 512`, `#outsz > 512`
The most general case. It is a simple generalization of #5. `sub sp` (or a pair
of `sub sp` for really large sizes) is used for both sizes that might overflow
the pre-indexed addressing mode offset limit.
```
stp r19,r20,[sp,#-96]! // pre-indexed, save incoming 1st FP/INT pair
stp d8,d9,[sp,#16] // save in FP regs (optional)
stp r0,r1,[sp,#32] // home params (optional)
stp r2,r3,[sp,#48]
stp r4,r5,[sp,#64]
stp r6,r7,[sp,#80]
sub sp,sp,#localsz // allocate locals space
stp fp,lr,[sp] // save <fp,lr> at bottom of local area
mov fp,sp // fp points to the bottom of local area
sub sp,sp,#outsz // allocate outgoing argument space
```
10 instructions. There are 3 SP adjustments. Works with alloca. Frame access is
via SP or FP.
We will use this.
## 7. chained, any size frame, but no alloca.
```
stp fp,lr,[sp,#-112]! // pre-indexed, save <fp,lr>
mov fp,sp // fp points to top of local area
stp r19,r20,[sp,#16] // save INT pair
stp d8,d9,[sp,#32] // save FP pair
stp r0,r1,[sp,#48] // home params (optional)
stp r2,r3,[sp,#64]
stp r4,r5,[sp,#80]
stp r6,r7,[sp,#96]
sub sp,sp,#framesz - 112 // allocate the remaining local area
```
9 instructions. There are 2 SP adjustments. The frame pointer FP points to the
top of the local area, which means this is not suitable for frames with alloca.
All frame access will be SP-relative. #1 and #2 are better for small frames, or
with alloca.
## 8. Unchained. No alloca.
```
stp r19,r20,[sp,#-80]! // pre-indexed, save incoming 1st FP/INT pair
stp r21,r22,[sp,#16] // ...
stp r23,lr,[sp,#32] // save last Int reg and lr
stp d8,d9,[sp,#48] // save FP pair (optional)
stp d10,d11,[sp,#64] // ...
sub sp,sp,#framesz-80 // allocate the remaining local area
Or, with even number saved Int registers. Note that here we leave 8 bytes of
padding at the highest address in the frame. We might choose to use a different
format, to put the padding in the locals area, where it might be absorbed by the
locals.
stp r19,r20,[sp,-80]! // pre-indexed, save in 1st FP/INT reg-pair
stp r21,r22,[sp,16] // ...
str lr,[sp, 32] // save lr
stp d8,d9,[sp, 40] // save FP reg-pair (optional)
stp d10,d11,[sp,56] // ...
sub sp,#framesz - 80 // allocate the remaining local area
```
All locals are accessed based on SP. FP points to the previous frame.
For optimization purpose, FP can be put at any position in locals area to
provide a better coverage for "reg-pair" and pre-/post-indexed offset addressing
mode. Locals below frame pointers can be accessed based on SP.
## 9. The minimal leaf frame
```
str lr,[sp,#-16]! // pre-indexed, save lr, align stack to 16
... function body ...
ldr lr,[sp],#16 // epilog: reverse prolog, load return address
ret lr
```
Note that in this case, there is 8 bytes of alignment above the save of LR.
| # ARM64 JIT frame layout
NOTE: This document was written before the code was written, and hasn't been
verified to match existing code. It refers to some documents that might not be
open source.
This document describes the frame layout constraints and options for the ARM64
JIT compiler.
These frame layouts were taken from the "Windows ARM64 Exception Data"
specification, and expanded for use by the JIT.
We will generate chained frames in most case (where we save the frame pointer on
the stack, and point the frame pointer (x29) at the saved frame pointer),
including all non-leaf frames, to support ETW stack walks. This is recommended
by the "Windows ARM64 ABI" document. See `ETW_EBP_FRAMED` in the JIT code. (We
currently don’t set `ETW_EBP_FRAMED` for ARM64.)
For frames with alloca (dynamic stack allocation), we must use a frame pointer
that is fixed after the prolog (and before any alloca), so the stack pointer can
vary. The frame pointer will be used to access locals, parameters, etc., in the
fixed part of the frame.
For non-alloca frames, the stack pointer is set and not changed at the end of
the prolog. In this case, the stack pointer can be used for all frame member
access. If a frame pointer is also created, the frame pointer can optionally be
used to access frame members if it gives an encoding advantage.
We require a frame pointer for several cases: (1) functions with exception
handling establish a frame pointer so handler funclets can use the frame pointer
to access parent function locals, (2) for functions with P/Invoke, (3) for
certain GC encoding limitations or requirements, (4) for varargs functions, (5)
for Edit & Continue functions, (6) for debuggable code, and (7) for MinOpts.
This list might not be exhaustive.
On ARM64, the stack pointer must remain 16 byte aligned at all times.
The immediate offset addressing modes for various instructions have different
offset ranges. We want the frames to be designed to efficiently use the
available instruction encodings. Some important offset ranges for immediate
offset addressing include:
* ldrb /ldrsb / strb, unsigned offset: 0 to 4095
* ldrh /ldrsh / strh, unsigned offset: 0 to 8190, multiples of 2 (aligned halfwords)
* ldr / str (32-bit variant) / ldrsw, unsigned offset: 0 to 16380, multiple of 4 (aligned words)
* ldr / str (64-bit variant), unsigned offset: 0 to 32760, multiple of 8 (aligned doublewords)
* ldp / stp (32-bit variant), pre-indexed, post-indexed, and signed offset: -256 to 252, multiple of 4
* ldp / stp (64-bit variant), pre-indexed, post-indexed, and signed offset: -512 to 504, multiple of 8
* ldurb / ldursb / ldurh / ldursb / ldur (32-bit and 64-bit variants) / ldursw / sturb / sturh / stur (32-bit and 64-bit variants): -256 to 255
* ldr / ldrh / ldrb / ldrsw / ldrsh / ldrsb / str / strh / strb pre-indexed/post-indexed: -256 to 255 (unscaled)
* add / sub (immediate): 0 to 4095, or with 12 bit left shift: 4096 to 16777215 (multiples of 4096).
* Thus, to construct a frame larger than 4095 using `sub`, we could use one "small" sub, or one "large" / shifted sub followed by a single "small" / unshifted sub. The reverse applies for tearing down the frame.
* Note that we need to probe the stack for stack overflow when allocating large frames.
Most of the offset modes (that aren't pre-indexed or post-indexed) are unsigned.
Thus, we want the frame pointer, if it exists, to be at a lower address than the
objects on the frame (with the small caveat that we could use the limited
negative offset addressing capability of the `ldu*` / `stu*` unscaled modes).
The stack pointer will point to the first slot of the outgoing stack argument
area, if any, even for alloca functions (thus, the alloca operation needs to
"move" the outgoing stack argument space down), so filling the outgoing stack
argument space will always use SP.
For extremely large frames (e.g., frames larger than 32760, certainly, but
probably for any frame larger than 4095), we need to globally reserve and use an
additional register to construct an offset, and then use a register offset mode
(see `compRsvdRegCheck()`). It is unlikely we could accurately allocate a
register for this purpose at all points where it will be actually necessary.
In general, we want to put objects close to the stack or frame pointer, to take
advantage of the limited addressing offsets described above, especially if we
use the ldp/stp instructions. If we do end up using ldp/stp, we will want to
consider pointing the frame pointer somewhere in the middle of the locals (or
other objects) in the frame, to maximize the limited, but signed, offset range.
For example, saved callee-saved registers should be far from the frame/stack
pointer, since they are going to be saved once and loaded once, whereas
locals/temps are expected to be used more frequently.
For variadic (varargs) functions, and possibly for functions with incoming
struct register arguments, it is easier to put the arguments on the stack in the
prolog such that the entire argument list is contiguous in memory, including
both the register and stack arguments. On ARM32, we used the "prespill" concept,
where we used a register mask "push" instruction for the "prespilled" registers.
Note that on ARM32, structs could be split between incoming argument registers
and the stack. On ARM64, this is not true. A struct <=16 bytes is passed in one
or two consecutive registers, or entirely on the stack. Structs >16 bytes are
passed by reference (the caller allocates space for the struct in its frame,
copies the output struct value there, and passes a pointer to that space). On
ARM64, instead of prespill we can instead just allocate the appropriate stack
space, and use `str` or `stp` to save the incoming register arguments to the
reserved space.
To support GC "return address hijacking", we need to, for all functions, save
the return address to the stack in the prolog, and load it from the stack in the
epilog before returning. We must do this so the VM can change the return address
stored on the stack to cause the function to return to a special location to
support suspension.
Below are some sample frame layouts. In these examples, `#localsz` is the byte
size of the locals/temps area (everything except callee-saved registers and the
outgoing argument space, but including space to save FP and SP), `#outsz` is the
outgoing stack parameter size, and `#framesz` is the size of the entire stack
(meaning `#localsz` + `#outsz` + callee-saved register size, but not including
any alloca size).
Note that in these frame layouts, the saved `<fp,lr>` pair is not contiguous
with the rest of the callee-saved registers. This is because for chained
functions, the frame pointer must point at the saved frame pointer. Also, if we
are to use the positive immediate offset addressing modes, we need the frame
pointer to be lowest on the stack. In addition, we want the callee-saved
registers to be "far away", especially for large frames where an immediate
offset addressing mode won’t be able to reach them, as we want locals to be
closer than the callee-saved registers.
To maintain 16 byte stack alignment, we may need to add alignment padding bytes.
Ideally we design the frame such that we only need at most 15 alignment bytes.
Since our frame objects are minimally 4 bytes (or maybe even 8 bytes?) in size,
we should only need maximally 12 (or 8?) alignment bytes. Note that every time
the stack pointer is changed, it needs to be by 16 bytes, so every time we
adjust the stack might require alignment. (Technically, it might be the case
that you can change the stack pointer by values not a multiple of 16, but you
certainly can’t load or store from non-16-byte-aligned SP values. Also, the
ARM64 unwind code `alloc_s` is 8 byte scaled, so it can only handle multiple of
8 byte changes to SP.) Note that ldp/stp can be given an 8-byte aligned address
when reading/writing 8-byte register pairs, even though the total data transfer
for the instruction is 16 bytes.
## 1. chained, `#framesz <= 512`, `#outsz = 0`
```
stp fp,lr,[sp,-#framesz]! // pre-indexed, save <fp,lr> at bottom of frame
mov fp,sp // fp points to bottom of stack
stp r19,r20,[sp,#framesz - 96] // save INT pair
stp d8,d9,[sp,#framesz - 80] // save FP pair
stp r0,r1,[sp,#framesz - 64] // home params (optional)
stp r2,r3,[sp,#framesz - 48]
stp r4,r5,[sp,#framesz - 32]
stp r6,r7,[sp,#framesz - 16]
```
8 instructions (for this set of registers saves, used in most examples given
here). There is a single SP adjustment, that is folded into the `<fp,lr>`
register pair store. Works with alloca. Frame access is via SP or FP.
We will use this for most frames with no outgoing stack arguments (which is
likely to be the 99% case, since we have 8 integer register arguments and 8
floating-point register arguments).
Here is a similar example, but with an odd number of saved registers:
```
stp fp,lr,[sp,-#framesz]! // pre-indexed, save <fp,lr> at bottom of frame
mov fp,sp // fp points to bottom of stack
stp r19,r20,[sp,#framesz - 24] // save INT pair
str r21,[sp,#framesz - 8] // save INT reg
```
Note that the saved registers are "packed" against the "caller SP" value (that
is, they are at the "top" of the downward-growing stack). Any alignment is lower
than the callee-saved registers.
For leaf functions, we don't need to save the callee-save registers, so we will
have, for chained function (such as functions with alloca):
```
stp fp,lr,[sp,-#framesz]! // pre-indexed, save <fp,lr> at bottom of frame
mov fp,sp // fp points to bottom of stack
```
## 2. chained, `#framesz - 16 <= 512`, `#outsz != 0`
```
sub sp,sp,#framesz
stp fp,lr,[sp,#outsz] // pre-indexed, save <fp,lr>
add fp,sp,#outsz // fp points to bottom of local area
stp r19,r20,[sp,#framez - 96] // save INT pair
stp d8,d9,[sp,#framesz - 80] // save FP pair
stp r0,r1,[sp,#framesz - 64] // home params (optional)
stp r2,r3,[sp,#framesz - 48]
stp r4,r5,[sp,#framesz - 32]
stp r6,r7,[sp,#framesz - 16]
```
9 instructions. There is a single SP adjustment. It isn’t folded into the
`<fp,lr>` register pair store because the SP adjustment points the new SP at the
outgoing argument space, and the `<fp,lr>` pair needs to be stored above that.
Works with alloca. Frame access is via SP or FP.
We will use this for most non-leaf frames with outgoing argument stack space.
As for #1, if there is an odd number of callee-save registers, they can easily
be put adjacent to the caller SP (at the "top" of the stack), so any alignment
bytes will be in the locals area.
## 3. chained, `(#framesz - #outsz) <= 512`, `#outsz != 0`.
Different from #2, as `#framesz` is too big. Might be useful for `#framesz >
512` but `(#framesz - #outsz) <= 512`.
```
stp fp,lr,[sp,-(#localsz + 96)]! // pre-indexed, save <fp,lr> above outgoing argument space
mov fp,sp // fp points to bottom of stack
stp r19,r20,[sp,#localsz + 80] // save INT pair
stp d8,d9,[sp,#localsz + 64] // save FP pair
stp r0,r1,[sp,#localsz + 48] // home params (optional)
stp r2,r3,[sp,#localsz + 32]
stp r4,r5,[sp,#localsz + 16]
stp r6,r7,[sp,#localsz]
sub sp,sp,#outsz
```
9 instructions. There are 2 SP adjustments. Works with alloca. Frame access is
via SP or FP.
We will not use this.
## 4. chained, `#localsz <= 512`
```
stp r19,r20,[sp,#-96]! // pre-indexed, save incoming 1st FP/INT pair
stp d8,d9,[sp,#16] // save incoming floating-point regs (optional)
stp r0,r1,[sp,#32] // home params (optional)
stp r2,r3,[sp,#48]
stp r4,r5,[sp,#64]
stp r6,r7,[sp,#80]
stp fp,lr,[sp,-#localsz]! // save <fp,lr> at bottom of local area
mov fp,sp // fp points to bottom of local area
sub sp,sp,#outsz // if #outsz != 0
```
9 instructions. There are 3 SP adjustments: to set SP for saving callee-saved
registers, for allocating the local space (and storing `<fp,lr>`), and for
allocating the outgoing argument space. Works with alloca. Frame access is via
SP or FP.
We likely will not use this. Instead, we will use #2 or #5/#6.
## 5. chained, `#localsz > 512`, `#outsz <= 512`.
Another case with an unlikely mix of sizes.
```
stp r19,r20,[sp,#-96]! // pre-indexed, save incoming 1st FP/INT pair
stp d8,d9,[sp,#16] // save in FP regs (optional)
stp r0,r1,[sp,#32] // home params (optional)
stp r2,r3,[sp,#48]
stp r4,r5,[sp,#64]
stp r6,r7,[sp,#80]
sub sp,sp,#localsz+#outsz // allocate remaining frame
stp fp,lr,[sp,#outsz] // save <fp,lr> at bottom of local area
add fp,sp,#outsz // fp points to the bottom of local area
```
9 instructions. There are 2 SP adjustments. Works with alloca. Frame access is
via SP or FP.
We will use this.
To handle an odd number of callee-saved registers with this layout, we would
need to insert alignment bytes higher in the stack. E.g.:
```
str r19,[sp,#-16]! // pre-indexed, save incoming 1st INT reg
sub sp,sp,#localsz + #outsz // allocate remaining frame
stp fp,lr,[sp,#outsz] // save <fp,lr> at bottom of local area
add fp,sp,#outsz // fp points to the bottom of local area
```
This is not ideal, since if `#localsz + #outsz` is not 16 byte aligned, it would
need to be padded, and we would end up with two different paddings that might
not be necessary. An alternative would be:
```
sub sp,sp,#16
str r19,[sp,#8] // Save register at the top
sub sp,sp,#localsz + #outsz // allocate remaining frame. Note that there are 8 bytes of padding from the first "sub sp" that can be subtracted from "#localsz + #outsz" before padding them up to 16.
stp fp,lr,[sp,#outsz] // save <fp,lr> at bottom of local area
add fp,sp,#outsz // fp points to the bottom of local area
```
## 6. chained, `#localsz > 512`, `#outsz > 512`
The most general case. It is a simple generalization of #5. `sub sp` (or a pair
of `sub sp` for really large sizes) is used for both sizes that might overflow
the pre-indexed addressing mode offset limit.
```
stp r19,r20,[sp,#-96]! // pre-indexed, save incoming 1st FP/INT pair
stp d8,d9,[sp,#16] // save in FP regs (optional)
stp r0,r1,[sp,#32] // home params (optional)
stp r2,r3,[sp,#48]
stp r4,r5,[sp,#64]
stp r6,r7,[sp,#80]
sub sp,sp,#localsz // allocate locals space
stp fp,lr,[sp] // save <fp,lr> at bottom of local area
mov fp,sp // fp points to the bottom of local area
sub sp,sp,#outsz // allocate outgoing argument space
```
10 instructions. There are 3 SP adjustments. Works with alloca. Frame access is
via SP or FP.
We will use this.
## 7. chained, any size frame, but no alloca.
```
stp fp,lr,[sp,#-112]! // pre-indexed, save <fp,lr>
mov fp,sp // fp points to top of local area
stp r19,r20,[sp,#16] // save INT pair
stp d8,d9,[sp,#32] // save FP pair
stp r0,r1,[sp,#48] // home params (optional)
stp r2,r3,[sp,#64]
stp r4,r5,[sp,#80]
stp r6,r7,[sp,#96]
sub sp,sp,#framesz - 112 // allocate the remaining local area
```
9 instructions. There are 2 SP adjustments. The frame pointer FP points to the
top of the local area, which means this is not suitable for frames with alloca.
All frame access will be SP-relative. #1 and #2 are better for small frames, or
with alloca.
## 8. Unchained. No alloca.
```
stp r19,r20,[sp,#-80]! // pre-indexed, save incoming 1st FP/INT pair
stp r21,r22,[sp,#16] // ...
stp r23,lr,[sp,#32] // save last Int reg and lr
stp d8,d9,[sp,#48] // save FP pair (optional)
stp d10,d11,[sp,#64] // ...
sub sp,sp,#framesz-80 // allocate the remaining local area
Or, with even number saved Int registers. Note that here we leave 8 bytes of
padding at the highest address in the frame. We might choose to use a different
format, to put the padding in the locals area, where it might be absorbed by the
locals.
stp r19,r20,[sp,-80]! // pre-indexed, save in 1st FP/INT reg-pair
stp r21,r22,[sp,16] // ...
str lr,[sp, 32] // save lr
stp d8,d9,[sp, 40] // save FP reg-pair (optional)
stp d10,d11,[sp,56] // ...
sub sp,#framesz - 80 // allocate the remaining local area
```
All locals are accessed based on SP. FP points to the previous frame.
For optimization purpose, FP can be put at any position in locals area to
provide a better coverage for "reg-pair" and pre-/post-indexed offset addressing
mode. Locals below frame pointers can be accessed based on SP.
## 9. The minimal leaf frame
```
str lr,[sp,#-16]! // pre-indexed, save lr, align stack to 16
... function body ...
ldr lr,[sp],#16 // epilog: reverse prolog, load return address
ret lr
```
Note that in this case, there is 8 bytes of alignment above the save of LR.
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/x86_64/Ltrace.c | #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gtrace.c"
#endif
| #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gtrace.c"
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/nativeaot/docs/prerequisites.md | If you're new to .NET, make sure to visit the [official starting page](http://dotnet.github.io). It will guide you through installing pre-requisites and building your first app.
If you're already familiar with .NET, make sure you've [downloaded and installed the .NET 6 SDK](https://www.microsoft.com/net/download/core).
The following pre-requisites need to be installed for building .NET 6 projects with Native AOT.
# Windows
* Install [Visual Studio 2022](https://visualstudio.microsoft.com/vs/community/), including Desktop development with C++ workload.
## Advanced Alternative: Minimum Visual C++ Build Tools Installation
If you wish to save disk space and do not need Visual Studio IDE, you may use the [Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022)
edition instead. First download the [bootstrapper](https://aka.ms/vs/17/release/vs_buildtools.exe) executable.
On Windows 10 version 1803 or later you may use the `curl` tool:
```cmd
curl -L https://aka.ms/vs/17/release/vs_buildtools.exe -o vs_buildtools.exe
```
Then launch the bootstrapper passing the installation path and the two required components (requires elevation):
```cmd
vs_buildtools.exe --installPath C:\VS2022 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 Microsoft.VisualStudio.Component.Windows10SDK.19041 --passive --norestart --nocache
```
Alternatively you may launch the bootstrapper without any options and use Visual Studio Installer UI to enable C++ x64/x86 build tools and Windows 10 SDK individual components.
Notes:
- You may skip the `Windows10SDK.19041` component if you already have Windows 10 SDK installed on your machine.
- To target Windows ARM64, you need to add the `Microsoft.VisualStudio.Component.VC.Tools.ARM64` (C++ ARM64 build tools) component instead.
- The `--installPath` option affects Build Tools installation only. Visual Studio Installer is always installed into
the `%ProgramFiles(x86)%\Microsoft Visual Studio\Installer` directory.
# Fedora (31+)
* Install `clang` and developer packages for libraries that .NET Core depends on:
```sh
sudo dnf install clang zlib-devel krb5-libs krb5-devel ncurses-compat-libs
```
This was tested on Fedora 31, but will most likely work on lower versions too.
# Ubuntu (16.04+)
* Install `clang` and developer packages for libraries that .NET Core depends on:
```sh
sudo apt-get install clang zlib1g-dev libkrb5-dev
```
# macOS (10.13+)
* Install latest [Command Line Tools for XCode](https://developer.apple.com/xcode/download/).
| If you're new to .NET, make sure to visit the [official starting page](http://dotnet.github.io). It will guide you through installing pre-requisites and building your first app.
If you're already familiar with .NET, make sure you've [downloaded and installed the .NET 6 SDK](https://www.microsoft.com/net/download/core).
The following pre-requisites need to be installed for building .NET 6 projects with Native AOT.
# Windows
* Install [Visual Studio 2022](https://visualstudio.microsoft.com/vs/community/), including Desktop development with C++ workload.
## Advanced Alternative: Minimum Visual C++ Build Tools Installation
If you wish to save disk space and do not need Visual Studio IDE, you may use the [Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022)
edition instead. First download the [bootstrapper](https://aka.ms/vs/17/release/vs_buildtools.exe) executable.
On Windows 10 version 1803 or later you may use the `curl` tool:
```cmd
curl -L https://aka.ms/vs/17/release/vs_buildtools.exe -o vs_buildtools.exe
```
Then launch the bootstrapper passing the installation path and the two required components (requires elevation):
```cmd
vs_buildtools.exe --installPath C:\VS2022 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 Microsoft.VisualStudio.Component.Windows10SDK.19041 --passive --norestart --nocache
```
Alternatively you may launch the bootstrapper without any options and use Visual Studio Installer UI to enable C++ x64/x86 build tools and Windows 10 SDK individual components.
Notes:
- You may skip the `Windows10SDK.19041` component if you already have Windows 10 SDK installed on your machine.
- To target Windows ARM64, you need to add the `Microsoft.VisualStudio.Component.VC.Tools.ARM64` (C++ ARM64 build tools) component instead.
- The `--installPath` option affects Build Tools installation only. Visual Studio Installer is always installed into
the `%ProgramFiles(x86)%\Microsoft Visual Studio\Installer` directory.
# Fedora (31+)
* Install `clang` and developer packages for libraries that .NET Core depends on:
```sh
sudo dnf install clang zlib-devel krb5-libs krb5-devel ncurses-compat-libs
```
This was tested on Fedora 31, but will most likely work on lower versions too.
# Ubuntu (16.04+)
* Install `clang` and developer packages for libraries that .NET Core depends on:
```sh
sudo apt-get install clang zlib1g-dev libkrb5-dev
```
# macOS (10.13+)
* Install latest [Command Line Tools for XCode](https://developer.apple.com/xcode/download/).
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/x86_64/Gget_save_loc.c | /* libunwind - a platform-independent unwind library
Copyright (C) 2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
Modified for x86_64 by Max Asbock <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
int
unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc)
{
struct cursor *c = (struct cursor *) cursor;
dwarf_loc_t loc;
loc = DWARF_NULL_LOC; /* default to "not saved" */
switch (reg)
{
case UNW_X86_64_RBX: loc = c->dwarf.loc[RBX]; break;
case UNW_X86_64_RSP: loc = c->dwarf.loc[RSP]; break;
case UNW_X86_64_RBP: loc = c->dwarf.loc[RBP]; break;
case UNW_X86_64_R12: loc = c->dwarf.loc[R12]; break;
case UNW_X86_64_R13: loc = c->dwarf.loc[R13]; break;
case UNW_X86_64_R14: loc = c->dwarf.loc[R14]; break;
case UNW_X86_64_R15: loc = c->dwarf.loc[R15]; break;
case UNW_X86_64_RIP: loc = c->dwarf.loc[RIP]; break;
default:
break;
}
memset (sloc, 0, sizeof (*sloc));
if (DWARF_IS_NULL_LOC (loc))
{
sloc->type = UNW_SLT_NONE;
return 0;
}
#if !defined(UNW_LOCAL_ONLY)
if (DWARF_IS_REG_LOC (loc))
{
sloc->type = UNW_SLT_REG;
sloc->u.regnum = DWARF_GET_LOC (loc);
}
else
#endif
{
sloc->type = UNW_SLT_MEMORY;
sloc->u.addr = DWARF_GET_LOC (loc);
}
return 0;
}
| /* libunwind - a platform-independent unwind library
Copyright (C) 2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
Modified for x86_64 by Max Asbock <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
int
unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc)
{
struct cursor *c = (struct cursor *) cursor;
dwarf_loc_t loc;
loc = DWARF_NULL_LOC; /* default to "not saved" */
switch (reg)
{
case UNW_X86_64_RBX: loc = c->dwarf.loc[RBX]; break;
case UNW_X86_64_RSP: loc = c->dwarf.loc[RSP]; break;
case UNW_X86_64_RBP: loc = c->dwarf.loc[RBP]; break;
case UNW_X86_64_R12: loc = c->dwarf.loc[R12]; break;
case UNW_X86_64_R13: loc = c->dwarf.loc[R13]; break;
case UNW_X86_64_R14: loc = c->dwarf.loc[R14]; break;
case UNW_X86_64_R15: loc = c->dwarf.loc[R15]; break;
case UNW_X86_64_RIP: loc = c->dwarf.loc[RIP]; break;
default:
break;
}
memset (sloc, 0, sizeof (*sloc));
if (DWARF_IS_NULL_LOC (loc))
{
sloc->type = UNW_SLT_NONE;
return 0;
}
#if !defined(UNW_LOCAL_ONLY)
if (DWARF_IS_REG_LOC (loc))
{
sloc->type = UNW_SLT_REG;
sloc->u.regnum = DWARF_GET_LOC (loc);
}
else
#endif
{
sloc->type = UNW_SLT_MEMORY;
sloc->u.addr = DWARF_GET_LOC (loc);
}
return 0;
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/metadata/mono-debug.c | /**
* \file
*
* Author:
* Mono Project (http://www.mono-project.com)
*
* Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
* Copyright 2004-2009 Novell, Inc (http://www.novell.com)
* Copyright 2011 Xamarin Inc (http://www.xamarin.com)
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/assembly-internals.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/tokentype.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/debug-internals.h>
#include <mono/metadata/mono-endian.h>
#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mempool.h>
#include <mono/metadata/debug-mono-symfile.h>
#include <mono/metadata/debug-mono-ppdb.h>
#include <mono/metadata/exception-internals.h>
#include <mono/metadata/runtime.h>
#include <mono/metadata/metadata-update.h>
#include <string.h>
#if NO_UNALIGNED_ACCESS
#define WRITE_UNALIGNED(type, addr, val) \
memcpy(addr, &val, sizeof(type))
#define READ_UNALIGNED(type, addr, val) \
memcpy(&val, addr, sizeof(type))
#else
#define WRITE_UNALIGNED(type, addr, val) \
(*(type *)(addr) = (val))
#define READ_UNALIGNED(type, addr, val) \
val = (*(type *)(addr))
#endif
/* Many functions have 'domain' parameters, those are ignored */
/*
* This contains per-memory manager info.
*/
typedef struct {
MonoMemPool *mp;
/* Maps MonoMethod->MonoDebugMethodAddress */
GHashTable *method_hash;
} DebugMemoryManager;
/* This contains JIT debugging information about a method in serialized format */
struct _MonoDebugMethodAddress {
const guint8 *code_start;
guint32 code_size;
guint8 data [MONO_ZERO_LEN_ARRAY];
};
static MonoDebugFormat mono_debug_format = MONO_DEBUG_FORMAT_NONE;
static gboolean mono_debug_initialized = FALSE;
/* Maps MonoImage -> MonoMonoDebugHandle */
static GHashTable *mono_debug_handles;
static mono_mutex_t debugger_lock_mutex;
static gboolean is_attached = FALSE;
static MonoDebugHandle *mono_debug_open_image (MonoImage *image, const guint8 *raw_contents, int size);
static MonoDebugHandle *mono_debug_get_image (MonoImage *image);
static void add_assembly (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer user_data, MonoError *error);
static MonoDebugHandle *open_symfile_from_bundle (MonoImage *image);
static DebugMemoryManager*
get_mem_manager (MonoMethod *method)
{
MonoMemoryManager *mem_manager = m_method_get_mem_manager (method);
if (!mono_debug_initialized)
return NULL;
if (!mem_manager->debug_info) {
DebugMemoryManager *info;
info = g_new0 (DebugMemoryManager, 1);
info->mp = mono_mempool_new ();
info->method_hash = g_hash_table_new (NULL, NULL);
mono_memory_barrier ();
mono_debugger_lock ();
if (!mem_manager->debug_info)
mem_manager->debug_info = info;
// FIXME: Free otherwise
mono_debugger_unlock ();
}
return (DebugMemoryManager*)mem_manager->debug_info;
}
/*
* mono_mem_manager_free_debug_info:
*
* Free the information maintained by this module for MEM_MANAGER.
*/
void
mono_mem_manager_free_debug_info (MonoMemoryManager *memory_manager)
{
DebugMemoryManager *info = (DebugMemoryManager*)memory_manager->debug_info;
if (!info)
return;
mono_mempool_destroy (info->mp);
g_hash_table_destroy (info->method_hash);
g_free (info);
}
static void
free_debug_handle (MonoDebugHandle *handle)
{
if (handle->ppdb)
mono_ppdb_close (handle->ppdb);
if (handle->symfile)
mono_debug_close_mono_symbol_file (handle->symfile);
/* decrease the refcount added with mono_image_addref () */
mono_image_close (handle->image);
g_free (handle);
}
/*
* Initialize debugging support.
*
* This method must be called after loading corlib,
* but before opening the application's main assembly because we need to set some
* callbacks here.
*/
void
mono_debug_init (MonoDebugFormat format)
{
g_assert (!mono_debug_initialized);
if (format == MONO_DEBUG_FORMAT_DEBUGGER)
g_error ("The mdb debugger is no longer supported.");
mono_debug_initialized = TRUE;
mono_debug_format = format;
mono_os_mutex_init_recursive (&debugger_lock_mutex);
mono_debugger_lock ();
mono_debug_handles = g_hash_table_new_full
(NULL, NULL, NULL, (GDestroyNotify) free_debug_handle);
mono_install_assembly_load_hook_v2 (add_assembly, NULL, FALSE);
mono_debugger_unlock ();
}
void
mono_debug_open_image_from_memory (MonoImage *image, const guint8 *raw_contents, int size)
{
MONO_ENTER_GC_UNSAFE;
if (!mono_debug_initialized)
goto leave;
mono_debug_open_image (image, raw_contents, size);
leave:
MONO_EXIT_GC_UNSAFE;
}
void
mono_debug_cleanup (void)
{
}
/**
* mono_debug_domain_create:
*/
void
mono_debug_domain_create (MonoDomain *domain)
{
g_assert_not_reached ();
}
void
mono_debug_domain_unload (MonoDomain *domain)
{
g_assert_not_reached ();
}
/*
* LOCKING: Assumes the debug lock is held.
*/
static MonoDebugHandle *
mono_debug_get_image (MonoImage *image)
{
return (MonoDebugHandle *)g_hash_table_lookup (mono_debug_handles, image);
}
/**
* mono_debug_close_image:
*/
void
mono_debug_close_image (MonoImage *image)
{
MonoDebugHandle *handle;
if (!mono_debug_initialized)
return;
mono_debugger_lock ();
handle = mono_debug_get_image (image);
if (!handle) {
mono_debugger_unlock ();
return;
}
g_hash_table_remove (mono_debug_handles, image);
mono_debugger_unlock ();
}
MonoDebugHandle *
mono_debug_get_handle (MonoImage *image)
{
return mono_debug_open_image (image, NULL, 0);
}
static MonoDebugHandle *
mono_debug_open_image (MonoImage *image, const guint8 *raw_contents, int size)
{
MonoDebugHandle *handle;
if (mono_image_is_dynamic (image))
return NULL;
mono_debugger_lock ();
handle = mono_debug_get_image (image);
if (handle != NULL) {
mono_debugger_unlock ();
return handle;
}
handle = g_new0 (MonoDebugHandle, 1);
handle->image = image;
mono_image_addref (image);
/* Try a ppdb file first */
handle->ppdb = mono_ppdb_load_file (handle->image, raw_contents, size);
if (!handle->ppdb)
handle->symfile = mono_debug_open_mono_symbols (handle, raw_contents, size, FALSE);
g_hash_table_insert (mono_debug_handles, image, handle);
mono_debugger_unlock ();
return handle;
}
static void
add_assembly (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer user_data, MonoError *error)
{
MonoDebugHandle *handle;
MonoImage *image;
mono_debugger_lock ();
image = mono_assembly_get_image_internal (assembly);
handle = open_symfile_from_bundle (image);
if (!handle)
mono_debug_open_image (image, NULL, 0);
mono_debugger_unlock ();
}
struct LookupMethodData
{
MonoDebugMethodInfo *minfo;
MonoMethod *method;
};
static void
lookup_method_func (gpointer key, gpointer value, gpointer user_data)
{
MonoDebugHandle *handle = (MonoDebugHandle *) value;
struct LookupMethodData *data = (struct LookupMethodData *) user_data;
if (data->minfo)
return;
if (handle->ppdb)
data->minfo = mono_ppdb_lookup_method (handle, data->method);
else if (handle->symfile)
data->minfo = mono_debug_symfile_lookup_method (handle, data->method);
}
static MonoDebugMethodInfo *
lookup_method (MonoMethod *method)
{
struct LookupMethodData data;
data.minfo = NULL;
data.method = method;
if (!mono_debug_handles)
return NULL;
g_hash_table_foreach (mono_debug_handles, lookup_method_func, &data);
return data.minfo;
}
/**
* mono_debug_lookup_method:
*
* Lookup symbol file information for the method \p method. The returned
* \c MonoDebugMethodInfo is a private structure, but it can be passed to
* \c mono_debug_symfile_lookup_location.
*/
MonoDebugMethodInfo *
mono_debug_lookup_method (MonoMethod *method)
{
MonoDebugMethodInfo *minfo;
if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
return NULL;
mono_debugger_lock ();
minfo = lookup_method (method);
mono_debugger_unlock ();
return minfo;
}
typedef struct
{
gboolean found;
MonoImage *image;
} LookupImageData;
static void
lookup_image_func (gpointer key, gpointer value, gpointer user_data)
{
MonoDebugHandle *handle = (MonoDebugHandle *) value;
LookupImageData *data = (LookupImageData *) user_data;
if (data->found)
return;
if (handle->image == data->image && (handle->symfile || handle->ppdb))
data->found = TRUE;
}
gboolean
mono_debug_image_has_debug_info (MonoImage *image)
{
LookupImageData data;
if (!mono_debug_handles)
return FALSE;
memset (&data, 0, sizeof (data));
data.image = image;
mono_debugger_lock ();
g_hash_table_foreach (mono_debug_handles, lookup_image_func, &data);
mono_debugger_unlock ();
return data.found;
}
static void
write_leb128 (guint32 value, guint8 *ptr, guint8 **rptr)
{
do {
guint8 byte = value & 0x7f;
value >>= 7;
if (value)
byte |= 0x80;
*ptr++ = byte;
} while (value);
*rptr = ptr;
}
static void
write_sleb128 (gint32 value, guint8 *ptr, guint8 **rptr)
{
gboolean more = 1;
while (more) {
guint8 byte = value & 0x7f;
value >>= 7;
if (((value == 0) && ((byte & 0x40) == 0)) || ((value == -1) && (byte & 0x40)))
more = 0;
else
byte |= 0x80;
*ptr++ = byte;
}
*rptr = ptr;
}
/* leb128 uses a maximum of 5 bytes for a 32 bit value */
#define LEB128_MAX_SIZE 5
#define WRITE_VARIABLE_MAX_SIZE (5 * LEB128_MAX_SIZE + sizeof (gpointer))
static void
write_variable (MonoDebugVarInfo *var, guint8 *ptr, guint8 **rptr)
{
write_leb128 (var->index, ptr, &ptr);
write_sleb128 (var->offset, ptr, &ptr);
write_leb128 (var->size, ptr, &ptr);
write_leb128 (var->begin_scope, ptr, &ptr);
write_leb128 (var->end_scope, ptr, &ptr);
WRITE_UNALIGNED (gpointer, ptr, var->type);
ptr += sizeof (gpointer);
*rptr = ptr;
}
/**
* mono_debug_add_method:
*/
MonoDebugMethodAddress *
mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDomain *domain)
{
DebugMemoryManager *info;
MonoDebugMethodAddress *address;
guint8 buffer [BUFSIZ];
guint8 *ptr, *oldptr;
guint32 i, size, total_size, max_size;
info = get_mem_manager (method);
max_size = (5 * LEB128_MAX_SIZE) + 1 + (2 * LEB128_MAX_SIZE * jit->num_line_numbers);
if (jit->has_var_info) {
/* this */
max_size += 1;
if (jit->this_var)
max_size += WRITE_VARIABLE_MAX_SIZE;
/* params */
max_size += LEB128_MAX_SIZE;
max_size += jit->num_params * WRITE_VARIABLE_MAX_SIZE;
/* locals */
max_size += LEB128_MAX_SIZE;
max_size += jit->num_locals * WRITE_VARIABLE_MAX_SIZE;
/* gsharedvt */
max_size += 1;
if (jit->gsharedvt_info_var)
max_size += 2 * WRITE_VARIABLE_MAX_SIZE;
}
if (max_size > BUFSIZ)
ptr = oldptr = (guint8 *)g_malloc (max_size);
else
ptr = oldptr = buffer;
write_leb128 (jit->prologue_end, ptr, &ptr);
write_leb128 (jit->epilogue_begin, ptr, &ptr);
write_leb128 (jit->num_line_numbers, ptr, &ptr);
for (i = 0; i < jit->num_line_numbers; i++) {
MonoDebugLineNumberEntry *lne = &jit->line_numbers [i];
write_sleb128 (lne->il_offset, ptr, &ptr);
write_sleb128 (lne->native_offset, ptr, &ptr);
}
write_leb128 (jit->has_var_info, ptr, &ptr);
if (jit->has_var_info) {
*ptr++ = jit->this_var ? 1 : 0;
if (jit->this_var)
write_variable (jit->this_var, ptr, &ptr);
write_leb128 (jit->num_params, ptr, &ptr);
for (i = 0; i < jit->num_params; i++)
write_variable (&jit->params [i], ptr, &ptr);
write_leb128 (jit->num_locals, ptr, &ptr);
for (i = 0; i < jit->num_locals; i++)
write_variable (&jit->locals [i], ptr, &ptr);
*ptr++ = jit->gsharedvt_info_var ? 1 : 0;
if (jit->gsharedvt_info_var) {
write_variable (jit->gsharedvt_info_var, ptr, &ptr);
write_variable (jit->gsharedvt_locals_var, ptr, &ptr);
}
}
size = ptr - oldptr;
g_assert (size < max_size);
total_size = size + sizeof (MonoDebugMethodAddress);
mono_debugger_lock ();
if (method_is_dynamic (method)) {
address = (MonoDebugMethodAddress *)g_malloc0 (total_size);
} else {
address = (MonoDebugMethodAddress *)mono_mempool_alloc (info->mp, total_size);
}
address->code_start = jit->code_start;
address->code_size = jit->code_size;
memcpy (&address->data, oldptr, size);
if (max_size > BUFSIZ)
g_free (oldptr);
g_hash_table_insert (info->method_hash, method, address);
mono_debugger_unlock ();
return address;
}
void
mono_debug_remove_method (MonoMethod *method, MonoDomain *domain)
{
DebugMemoryManager *info;
MonoDebugMethodAddress *address;
if (!mono_debug_initialized)
return;
g_assert (method_is_dynamic (method));
info = get_mem_manager (method);
mono_debugger_lock ();
address = (MonoDebugMethodAddress *)g_hash_table_lookup (info->method_hash, method);
if (address)
g_free (address);
g_hash_table_remove (info->method_hash, method);
mono_debugger_unlock ();
}
/**
* mono_debug_add_delegate_trampoline:
*/
void
mono_debug_add_delegate_trampoline (gpointer code, int size)
{
}
static guint32
read_leb128 (guint8 *ptr, guint8 **rptr)
{
guint32 result = 0, shift = 0;
while (TRUE) {
guint8 byte = *ptr++;
result |= (byte & 0x7f) << shift;
if ((byte & 0x80) == 0)
break;
shift += 7;
}
*rptr = ptr;
return result;
}
static gint32
read_sleb128 (guint8 *ptr, guint8 **rptr)
{
gint32 result = 0;
guint32 shift = 0;
while (TRUE) {
guint8 byte = *ptr++;
result |= (byte & 0x7f) << shift;
shift += 7;
if (byte & 0x80)
continue;
if ((shift < 32) && (byte & 0x40))
result |= - (1 << shift);
break;
}
*rptr = ptr;
return result;
}
static void
read_variable (MonoDebugVarInfo *var, guint8 *ptr, guint8 **rptr)
{
var->index = read_leb128 (ptr, &ptr);
var->offset = read_sleb128 (ptr, &ptr);
var->size = read_leb128 (ptr, &ptr);
var->begin_scope = read_leb128 (ptr, &ptr);
var->end_scope = read_leb128 (ptr, &ptr);
READ_UNALIGNED (MonoType *, ptr, var->type);
ptr += sizeof (gpointer);
*rptr = ptr;
}
static void
free_method_jit_info (MonoDebugMethodJitInfo *jit, gboolean stack)
{
if (!jit)
return;
g_free (jit->line_numbers);
g_free (jit->this_var);
g_free (jit->params);
g_free (jit->locals);
g_free (jit->gsharedvt_info_var);
g_free (jit->gsharedvt_locals_var);
if (!stack)
g_free (jit);
}
void
mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit)
{
free_method_jit_info (jit, FALSE);
}
static MonoDebugMethodJitInfo *
mono_debug_read_method (MonoDebugMethodAddress *address, MonoDebugMethodJitInfo *jit)
{
guint32 i;
guint8 *ptr;
memset (jit, 0, sizeof (*jit));
jit->code_start = address->code_start;
jit->code_size = address->code_size;
ptr = (guint8 *) &address->data;
jit->prologue_end = read_leb128 (ptr, &ptr);
jit->epilogue_begin = read_leb128 (ptr, &ptr);
jit->num_line_numbers = read_leb128 (ptr, &ptr);
jit->line_numbers = g_new0 (MonoDebugLineNumberEntry, jit->num_line_numbers);
for (i = 0; i < jit->num_line_numbers; i++) {
MonoDebugLineNumberEntry *lne = &jit->line_numbers [i];
lne->il_offset = read_sleb128 (ptr, &ptr);
lne->native_offset = read_sleb128 (ptr, &ptr);
}
jit->has_var_info = read_leb128 (ptr, &ptr);
if (jit->has_var_info) {
if (*ptr++) {
jit->this_var = g_new0 (MonoDebugVarInfo, 1);
read_variable (jit->this_var, ptr, &ptr);
}
jit->num_params = read_leb128 (ptr, &ptr);
jit->params = g_new0 (MonoDebugVarInfo, jit->num_params);
for (i = 0; i < jit->num_params; i++)
read_variable (&jit->params [i], ptr, &ptr);
jit->num_locals = read_leb128 (ptr, &ptr);
jit->locals = g_new0 (MonoDebugVarInfo, jit->num_locals);
for (i = 0; i < jit->num_locals; i++)
read_variable (&jit->locals [i], ptr, &ptr);
if (*ptr++) {
jit->gsharedvt_info_var = g_new0 (MonoDebugVarInfo, 1);
jit->gsharedvt_locals_var = g_new0 (MonoDebugVarInfo, 1);
read_variable (jit->gsharedvt_info_var, ptr, &ptr);
read_variable (jit->gsharedvt_locals_var, ptr, &ptr);
}
}
return jit;
}
static MonoDebugMethodJitInfo *
find_method (MonoMethod *method, MonoDebugMethodJitInfo *jit)
{
DebugMemoryManager *info;
MonoDebugMethodAddress *address;
info = get_mem_manager (method);
address = (MonoDebugMethodAddress *)g_hash_table_lookup (info->method_hash, method);
if (!address)
return NULL;
return mono_debug_read_method (address, jit);
}
MonoDebugMethodJitInfo *
mono_debug_find_method (MonoMethod *method, MonoDomain *domain)
{
if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
return NULL;
MonoDebugMethodJitInfo *res = g_new0 (MonoDebugMethodJitInfo, 1);
mono_debugger_lock ();
find_method (method, res);
mono_debugger_unlock ();
return res;
}
MonoDebugMethodAddressList *
mono_debug_lookup_method_addresses (MonoMethod *method)
{
g_assert_not_reached ();
return NULL;
}
static gint32
il_offset_from_address (MonoMethod *method, guint32 native_offset)
{
MonoDebugMethodJitInfo mem;
int i;
MonoDebugMethodJitInfo *jit = find_method (method, &mem);
if (!jit || !jit->line_numbers)
goto cleanup_and_fail;
for (i = jit->num_line_numbers - 1; i >= 0; i--) {
MonoDebugLineNumberEntry lne = jit->line_numbers [i];
if (lne.native_offset <= native_offset) {
free_method_jit_info (jit, TRUE);
return lne.il_offset;
}
}
cleanup_and_fail:
free_method_jit_info (jit, TRUE);
return -1;
}
/**
* mono_debug_il_offset_from_address:
*
* Compute the IL offset corresponding to \p native_offset inside the native
* code of \p method in \p domain.
*/
gint32
mono_debug_il_offset_from_address (MonoMethod *method, MonoDomain *domain, guint32 native_offset)
{
gint32 res;
mono_debugger_lock ();
res = il_offset_from_address (method, native_offset);
mono_debugger_unlock ();
return res;
}
/**
* mono_debug_lookup_source_location:
* \param address Native offset within the \p method's machine code.
* Lookup the source code corresponding to the machine instruction located at
* native offset \p address within \p method.
* The returned \c MonoDebugSourceLocation contains both file / line number
* information and the corresponding IL offset. It must be freed by
* \c mono_debug_free_source_location.
*/
MonoDebugSourceLocation *
mono_debug_lookup_source_location (MonoMethod *method, guint32 address, MonoDomain *domain)
{
MonoDebugMethodInfo *minfo;
MonoDebugSourceLocation *location;
gint32 offset;
if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
return NULL;
mono_debugger_lock ();
minfo = lookup_method (method);
if (!minfo || !minfo->handle) {
mono_debugger_unlock ();
return NULL;
}
if (!minfo->handle->ppdb && (!minfo->handle->symfile || !mono_debug_symfile_is_loaded (minfo->handle->symfile))) {
mono_debugger_unlock ();
return NULL;
}
offset = il_offset_from_address (method, address);
if (offset < 0) {
mono_debugger_unlock ();
return NULL;
}
if (minfo->handle->ppdb)
location = mono_ppdb_lookup_location (minfo, offset);
else
location = mono_debug_symfile_lookup_location (minfo, offset);
mono_debugger_unlock ();
return location;
}
/**
* mono_debug_lookup_source_location_by_il:
*
* Same as mono_debug_lookup_source_location but take an IL_OFFSET argument.
*/
MonoDebugSourceLocation *
mono_debug_lookup_source_location_by_il (MonoMethod *method, guint32 il_offset, MonoDomain *domain)
{
MonoDebugMethodInfo *minfo;
MonoDebugSourceLocation *location;
if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
return NULL;
mono_debugger_lock ();
minfo = lookup_method (method);
if (!minfo || !minfo->handle) {
mono_debugger_unlock ();
return NULL;
}
if (!minfo->handle->ppdb && (!minfo->handle->symfile || !mono_debug_symfile_is_loaded (minfo->handle->symfile))) {
mono_debugger_unlock ();
return NULL;
}
if (minfo->handle->ppdb)
location = mono_ppdb_lookup_location (minfo, il_offset);
else
location = mono_debug_symfile_lookup_location (minfo, il_offset);
mono_debugger_unlock ();
return location;
}
MonoDebugSourceLocation *
mono_debug_method_lookup_location (MonoDebugMethodInfo *minfo, int il_offset)
{
MonoImage* img = m_class_get_image (minfo->method->klass);
if (img->has_updates) {
int idx = mono_metadata_token_index (minfo->method->token);
MonoDebugInformationEnc *mdie = (MonoDebugInformationEnc *) mono_metadata_update_get_updated_method_ppdb (img, idx);
if (mdie != NULL) {
MonoDebugSourceLocation * ret = mono_ppdb_lookup_location_enc (mdie->ppdb_file, mdie->idx, il_offset);
if (ret)
return ret;
} else {
gboolean added_method = idx >= table_info_get_rows (&img->tables[MONO_TABLE_METHOD]);
if (added_method)
return NULL;
}
}
MonoDebugSourceLocation *location;
mono_debugger_lock ();
if (minfo->handle->ppdb)
location = mono_ppdb_lookup_location (minfo, il_offset);
else
location = mono_debug_symfile_lookup_location (minfo, il_offset);
mono_debugger_unlock ();
return location;
}
/*
* mono_debug_lookup_locals:
*
* Return information about the local variables of MINFO.
* The result should be freed using mono_debug_free_locals ().
*/
MonoDebugLocalsInfo*
mono_debug_lookup_locals (MonoMethod *method)
{
MonoDebugMethodInfo *minfo;
MonoDebugLocalsInfo *res;
MonoImage* img = m_class_get_image (method->klass);
if (img->has_updates) {
int idx = mono_metadata_token_index (method->token);
MonoDebugInformationEnc *mdie = (MonoDebugInformationEnc *) mono_metadata_update_get_updated_method_ppdb (img, idx);
if (mdie != NULL) {
res = mono_ppdb_lookup_locals_enc (mdie->ppdb_file->image, mdie->idx);
if (res != NULL)
return res;
}
}
if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
return NULL;
mono_debugger_lock ();
minfo = lookup_method (method);
if (!minfo || !minfo->handle) {
mono_debugger_unlock ();
return NULL;
}
if (minfo->handle->ppdb) {
res = mono_ppdb_lookup_locals (minfo);
} else {
if (!minfo->handle->symfile || !mono_debug_symfile_is_loaded (minfo->handle->symfile))
res = NULL;
else
res = mono_debug_symfile_lookup_locals (minfo);
}
mono_debugger_unlock ();
return res;
}
/*
* mono_debug_free_locals:
*
* Free all the data allocated by mono_debug_lookup_locals ().
*/
void
mono_debug_free_locals (MonoDebugLocalsInfo *info)
{
int i;
for (i = 0; i < info->num_locals; ++i)
g_free (info->locals [i].name);
g_free (info->locals);
g_free (info->code_blocks);
g_free (info);
}
/*
* mono_debug_lookup_method_async_debug_info:
*
* Return information about the async stepping information of method.
* The result should be freed using mono_debug_free_async_debug_info ().
*/
MonoDebugMethodAsyncInfo*
mono_debug_lookup_method_async_debug_info (MonoMethod *method)
{
MonoDebugMethodInfo *minfo;
MonoDebugMethodAsyncInfo *res = NULL;
if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
return NULL;
mono_debugger_lock ();
minfo = lookup_method (method);
if (!minfo || !minfo->handle) {
mono_debugger_unlock ();
return NULL;
}
if (minfo->handle->ppdb)
res = mono_ppdb_lookup_method_async_debug_info (minfo);
mono_debugger_unlock ();
return res;
}
/*
* mono_debug_free_method_async_debug_info:
*
* Free all the data allocated by mono_debug_lookup_method_async_debug_info ().
*/
void
mono_debug_free_method_async_debug_info (MonoDebugMethodAsyncInfo *info)
{
if (info->num_awaits) {
g_free (info->yield_offsets);
g_free (info->resume_offsets);
g_free (info->move_next_method_token);
}
g_free (info);
}
/**
* mono_debug_free_source_location:
* \param location A \c MonoDebugSourceLocation
* Frees the \p location.
*/
void
mono_debug_free_source_location (MonoDebugSourceLocation *location)
{
if (location) {
g_free (location->source_file);
g_free (location);
}
}
static int (*get_seq_point) (MonoMethod *method, gint32 native_offset);
void
mono_install_get_seq_point (MonoGetSeqPointFunc func)
{
get_seq_point = func;
}
/**
* mono_debug_print_stack_frame:
* \param native_offset Native offset within the \p method's machine code.
* Conventient wrapper around \c mono_debug_lookup_source_location which can be
* used if you only want to use the location to print a stack frame.
*/
gchar *
mono_debug_print_stack_frame (MonoMethod *method, guint32 native_offset, MonoDomain *domain)
{
MonoDebugSourceLocation *location;
gchar *fname, *ptr, *res;
int offset;
fname = mono_method_full_name (method, TRUE);
for (ptr = fname; *ptr; ptr++) {
if (*ptr == ':') *ptr = '.';
}
location = mono_debug_lookup_source_location (method, native_offset, NULL);
if (!location) {
if (mono_debug_initialized) {
mono_debugger_lock ();
offset = il_offset_from_address (method, native_offset);
mono_debugger_unlock ();
} else {
offset = -1;
}
if (offset < 0 && get_seq_point)
offset = get_seq_point (method, native_offset);
if (offset < 0)
res = g_strdup_printf ("at %s <0x%05x>", fname, native_offset);
else {
char *mvid = mono_guid_to_string_minimal ((uint8_t*)m_class_get_image (method->klass)->heap_guid.data);
char *aotid = mono_runtime_get_aotid ();
if (aotid)
res = g_strdup_printf ("at %s [0x%05x] in <%s#%s>:0" , fname, offset, mvid, aotid);
else
res = g_strdup_printf ("at %s [0x%05x] in <%s>:0" , fname, offset, mvid);
g_free (aotid);
g_free (mvid);
}
g_free (fname);
return res;
}
res = g_strdup_printf ("at %s [0x%05x] in %s:%d", fname, location->il_offset,
location->source_file, location->row);
g_free (fname);
mono_debug_free_source_location (location);
return res;
}
void
mono_set_is_debugger_attached (gboolean attached)
{
is_attached = attached;
}
gboolean
mono_is_debugger_attached (void)
{
return is_attached;
}
/*
* Bundles
*/
typedef struct _BundledSymfile BundledSymfile;
struct _BundledSymfile {
BundledSymfile *next;
const char *aname;
const mono_byte *raw_contents;
int size;
};
static BundledSymfile *bundled_symfiles = NULL;
/**
* mono_register_symfile_for_assembly:
*/
void
mono_register_symfile_for_assembly (const char *assembly_name, const mono_byte *raw_contents, int size)
{
BundledSymfile *bsymfile;
bsymfile = g_new0 (BundledSymfile, 1);
bsymfile->aname = assembly_name;
bsymfile->raw_contents = raw_contents;
bsymfile->size = size;
bsymfile->next = bundled_symfiles;
bundled_symfiles = bsymfile;
}
static MonoDebugHandle *
open_symfile_from_bundle (MonoImage *image)
{
BundledSymfile *bsymfile;
for (bsymfile = bundled_symfiles; bsymfile; bsymfile = bsymfile->next) {
if (strcmp (bsymfile->aname, image->module_name))
continue;
return mono_debug_open_image (image, bsymfile->raw_contents, bsymfile->size);
}
return NULL;
}
void
mono_debugger_lock (void)
{
g_assert (mono_debug_initialized);
mono_os_mutex_lock (&debugger_lock_mutex);
}
void
mono_debugger_unlock (void)
{
g_assert (mono_debug_initialized);
mono_os_mutex_unlock (&debugger_lock_mutex);
}
/**
* mono_debug_enabled:
*
* Returns true is debug information is enabled. This doesn't relate if a debugger is present or not.
*/
mono_bool
mono_debug_enabled (void)
{
return mono_debug_format != MONO_DEBUG_FORMAT_NONE;
}
void
mono_debug_get_seq_points (MonoDebugMethodInfo *minfo, char **source_file, GPtrArray **source_file_list, int **source_files, MonoSymSeqPoint **seq_points, int *n_seq_points)
{
MonoImage* img = m_class_get_image (minfo->method->klass);
if (img->has_updates) {
int idx = mono_metadata_token_index (minfo->method->token);
MonoDebugInformationEnc *mdie = (MonoDebugInformationEnc *) mono_metadata_update_get_updated_method_ppdb (img, idx);
if (mdie != NULL) {
if (mono_ppdb_get_seq_points_enc (minfo, mdie->ppdb_file, mdie->idx, source_file, source_file_list, source_files, seq_points, n_seq_points))
return;
}
/*
* dotnet watch sometimes sends us updated with PPDB deltas, but the baseline
* project has debug info (and we use it for seq points?). In tht case, just say
* the added method has no sequence points. N.B. intentionally, comparing idx to
* the baseline tables. For methods that already existed, use their old seq points.
*/
if (idx >= table_info_get_rows (&img->tables[MONO_TABLE_METHOD])) {
if (source_file)
*source_file = NULL;
if (source_file_list)
*source_file_list = NULL;
if (source_files)
*source_files = NULL;
if (seq_points)
*seq_points = NULL;
if (n_seq_points)
*n_seq_points = 0;
return;
}
}
if (minfo->handle->ppdb)
mono_ppdb_get_seq_points (minfo, source_file, source_file_list, source_files, seq_points, n_seq_points);
else
mono_debug_symfile_get_seq_points (minfo, source_file, source_file_list, source_files, seq_points, n_seq_points);
}
char*
mono_debug_image_get_sourcelink (MonoImage *image)
{
MonoDebugHandle *handle = mono_debug_get_handle (image);
if (handle && handle->ppdb)
return mono_ppdb_get_sourcelink (handle);
else
return NULL;
}
| /**
* \file
*
* Author:
* Mono Project (http://www.mono-project.com)
*
* Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
* Copyright 2004-2009 Novell, Inc (http://www.novell.com)
* Copyright 2011 Xamarin Inc (http://www.xamarin.com)
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/assembly-internals.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/tokentype.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/debug-internals.h>
#include <mono/metadata/mono-endian.h>
#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mempool.h>
#include <mono/metadata/debug-mono-symfile.h>
#include <mono/metadata/debug-mono-ppdb.h>
#include <mono/metadata/exception-internals.h>
#include <mono/metadata/runtime.h>
#include <mono/metadata/metadata-update.h>
#include <string.h>
#if NO_UNALIGNED_ACCESS
#define WRITE_UNALIGNED(type, addr, val) \
memcpy(addr, &val, sizeof(type))
#define READ_UNALIGNED(type, addr, val) \
memcpy(&val, addr, sizeof(type))
#else
#define WRITE_UNALIGNED(type, addr, val) \
(*(type *)(addr) = (val))
#define READ_UNALIGNED(type, addr, val) \
val = (*(type *)(addr))
#endif
/* Many functions have 'domain' parameters, those are ignored */
/*
* This contains per-memory manager info.
*/
typedef struct {
MonoMemPool *mp;
/* Maps MonoMethod->MonoDebugMethodAddress */
GHashTable *method_hash;
} DebugMemoryManager;
/* This contains JIT debugging information about a method in serialized format */
struct _MonoDebugMethodAddress {
const guint8 *code_start;
guint32 code_size;
guint8 data [MONO_ZERO_LEN_ARRAY];
};
static MonoDebugFormat mono_debug_format = MONO_DEBUG_FORMAT_NONE;
static gboolean mono_debug_initialized = FALSE;
/* Maps MonoImage -> MonoMonoDebugHandle */
static GHashTable *mono_debug_handles;
static mono_mutex_t debugger_lock_mutex;
static gboolean is_attached = FALSE;
static MonoDebugHandle *mono_debug_open_image (MonoImage *image, const guint8 *raw_contents, int size);
static MonoDebugHandle *mono_debug_get_image (MonoImage *image);
static void add_assembly (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer user_data, MonoError *error);
static MonoDebugHandle *open_symfile_from_bundle (MonoImage *image);
static DebugMemoryManager*
get_mem_manager (MonoMethod *method)
{
MonoMemoryManager *mem_manager = m_method_get_mem_manager (method);
if (!mono_debug_initialized)
return NULL;
if (!mem_manager->debug_info) {
DebugMemoryManager *info;
info = g_new0 (DebugMemoryManager, 1);
info->mp = mono_mempool_new ();
info->method_hash = g_hash_table_new (NULL, NULL);
mono_memory_barrier ();
mono_debugger_lock ();
if (!mem_manager->debug_info)
mem_manager->debug_info = info;
// FIXME: Free otherwise
mono_debugger_unlock ();
}
return (DebugMemoryManager*)mem_manager->debug_info;
}
/*
* mono_mem_manager_free_debug_info:
*
* Free the information maintained by this module for MEM_MANAGER.
*/
void
mono_mem_manager_free_debug_info (MonoMemoryManager *memory_manager)
{
DebugMemoryManager *info = (DebugMemoryManager*)memory_manager->debug_info;
if (!info)
return;
mono_mempool_destroy (info->mp);
g_hash_table_destroy (info->method_hash);
g_free (info);
}
static void
free_debug_handle (MonoDebugHandle *handle)
{
if (handle->ppdb)
mono_ppdb_close (handle->ppdb);
if (handle->symfile)
mono_debug_close_mono_symbol_file (handle->symfile);
/* decrease the refcount added with mono_image_addref () */
mono_image_close (handle->image);
g_free (handle);
}
/*
* Initialize debugging support.
*
* This method must be called after loading corlib,
* but before opening the application's main assembly because we need to set some
* callbacks here.
*/
void
mono_debug_init (MonoDebugFormat format)
{
g_assert (!mono_debug_initialized);
if (format == MONO_DEBUG_FORMAT_DEBUGGER)
g_error ("The mdb debugger is no longer supported.");
mono_debug_initialized = TRUE;
mono_debug_format = format;
mono_os_mutex_init_recursive (&debugger_lock_mutex);
mono_debugger_lock ();
mono_debug_handles = g_hash_table_new_full
(NULL, NULL, NULL, (GDestroyNotify) free_debug_handle);
mono_install_assembly_load_hook_v2 (add_assembly, NULL, FALSE);
mono_debugger_unlock ();
}
void
mono_debug_open_image_from_memory (MonoImage *image, const guint8 *raw_contents, int size)
{
MONO_ENTER_GC_UNSAFE;
if (!mono_debug_initialized)
goto leave;
mono_debug_open_image (image, raw_contents, size);
leave:
MONO_EXIT_GC_UNSAFE;
}
void
mono_debug_cleanup (void)
{
}
/**
* mono_debug_domain_create:
*/
void
mono_debug_domain_create (MonoDomain *domain)
{
g_assert_not_reached ();
}
void
mono_debug_domain_unload (MonoDomain *domain)
{
g_assert_not_reached ();
}
/*
* LOCKING: Assumes the debug lock is held.
*/
static MonoDebugHandle *
mono_debug_get_image (MonoImage *image)
{
return (MonoDebugHandle *)g_hash_table_lookup (mono_debug_handles, image);
}
/**
* mono_debug_close_image:
*/
void
mono_debug_close_image (MonoImage *image)
{
MonoDebugHandle *handle;
if (!mono_debug_initialized)
return;
mono_debugger_lock ();
handle = mono_debug_get_image (image);
if (!handle) {
mono_debugger_unlock ();
return;
}
g_hash_table_remove (mono_debug_handles, image);
mono_debugger_unlock ();
}
MonoDebugHandle *
mono_debug_get_handle (MonoImage *image)
{
return mono_debug_open_image (image, NULL, 0);
}
static MonoDebugHandle *
mono_debug_open_image (MonoImage *image, const guint8 *raw_contents, int size)
{
MonoDebugHandle *handle;
if (mono_image_is_dynamic (image))
return NULL;
mono_debugger_lock ();
handle = mono_debug_get_image (image);
if (handle != NULL) {
mono_debugger_unlock ();
return handle;
}
handle = g_new0 (MonoDebugHandle, 1);
handle->image = image;
mono_image_addref (image);
/* Try a ppdb file first */
handle->ppdb = mono_ppdb_load_file (handle->image, raw_contents, size);
if (!handle->ppdb)
handle->symfile = mono_debug_open_mono_symbols (handle, raw_contents, size, FALSE);
g_hash_table_insert (mono_debug_handles, image, handle);
mono_debugger_unlock ();
return handle;
}
static void
add_assembly (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer user_data, MonoError *error)
{
MonoDebugHandle *handle;
MonoImage *image;
mono_debugger_lock ();
image = mono_assembly_get_image_internal (assembly);
handle = open_symfile_from_bundle (image);
if (!handle)
mono_debug_open_image (image, NULL, 0);
mono_debugger_unlock ();
}
struct LookupMethodData
{
MonoDebugMethodInfo *minfo;
MonoMethod *method;
};
static void
lookup_method_func (gpointer key, gpointer value, gpointer user_data)
{
MonoDebugHandle *handle = (MonoDebugHandle *) value;
struct LookupMethodData *data = (struct LookupMethodData *) user_data;
if (data->minfo)
return;
if (handle->ppdb)
data->minfo = mono_ppdb_lookup_method (handle, data->method);
else if (handle->symfile)
data->minfo = mono_debug_symfile_lookup_method (handle, data->method);
}
static MonoDebugMethodInfo *
lookup_method (MonoMethod *method)
{
struct LookupMethodData data;
data.minfo = NULL;
data.method = method;
if (!mono_debug_handles)
return NULL;
g_hash_table_foreach (mono_debug_handles, lookup_method_func, &data);
return data.minfo;
}
/**
* mono_debug_lookup_method:
*
* Lookup symbol file information for the method \p method. The returned
* \c MonoDebugMethodInfo is a private structure, but it can be passed to
* \c mono_debug_symfile_lookup_location.
*/
MonoDebugMethodInfo *
mono_debug_lookup_method (MonoMethod *method)
{
MonoDebugMethodInfo *minfo;
if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
return NULL;
mono_debugger_lock ();
minfo = lookup_method (method);
mono_debugger_unlock ();
return minfo;
}
typedef struct
{
gboolean found;
MonoImage *image;
} LookupImageData;
static void
lookup_image_func (gpointer key, gpointer value, gpointer user_data)
{
MonoDebugHandle *handle = (MonoDebugHandle *) value;
LookupImageData *data = (LookupImageData *) user_data;
if (data->found)
return;
if (handle->image == data->image && (handle->symfile || handle->ppdb))
data->found = TRUE;
}
gboolean
mono_debug_image_has_debug_info (MonoImage *image)
{
LookupImageData data;
if (!mono_debug_handles)
return FALSE;
memset (&data, 0, sizeof (data));
data.image = image;
mono_debugger_lock ();
g_hash_table_foreach (mono_debug_handles, lookup_image_func, &data);
mono_debugger_unlock ();
return data.found;
}
static void
write_leb128 (guint32 value, guint8 *ptr, guint8 **rptr)
{
do {
guint8 byte = value & 0x7f;
value >>= 7;
if (value)
byte |= 0x80;
*ptr++ = byte;
} while (value);
*rptr = ptr;
}
static void
write_sleb128 (gint32 value, guint8 *ptr, guint8 **rptr)
{
gboolean more = 1;
while (more) {
guint8 byte = value & 0x7f;
value >>= 7;
if (((value == 0) && ((byte & 0x40) == 0)) || ((value == -1) && (byte & 0x40)))
more = 0;
else
byte |= 0x80;
*ptr++ = byte;
}
*rptr = ptr;
}
/* leb128 uses a maximum of 5 bytes for a 32 bit value */
#define LEB128_MAX_SIZE 5
#define WRITE_VARIABLE_MAX_SIZE (5 * LEB128_MAX_SIZE + sizeof (gpointer))
static void
write_variable (MonoDebugVarInfo *var, guint8 *ptr, guint8 **rptr)
{
write_leb128 (var->index, ptr, &ptr);
write_sleb128 (var->offset, ptr, &ptr);
write_leb128 (var->size, ptr, &ptr);
write_leb128 (var->begin_scope, ptr, &ptr);
write_leb128 (var->end_scope, ptr, &ptr);
WRITE_UNALIGNED (gpointer, ptr, var->type);
ptr += sizeof (gpointer);
*rptr = ptr;
}
/**
* mono_debug_add_method:
*/
MonoDebugMethodAddress *
mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDomain *domain)
{
DebugMemoryManager *info;
MonoDebugMethodAddress *address;
guint8 buffer [BUFSIZ];
guint8 *ptr, *oldptr;
guint32 i, size, total_size, max_size;
info = get_mem_manager (method);
max_size = (5 * LEB128_MAX_SIZE) + 1 + (2 * LEB128_MAX_SIZE * jit->num_line_numbers);
if (jit->has_var_info) {
/* this */
max_size += 1;
if (jit->this_var)
max_size += WRITE_VARIABLE_MAX_SIZE;
/* params */
max_size += LEB128_MAX_SIZE;
max_size += jit->num_params * WRITE_VARIABLE_MAX_SIZE;
/* locals */
max_size += LEB128_MAX_SIZE;
max_size += jit->num_locals * WRITE_VARIABLE_MAX_SIZE;
/* gsharedvt */
max_size += 1;
if (jit->gsharedvt_info_var)
max_size += 2 * WRITE_VARIABLE_MAX_SIZE;
}
if (max_size > BUFSIZ)
ptr = oldptr = (guint8 *)g_malloc (max_size);
else
ptr = oldptr = buffer;
write_leb128 (jit->prologue_end, ptr, &ptr);
write_leb128 (jit->epilogue_begin, ptr, &ptr);
write_leb128 (jit->num_line_numbers, ptr, &ptr);
for (i = 0; i < jit->num_line_numbers; i++) {
MonoDebugLineNumberEntry *lne = &jit->line_numbers [i];
write_sleb128 (lne->il_offset, ptr, &ptr);
write_sleb128 (lne->native_offset, ptr, &ptr);
}
write_leb128 (jit->has_var_info, ptr, &ptr);
if (jit->has_var_info) {
*ptr++ = jit->this_var ? 1 : 0;
if (jit->this_var)
write_variable (jit->this_var, ptr, &ptr);
write_leb128 (jit->num_params, ptr, &ptr);
for (i = 0; i < jit->num_params; i++)
write_variable (&jit->params [i], ptr, &ptr);
write_leb128 (jit->num_locals, ptr, &ptr);
for (i = 0; i < jit->num_locals; i++)
write_variable (&jit->locals [i], ptr, &ptr);
*ptr++ = jit->gsharedvt_info_var ? 1 : 0;
if (jit->gsharedvt_info_var) {
write_variable (jit->gsharedvt_info_var, ptr, &ptr);
write_variable (jit->gsharedvt_locals_var, ptr, &ptr);
}
}
size = ptr - oldptr;
g_assert (size < max_size);
total_size = size + sizeof (MonoDebugMethodAddress);
mono_debugger_lock ();
if (method_is_dynamic (method)) {
address = (MonoDebugMethodAddress *)g_malloc0 (total_size);
} else {
address = (MonoDebugMethodAddress *)mono_mempool_alloc (info->mp, total_size);
}
address->code_start = jit->code_start;
address->code_size = jit->code_size;
memcpy (&address->data, oldptr, size);
if (max_size > BUFSIZ)
g_free (oldptr);
g_hash_table_insert (info->method_hash, method, address);
mono_debugger_unlock ();
return address;
}
void
mono_debug_remove_method (MonoMethod *method, MonoDomain *domain)
{
DebugMemoryManager *info;
MonoDebugMethodAddress *address;
if (!mono_debug_initialized)
return;
g_assert (method_is_dynamic (method));
info = get_mem_manager (method);
mono_debugger_lock ();
address = (MonoDebugMethodAddress *)g_hash_table_lookup (info->method_hash, method);
if (address)
g_free (address);
g_hash_table_remove (info->method_hash, method);
mono_debugger_unlock ();
}
/**
* mono_debug_add_delegate_trampoline:
*/
void
mono_debug_add_delegate_trampoline (gpointer code, int size)
{
}
static guint32
read_leb128 (guint8 *ptr, guint8 **rptr)
{
guint32 result = 0, shift = 0;
while (TRUE) {
guint8 byte = *ptr++;
result |= (byte & 0x7f) << shift;
if ((byte & 0x80) == 0)
break;
shift += 7;
}
*rptr = ptr;
return result;
}
static gint32
read_sleb128 (guint8 *ptr, guint8 **rptr)
{
gint32 result = 0;
guint32 shift = 0;
while (TRUE) {
guint8 byte = *ptr++;
result |= (byte & 0x7f) << shift;
shift += 7;
if (byte & 0x80)
continue;
if ((shift < 32) && (byte & 0x40))
result |= - (1 << shift);
break;
}
*rptr = ptr;
return result;
}
static void
read_variable (MonoDebugVarInfo *var, guint8 *ptr, guint8 **rptr)
{
var->index = read_leb128 (ptr, &ptr);
var->offset = read_sleb128 (ptr, &ptr);
var->size = read_leb128 (ptr, &ptr);
var->begin_scope = read_leb128 (ptr, &ptr);
var->end_scope = read_leb128 (ptr, &ptr);
READ_UNALIGNED (MonoType *, ptr, var->type);
ptr += sizeof (gpointer);
*rptr = ptr;
}
static void
free_method_jit_info (MonoDebugMethodJitInfo *jit, gboolean stack)
{
if (!jit)
return;
g_free (jit->line_numbers);
g_free (jit->this_var);
g_free (jit->params);
g_free (jit->locals);
g_free (jit->gsharedvt_info_var);
g_free (jit->gsharedvt_locals_var);
if (!stack)
g_free (jit);
}
void
mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit)
{
free_method_jit_info (jit, FALSE);
}
static MonoDebugMethodJitInfo *
mono_debug_read_method (MonoDebugMethodAddress *address, MonoDebugMethodJitInfo *jit)
{
guint32 i;
guint8 *ptr;
memset (jit, 0, sizeof (*jit));
jit->code_start = address->code_start;
jit->code_size = address->code_size;
ptr = (guint8 *) &address->data;
jit->prologue_end = read_leb128 (ptr, &ptr);
jit->epilogue_begin = read_leb128 (ptr, &ptr);
jit->num_line_numbers = read_leb128 (ptr, &ptr);
jit->line_numbers = g_new0 (MonoDebugLineNumberEntry, jit->num_line_numbers);
for (i = 0; i < jit->num_line_numbers; i++) {
MonoDebugLineNumberEntry *lne = &jit->line_numbers [i];
lne->il_offset = read_sleb128 (ptr, &ptr);
lne->native_offset = read_sleb128 (ptr, &ptr);
}
jit->has_var_info = read_leb128 (ptr, &ptr);
if (jit->has_var_info) {
if (*ptr++) {
jit->this_var = g_new0 (MonoDebugVarInfo, 1);
read_variable (jit->this_var, ptr, &ptr);
}
jit->num_params = read_leb128 (ptr, &ptr);
jit->params = g_new0 (MonoDebugVarInfo, jit->num_params);
for (i = 0; i < jit->num_params; i++)
read_variable (&jit->params [i], ptr, &ptr);
jit->num_locals = read_leb128 (ptr, &ptr);
jit->locals = g_new0 (MonoDebugVarInfo, jit->num_locals);
for (i = 0; i < jit->num_locals; i++)
read_variable (&jit->locals [i], ptr, &ptr);
if (*ptr++) {
jit->gsharedvt_info_var = g_new0 (MonoDebugVarInfo, 1);
jit->gsharedvt_locals_var = g_new0 (MonoDebugVarInfo, 1);
read_variable (jit->gsharedvt_info_var, ptr, &ptr);
read_variable (jit->gsharedvt_locals_var, ptr, &ptr);
}
}
return jit;
}
static MonoDebugMethodJitInfo *
find_method (MonoMethod *method, MonoDebugMethodJitInfo *jit)
{
DebugMemoryManager *info;
MonoDebugMethodAddress *address;
info = get_mem_manager (method);
address = (MonoDebugMethodAddress *)g_hash_table_lookup (info->method_hash, method);
if (!address)
return NULL;
return mono_debug_read_method (address, jit);
}
MonoDebugMethodJitInfo *
mono_debug_find_method (MonoMethod *method, MonoDomain *domain)
{
if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
return NULL;
MonoDebugMethodJitInfo *res = g_new0 (MonoDebugMethodJitInfo, 1);
mono_debugger_lock ();
find_method (method, res);
mono_debugger_unlock ();
return res;
}
MonoDebugMethodAddressList *
mono_debug_lookup_method_addresses (MonoMethod *method)
{
g_assert_not_reached ();
return NULL;
}
static gint32
il_offset_from_address (MonoMethod *method, guint32 native_offset)
{
MonoDebugMethodJitInfo mem;
int i;
MonoDebugMethodJitInfo *jit = find_method (method, &mem);
if (!jit || !jit->line_numbers)
goto cleanup_and_fail;
for (i = jit->num_line_numbers - 1; i >= 0; i--) {
MonoDebugLineNumberEntry lne = jit->line_numbers [i];
if (lne.native_offset <= native_offset) {
free_method_jit_info (jit, TRUE);
return lne.il_offset;
}
}
cleanup_and_fail:
free_method_jit_info (jit, TRUE);
return -1;
}
/**
* mono_debug_il_offset_from_address:
*
* Compute the IL offset corresponding to \p native_offset inside the native
* code of \p method in \p domain.
*/
gint32
mono_debug_il_offset_from_address (MonoMethod *method, MonoDomain *domain, guint32 native_offset)
{
gint32 res;
mono_debugger_lock ();
res = il_offset_from_address (method, native_offset);
mono_debugger_unlock ();
return res;
}
/**
* mono_debug_lookup_source_location:
* \param address Native offset within the \p method's machine code.
* Lookup the source code corresponding to the machine instruction located at
* native offset \p address within \p method.
* The returned \c MonoDebugSourceLocation contains both file / line number
* information and the corresponding IL offset. It must be freed by
* \c mono_debug_free_source_location.
*/
MonoDebugSourceLocation *
mono_debug_lookup_source_location (MonoMethod *method, guint32 address, MonoDomain *domain)
{
MonoDebugMethodInfo *minfo;
MonoDebugSourceLocation *location;
gint32 offset;
if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
return NULL;
mono_debugger_lock ();
minfo = lookup_method (method);
if (!minfo || !minfo->handle) {
mono_debugger_unlock ();
return NULL;
}
if (!minfo->handle->ppdb && (!minfo->handle->symfile || !mono_debug_symfile_is_loaded (minfo->handle->symfile))) {
mono_debugger_unlock ();
return NULL;
}
offset = il_offset_from_address (method, address);
if (offset < 0) {
mono_debugger_unlock ();
return NULL;
}
if (minfo->handle->ppdb)
location = mono_ppdb_lookup_location (minfo, offset);
else
location = mono_debug_symfile_lookup_location (minfo, offset);
mono_debugger_unlock ();
return location;
}
/**
* mono_debug_lookup_source_location_by_il:
*
* Same as mono_debug_lookup_source_location but take an IL_OFFSET argument.
*/
MonoDebugSourceLocation *
mono_debug_lookup_source_location_by_il (MonoMethod *method, guint32 il_offset, MonoDomain *domain)
{
MonoDebugMethodInfo *minfo;
MonoDebugSourceLocation *location;
if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
return NULL;
mono_debugger_lock ();
minfo = lookup_method (method);
if (!minfo || !minfo->handle) {
mono_debugger_unlock ();
return NULL;
}
if (!minfo->handle->ppdb && (!minfo->handle->symfile || !mono_debug_symfile_is_loaded (minfo->handle->symfile))) {
mono_debugger_unlock ();
return NULL;
}
if (minfo->handle->ppdb)
location = mono_ppdb_lookup_location (minfo, il_offset);
else
location = mono_debug_symfile_lookup_location (minfo, il_offset);
mono_debugger_unlock ();
return location;
}
MonoDebugSourceLocation *
mono_debug_method_lookup_location (MonoDebugMethodInfo *minfo, int il_offset)
{
MonoImage* img = m_class_get_image (minfo->method->klass);
if (img->has_updates) {
int idx = mono_metadata_token_index (minfo->method->token);
MonoDebugInformationEnc *mdie = (MonoDebugInformationEnc *) mono_metadata_update_get_updated_method_ppdb (img, idx);
if (mdie != NULL) {
MonoDebugSourceLocation * ret = mono_ppdb_lookup_location_enc (mdie->ppdb_file, mdie->idx, il_offset);
if (ret)
return ret;
} else {
gboolean added_method = idx >= table_info_get_rows (&img->tables[MONO_TABLE_METHOD]);
if (added_method)
return NULL;
}
}
MonoDebugSourceLocation *location;
mono_debugger_lock ();
if (minfo->handle->ppdb)
location = mono_ppdb_lookup_location (minfo, il_offset);
else
location = mono_debug_symfile_lookup_location (minfo, il_offset);
mono_debugger_unlock ();
return location;
}
/*
* mono_debug_lookup_locals:
*
* Return information about the local variables of MINFO.
* The result should be freed using mono_debug_free_locals ().
*/
MonoDebugLocalsInfo*
mono_debug_lookup_locals (MonoMethod *method)
{
MonoDebugMethodInfo *minfo;
MonoDebugLocalsInfo *res;
MonoImage* img = m_class_get_image (method->klass);
if (img->has_updates) {
int idx = mono_metadata_token_index (method->token);
MonoDebugInformationEnc *mdie = (MonoDebugInformationEnc *) mono_metadata_update_get_updated_method_ppdb (img, idx);
if (mdie != NULL) {
res = mono_ppdb_lookup_locals_enc (mdie->ppdb_file->image, mdie->idx);
if (res != NULL)
return res;
}
}
if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
return NULL;
mono_debugger_lock ();
minfo = lookup_method (method);
if (!minfo || !minfo->handle) {
mono_debugger_unlock ();
return NULL;
}
if (minfo->handle->ppdb) {
res = mono_ppdb_lookup_locals (minfo);
} else {
if (!minfo->handle->symfile || !mono_debug_symfile_is_loaded (minfo->handle->symfile))
res = NULL;
else
res = mono_debug_symfile_lookup_locals (minfo);
}
mono_debugger_unlock ();
return res;
}
/*
* mono_debug_free_locals:
*
* Free all the data allocated by mono_debug_lookup_locals ().
*/
void
mono_debug_free_locals (MonoDebugLocalsInfo *info)
{
int i;
for (i = 0; i < info->num_locals; ++i)
g_free (info->locals [i].name);
g_free (info->locals);
g_free (info->code_blocks);
g_free (info);
}
/*
* mono_debug_lookup_method_async_debug_info:
*
* Return information about the async stepping information of method.
* The result should be freed using mono_debug_free_async_debug_info ().
*/
MonoDebugMethodAsyncInfo*
mono_debug_lookup_method_async_debug_info (MonoMethod *method)
{
MonoDebugMethodInfo *minfo;
MonoDebugMethodAsyncInfo *res = NULL;
if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
return NULL;
mono_debugger_lock ();
minfo = lookup_method (method);
if (!minfo || !minfo->handle) {
mono_debugger_unlock ();
return NULL;
}
if (minfo->handle->ppdb)
res = mono_ppdb_lookup_method_async_debug_info (minfo);
mono_debugger_unlock ();
return res;
}
/*
* mono_debug_free_method_async_debug_info:
*
* Free all the data allocated by mono_debug_lookup_method_async_debug_info ().
*/
void
mono_debug_free_method_async_debug_info (MonoDebugMethodAsyncInfo *info)
{
if (info->num_awaits) {
g_free (info->yield_offsets);
g_free (info->resume_offsets);
g_free (info->move_next_method_token);
}
g_free (info);
}
/**
* mono_debug_free_source_location:
* \param location A \c MonoDebugSourceLocation
* Frees the \p location.
*/
void
mono_debug_free_source_location (MonoDebugSourceLocation *location)
{
if (location) {
g_free (location->source_file);
g_free (location);
}
}
static int (*get_seq_point) (MonoMethod *method, gint32 native_offset);
void
mono_install_get_seq_point (MonoGetSeqPointFunc func)
{
get_seq_point = func;
}
/**
* mono_debug_print_stack_frame:
* \param native_offset Native offset within the \p method's machine code.
* Conventient wrapper around \c mono_debug_lookup_source_location which can be
* used if you only want to use the location to print a stack frame.
*/
gchar *
mono_debug_print_stack_frame (MonoMethod *method, guint32 native_offset, MonoDomain *domain)
{
MonoDebugSourceLocation *location;
gchar *fname, *ptr, *res;
int offset;
fname = mono_method_full_name (method, TRUE);
for (ptr = fname; *ptr; ptr++) {
if (*ptr == ':') *ptr = '.';
}
location = mono_debug_lookup_source_location (method, native_offset, NULL);
if (!location) {
if (mono_debug_initialized) {
mono_debugger_lock ();
offset = il_offset_from_address (method, native_offset);
mono_debugger_unlock ();
} else {
offset = -1;
}
if (offset < 0 && get_seq_point)
offset = get_seq_point (method, native_offset);
if (offset < 0)
res = g_strdup_printf ("at %s <0x%05x>", fname, native_offset);
else {
char *mvid = mono_guid_to_string_minimal ((uint8_t*)m_class_get_image (method->klass)->heap_guid.data);
char *aotid = mono_runtime_get_aotid ();
if (aotid)
res = g_strdup_printf ("at %s [0x%05x] in <%s#%s>:0" , fname, offset, mvid, aotid);
else
res = g_strdup_printf ("at %s [0x%05x] in <%s>:0" , fname, offset, mvid);
g_free (aotid);
g_free (mvid);
}
g_free (fname);
return res;
}
res = g_strdup_printf ("at %s [0x%05x] in %s:%d", fname, location->il_offset,
location->source_file, location->row);
g_free (fname);
mono_debug_free_source_location (location);
return res;
}
void
mono_set_is_debugger_attached (gboolean attached)
{
is_attached = attached;
}
gboolean
mono_is_debugger_attached (void)
{
return is_attached;
}
/*
* Bundles
*/
typedef struct _BundledSymfile BundledSymfile;
struct _BundledSymfile {
BundledSymfile *next;
const char *aname;
const mono_byte *raw_contents;
int size;
};
static BundledSymfile *bundled_symfiles = NULL;
/**
* mono_register_symfile_for_assembly:
*/
void
mono_register_symfile_for_assembly (const char *assembly_name, const mono_byte *raw_contents, int size)
{
BundledSymfile *bsymfile;
bsymfile = g_new0 (BundledSymfile, 1);
bsymfile->aname = assembly_name;
bsymfile->raw_contents = raw_contents;
bsymfile->size = size;
bsymfile->next = bundled_symfiles;
bundled_symfiles = bsymfile;
}
static MonoDebugHandle *
open_symfile_from_bundle (MonoImage *image)
{
BundledSymfile *bsymfile;
for (bsymfile = bundled_symfiles; bsymfile; bsymfile = bsymfile->next) {
if (strcmp (bsymfile->aname, image->module_name))
continue;
return mono_debug_open_image (image, bsymfile->raw_contents, bsymfile->size);
}
return NULL;
}
void
mono_debugger_lock (void)
{
g_assert (mono_debug_initialized);
mono_os_mutex_lock (&debugger_lock_mutex);
}
void
mono_debugger_unlock (void)
{
g_assert (mono_debug_initialized);
mono_os_mutex_unlock (&debugger_lock_mutex);
}
/**
* mono_debug_enabled:
*
* Returns true is debug information is enabled. This doesn't relate if a debugger is present or not.
*/
mono_bool
mono_debug_enabled (void)
{
return mono_debug_format != MONO_DEBUG_FORMAT_NONE;
}
void
mono_debug_get_seq_points (MonoDebugMethodInfo *minfo, char **source_file, GPtrArray **source_file_list, int **source_files, MonoSymSeqPoint **seq_points, int *n_seq_points)
{
MonoImage* img = m_class_get_image (minfo->method->klass);
if (img->has_updates) {
int idx = mono_metadata_token_index (minfo->method->token);
MonoDebugInformationEnc *mdie = (MonoDebugInformationEnc *) mono_metadata_update_get_updated_method_ppdb (img, idx);
if (mdie != NULL) {
if (mono_ppdb_get_seq_points_enc (minfo, mdie->ppdb_file, mdie->idx, source_file, source_file_list, source_files, seq_points, n_seq_points))
return;
}
/*
* dotnet watch sometimes sends us updated with PPDB deltas, but the baseline
* project has debug info (and we use it for seq points?). In tht case, just say
* the added method has no sequence points. N.B. intentionally, comparing idx to
* the baseline tables. For methods that already existed, use their old seq points.
*/
if (idx >= table_info_get_rows (&img->tables[MONO_TABLE_METHOD])) {
if (source_file)
*source_file = NULL;
if (source_file_list)
*source_file_list = NULL;
if (source_files)
*source_files = NULL;
if (seq_points)
*seq_points = NULL;
if (n_seq_points)
*n_seq_points = 0;
return;
}
}
if (minfo->handle->ppdb)
mono_ppdb_get_seq_points (minfo, source_file, source_file_list, source_files, seq_points, n_seq_points);
else
mono_debug_symfile_get_seq_points (minfo, source_file, source_file_list, source_files, seq_points, n_seq_points);
}
char*
mono_debug_image_get_sourcelink (MonoImage *image)
{
MonoDebugHandle *handle = mono_debug_get_handle (image);
if (handle && handle->ppdb)
return mono_ppdb_get_sourcelink (handle);
else
return NULL;
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/dwarf/Gfind_unwind_table.c | /* libunwind - a platform-independent unwind library
Copyright (C) 2003-2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include "libunwind_i.h"
#include "dwarf-eh.h"
#include "dwarf_i.h"
#define to_unw_word(p) ((unw_word_t) (uintptr_t) (p))
int
dwarf_find_unwind_table (struct elf_dyn_info *edi, unw_addr_space_t as,
char *path, unw_word_t segbase, unw_word_t mapoff,
unw_word_t ip)
{
Elf_W(Phdr) *phdr, *ptxt = NULL, *peh_hdr = NULL, *pdyn = NULL;
unw_word_t addr, eh_frame_start, fde_count, load_base;
unw_word_t max_load_addr = 0;
unw_word_t start_ip = to_unw_word (-1);
unw_word_t end_ip = 0;
struct dwarf_eh_frame_hdr *hdr;
unw_proc_info_t pi;
unw_accessors_t *a;
Elf_W(Ehdr) *ehdr;
#if UNW_TARGET_ARM
const Elf_W(Phdr) *parm_exidx = NULL;
#endif
int i, ret, found = 0;
/* XXX: Much of this code is Linux/LSB-specific. */
if (!elf_w(valid_object) (&edi->ei))
return -UNW_ENOINFO;
ehdr = edi->ei.image;
phdr = (Elf_W(Phdr) *) ((char *) edi->ei.image + ehdr->e_phoff);
for (i = 0; i < ehdr->e_phnum; ++i)
{
switch (phdr[i].p_type)
{
case PT_LOAD:
if (phdr[i].p_vaddr < start_ip)
start_ip = phdr[i].p_vaddr;
if (phdr[i].p_vaddr + phdr[i].p_memsz > end_ip)
end_ip = phdr[i].p_vaddr + phdr[i].p_memsz;
if (phdr[i].p_offset == mapoff)
ptxt = phdr + i;
if ((uintptr_t) edi->ei.image + phdr->p_filesz > max_load_addr)
max_load_addr = (uintptr_t) edi->ei.image + phdr->p_filesz;
break;
case PT_GNU_EH_FRAME:
#if defined __sun
case PT_SUNW_UNWIND:
#endif
peh_hdr = phdr + i;
break;
case PT_DYNAMIC:
pdyn = phdr + i;
break;
#if UNW_TARGET_ARM
case PT_ARM_EXIDX:
parm_exidx = phdr + i;
break;
#endif
default:
break;
}
}
if (!ptxt)
return 0;
load_base = segbase - ptxt->p_vaddr;
start_ip += load_base;
end_ip += load_base;
if (peh_hdr)
{
if (pdyn)
{
/* For dynamicly linked executables and shared libraries,
DT_PLTGOT is the value that data-relative addresses are
relative to for that object. We call this the "gp". */
Elf_W(Dyn) *dyn = (Elf_W(Dyn) *)(pdyn->p_offset
+ (char *) edi->ei.image);
for (; dyn->d_tag != DT_NULL; ++dyn)
if (dyn->d_tag == DT_PLTGOT)
{
/* Assume that _DYNAMIC is writable and GLIBC has
relocated it (true for x86 at least). */
edi->di_cache.gp = dyn->d_un.d_ptr;
break;
}
}
else
/* Otherwise this is a static executable with no _DYNAMIC. Assume
that data-relative addresses are relative to 0, i.e.,
absolute. */
edi->di_cache.gp = 0;
hdr = (struct dwarf_eh_frame_hdr *) (peh_hdr->p_offset
+ (char *) edi->ei.image);
if (hdr->version != DW_EH_VERSION)
{
Debug (1, "table `%s' has unexpected version %d\n",
path, hdr->version);
return -UNW_ENOINFO;
}
a = unw_get_accessors_int (unw_local_addr_space);
addr = to_unw_word (&hdr->eh_frame);
/* Fill in a dummy proc_info structure. We just need to fill in
enough to ensure that dwarf_read_encoded_pointer() can do it's
job. Since we don't have a procedure-context at this point, all
we have to do is fill in the global-pointer. */
memset (&pi, 0, sizeof (pi));
pi.gp = edi->di_cache.gp;
/* (Optionally) read eh_frame_ptr: */
if ((ret = dwarf_read_encoded_pointer (unw_local_addr_space, a,
&addr, hdr->eh_frame_ptr_enc, &pi,
&eh_frame_start, NULL)) < 0)
return -UNW_ENOINFO;
/* (Optionally) read fde_count: */
if ((ret = dwarf_read_encoded_pointer (unw_local_addr_space, a,
&addr, hdr->fde_count_enc, &pi,
&fde_count, NULL)) < 0)
return -UNW_ENOINFO;
if (hdr->table_enc != (DW_EH_PE_datarel | DW_EH_PE_sdata4))
{
#if 1
abort ();
#else
unw_word_t eh_frame_end;
/* If there is no search table or it has an unsupported
encoding, fall back on linear search. */
if (hdr->table_enc == DW_EH_PE_omit)
Debug (4, "EH lacks search table; doing linear search\n");
else
Debug (4, "EH table has encoding 0x%x; doing linear search\n",
hdr->table_enc);
eh_frame_end = max_load_addr; /* XXX can we do better? */
if (hdr->fde_count_enc == DW_EH_PE_omit)
fde_count = ~0UL;
if (hdr->eh_frame_ptr_enc == DW_EH_PE_omit)
abort ();
return linear_search (unw_local_addr_space, ip,
eh_frame_start, eh_frame_end, fde_count,
pi, need_unwind_info, NULL);
#endif
}
edi->di_cache.start_ip = start_ip;
edi->di_cache.end_ip = end_ip;
edi->di_cache.load_offset = 0;
edi->di_cache.format = UNW_INFO_FORMAT_REMOTE_TABLE;
edi->di_cache.u.rti.name_ptr = 0;
/* two 32-bit values (ip_offset/fde_offset) per table-entry: */
edi->di_cache.u.rti.table_len = (fde_count * 8) / sizeof (unw_word_t);
edi->di_cache.u.rti.table_data = ((load_base + peh_hdr->p_vaddr)
+ (addr - to_unw_word (edi->ei.image)
- peh_hdr->p_offset));
/* For the binary-search table in the eh_frame_hdr, data-relative
means relative to the start of that section... */
edi->di_cache.u.rti.segbase = ((load_base + peh_hdr->p_vaddr)
+ (to_unw_word (hdr) -
to_unw_word (edi->ei.image)
- peh_hdr->p_offset));
found = 1;
}
#if UNW_TARGET_ARM
if (parm_exidx)
{
edi->di_arm.format = UNW_INFO_FORMAT_ARM_EXIDX;
edi->di_arm.start_ip = start_ip;
edi->di_arm.end_ip = end_ip;
edi->di_arm.u.rti.name_ptr = to_unw_word (path);
edi->di_arm.u.rti.table_data = load_base + parm_exidx->p_vaddr;
edi->di_arm.u.rti.table_len = parm_exidx->p_memsz;
found = 1;
}
#endif
#ifdef CONFIG_DEBUG_FRAME
/* Try .debug_frame. */
found = dwarf_find_debug_frame (found, &edi->di_debug, ip, load_base, path,
start_ip, end_ip);
#endif
return found;
}
| /* libunwind - a platform-independent unwind library
Copyright (C) 2003-2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include "libunwind_i.h"
#include "dwarf-eh.h"
#include "dwarf_i.h"
#define to_unw_word(p) ((unw_word_t) (uintptr_t) (p))
int
dwarf_find_unwind_table (struct elf_dyn_info *edi, unw_addr_space_t as,
char *path, unw_word_t segbase, unw_word_t mapoff,
unw_word_t ip)
{
Elf_W(Phdr) *phdr, *ptxt = NULL, *peh_hdr = NULL, *pdyn = NULL;
unw_word_t addr, eh_frame_start, fde_count, load_base;
unw_word_t max_load_addr = 0;
unw_word_t start_ip = to_unw_word (-1);
unw_word_t end_ip = 0;
struct dwarf_eh_frame_hdr *hdr;
unw_proc_info_t pi;
unw_accessors_t *a;
Elf_W(Ehdr) *ehdr;
#if UNW_TARGET_ARM
const Elf_W(Phdr) *parm_exidx = NULL;
#endif
int i, ret, found = 0;
/* XXX: Much of this code is Linux/LSB-specific. */
if (!elf_w(valid_object) (&edi->ei))
return -UNW_ENOINFO;
ehdr = edi->ei.image;
phdr = (Elf_W(Phdr) *) ((char *) edi->ei.image + ehdr->e_phoff);
for (i = 0; i < ehdr->e_phnum; ++i)
{
switch (phdr[i].p_type)
{
case PT_LOAD:
if (phdr[i].p_vaddr < start_ip)
start_ip = phdr[i].p_vaddr;
if (phdr[i].p_vaddr + phdr[i].p_memsz > end_ip)
end_ip = phdr[i].p_vaddr + phdr[i].p_memsz;
if (phdr[i].p_offset == mapoff)
ptxt = phdr + i;
if ((uintptr_t) edi->ei.image + phdr->p_filesz > max_load_addr)
max_load_addr = (uintptr_t) edi->ei.image + phdr->p_filesz;
break;
case PT_GNU_EH_FRAME:
#if defined __sun
case PT_SUNW_UNWIND:
#endif
peh_hdr = phdr + i;
break;
case PT_DYNAMIC:
pdyn = phdr + i;
break;
#if UNW_TARGET_ARM
case PT_ARM_EXIDX:
parm_exidx = phdr + i;
break;
#endif
default:
break;
}
}
if (!ptxt)
return 0;
load_base = segbase - ptxt->p_vaddr;
start_ip += load_base;
end_ip += load_base;
if (peh_hdr)
{
if (pdyn)
{
/* For dynamicly linked executables and shared libraries,
DT_PLTGOT is the value that data-relative addresses are
relative to for that object. We call this the "gp". */
Elf_W(Dyn) *dyn = (Elf_W(Dyn) *)(pdyn->p_offset
+ (char *) edi->ei.image);
for (; dyn->d_tag != DT_NULL; ++dyn)
if (dyn->d_tag == DT_PLTGOT)
{
/* Assume that _DYNAMIC is writable and GLIBC has
relocated it (true for x86 at least). */
edi->di_cache.gp = dyn->d_un.d_ptr;
break;
}
}
else
/* Otherwise this is a static executable with no _DYNAMIC. Assume
that data-relative addresses are relative to 0, i.e.,
absolute. */
edi->di_cache.gp = 0;
hdr = (struct dwarf_eh_frame_hdr *) (peh_hdr->p_offset
+ (char *) edi->ei.image);
if (hdr->version != DW_EH_VERSION)
{
Debug (1, "table `%s' has unexpected version %d\n",
path, hdr->version);
return -UNW_ENOINFO;
}
a = unw_get_accessors_int (unw_local_addr_space);
addr = to_unw_word (&hdr->eh_frame);
/* Fill in a dummy proc_info structure. We just need to fill in
enough to ensure that dwarf_read_encoded_pointer() can do it's
job. Since we don't have a procedure-context at this point, all
we have to do is fill in the global-pointer. */
memset (&pi, 0, sizeof (pi));
pi.gp = edi->di_cache.gp;
/* (Optionally) read eh_frame_ptr: */
if ((ret = dwarf_read_encoded_pointer (unw_local_addr_space, a,
&addr, hdr->eh_frame_ptr_enc, &pi,
&eh_frame_start, NULL)) < 0)
return -UNW_ENOINFO;
/* (Optionally) read fde_count: */
if ((ret = dwarf_read_encoded_pointer (unw_local_addr_space, a,
&addr, hdr->fde_count_enc, &pi,
&fde_count, NULL)) < 0)
return -UNW_ENOINFO;
if (hdr->table_enc != (DW_EH_PE_datarel | DW_EH_PE_sdata4))
{
#if 1
abort ();
#else
unw_word_t eh_frame_end;
/* If there is no search table or it has an unsupported
encoding, fall back on linear search. */
if (hdr->table_enc == DW_EH_PE_omit)
Debug (4, "EH lacks search table; doing linear search\n");
else
Debug (4, "EH table has encoding 0x%x; doing linear search\n",
hdr->table_enc);
eh_frame_end = max_load_addr; /* XXX can we do better? */
if (hdr->fde_count_enc == DW_EH_PE_omit)
fde_count = ~0UL;
if (hdr->eh_frame_ptr_enc == DW_EH_PE_omit)
abort ();
return linear_search (unw_local_addr_space, ip,
eh_frame_start, eh_frame_end, fde_count,
pi, need_unwind_info, NULL);
#endif
}
edi->di_cache.start_ip = start_ip;
edi->di_cache.end_ip = end_ip;
edi->di_cache.load_offset = 0;
edi->di_cache.format = UNW_INFO_FORMAT_REMOTE_TABLE;
edi->di_cache.u.rti.name_ptr = 0;
/* two 32-bit values (ip_offset/fde_offset) per table-entry: */
edi->di_cache.u.rti.table_len = (fde_count * 8) / sizeof (unw_word_t);
edi->di_cache.u.rti.table_data = ((load_base + peh_hdr->p_vaddr)
+ (addr - to_unw_word (edi->ei.image)
- peh_hdr->p_offset));
/* For the binary-search table in the eh_frame_hdr, data-relative
means relative to the start of that section... */
edi->di_cache.u.rti.segbase = ((load_base + peh_hdr->p_vaddr)
+ (to_unw_word (hdr) -
to_unw_word (edi->ei.image)
- peh_hdr->p_offset));
found = 1;
}
#if UNW_TARGET_ARM
if (parm_exidx)
{
edi->di_arm.format = UNW_INFO_FORMAT_ARM_EXIDX;
edi->di_arm.start_ip = start_ip;
edi->di_arm.end_ip = end_ip;
edi->di_arm.u.rti.name_ptr = to_unw_word (path);
edi->di_arm.u.rti.table_data = load_base + parm_exidx->p_vaddr;
edi->di_arm.u.rti.table_len = parm_exidx->p_memsz;
found = 1;
}
#endif
#ifdef CONFIG_DEBUG_FRAME
/* Try .debug_frame. */
found = dwarf_find_debug_frame (found, &edi->di_debug, ip, load_base, path,
start_ip, end_ip);
#endif
return found;
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/mini/interp/interp.c | /**
* \file
*
* interp.c: Interpreter for CIL byte codes
*
* Authors:
* Paolo Molaro ([email protected])
* Miguel de Icaza ([email protected])
* Dietmar Maurer ([email protected])
*
* (C) 2001, 2002 Ximian, Inc.
*/
#ifndef __USE_ISOC99
#define __USE_ISOC99
#endif
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <glib.h>
#include <math.h>
#include <locale.h>
#include <mono/utils/gc_wrapper.h>
#include <mono/utils/mono-math.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-tls-inline.h>
#include <mono/utils/mono-threads.h>
#include <mono/utils/mono-membar.h>
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#else
# ifdef __CYGWIN__
# define alloca __builtin_alloca
# endif
#endif
/* trim excessive headers */
#include <mono/metadata/image.h>
#include <mono/metadata/assembly-internals.h>
#include <mono/metadata/cil-coff.h>
#include <mono/metadata/mono-endian.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/tokentype.h>
#include <mono/metadata/loader.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/reflection.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/verify.h>
#include <mono/metadata/opcodes.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/marshal.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/gc-internals.h>
#include <mono/utils/atomic.h>
#include "interp.h"
#include "interp-internals.h"
#include "mintops.h"
#include "interp-intrins.h"
#include <mono/mini/mini.h>
#include <mono/mini/mini-runtime.h>
#include <mono/mini/aot-runtime.h>
#include <mono/mini/llvm-runtime.h>
#include <mono/mini/llvmonly-runtime.h>
#include <mono/mini/jit-icalls.h>
#include <mono/mini/ee.h>
#include <mono/mini/trace.h>
#include <mono/metadata/components.h>
#ifdef TARGET_ARM
#include <mono/mini/mini-arm.h>
#endif
#include <mono/metadata/icall-decl.h>
/* Arguments that are passed when invoking only a finally/filter clause from the frame */
struct FrameClauseArgs {
/* Where we start the frame execution from */
const guint16 *start_with_ip;
/*
* End ip of the exit_clause. We need it so we know whether the resume
* state is for this frame (which is called from EH) or for the original
* frame further down the stack.
*/
const guint16 *end_at_ip;
/* Frame that is executing this clause */
InterpFrame *exec_frame;
};
/*
* This code synchronizes with interp_mark_stack () using compiler memory barriers.
*/
static FrameDataFragment*
frame_data_frag_new (int size)
{
FrameDataFragment *frag = (FrameDataFragment*)g_malloc (size);
frag->pos = (guint8*)&frag->data;
frag->end = (guint8*)frag + size;
frag->next = NULL;
return frag;
}
static void
frame_data_frag_free (FrameDataFragment *frag)
{
while (frag) {
FrameDataFragment *next = frag->next;
g_free (frag);
frag = next;
}
}
static void
frame_data_allocator_init (FrameDataAllocator *stack, int size)
{
FrameDataFragment *frag;
frag = frame_data_frag_new (size);
stack->first = stack->current = frag;
stack->infos_capacity = 4;
stack->infos = (FrameDataInfo*)g_malloc (stack->infos_capacity * sizeof (FrameDataInfo));
}
static void
frame_data_allocator_free (FrameDataAllocator *stack)
{
/* Assert to catch leaks */
g_assert_checked (stack->current == stack->first && stack->current->pos == (guint8*)&stack->current->data);
frame_data_frag_free (stack->first);
}
static FrameDataFragment*
frame_data_allocator_add_frag (FrameDataAllocator *stack, int size)
{
FrameDataFragment *new_frag;
// FIXME:
int frag_size = 4096;
if (size + sizeof (FrameDataFragment) > frag_size)
frag_size = size + sizeof (FrameDataFragment);
new_frag = frame_data_frag_new (frag_size);
mono_compiler_barrier ();
stack->current->next = new_frag;
stack->current = new_frag;
return new_frag;
}
static gpointer
frame_data_allocator_alloc (FrameDataAllocator *stack, InterpFrame *frame, int size)
{
FrameDataFragment *current = stack->current;
gpointer res;
int infos_len = stack->infos_len;
if (!infos_len || (infos_len > 0 && stack->infos [infos_len - 1].frame != frame)) {
/* First allocation by this frame. Save the markers for restore */
if (infos_len == stack->infos_capacity) {
stack->infos_capacity = infos_len * 2;
stack->infos = (FrameDataInfo*)g_realloc (stack->infos, stack->infos_capacity * sizeof (FrameDataInfo));
}
stack->infos [infos_len].frame = frame;
stack->infos [infos_len].frag = current;
stack->infos [infos_len].pos = current->pos;
stack->infos_len++;
}
if (G_LIKELY (current->pos + size <= current->end)) {
res = current->pos;
current->pos += size;
} else {
if (current->next && current->next->pos + size <= current->next->end) {
current = stack->current = current->next;
current->pos = (guint8*)¤t->data;
} else {
FrameDataFragment *tmp = current->next;
/* avoid linking to be freed fragments, so the GC can't trip over it */
current->next = NULL;
mono_compiler_barrier ();
frame_data_frag_free (tmp);
current = frame_data_allocator_add_frag (stack, size);
}
g_assert (current->pos + size <= current->end);
res = (gpointer)current->pos;
current->pos += size;
}
mono_compiler_barrier ();
return res;
}
static void
frame_data_allocator_pop (FrameDataAllocator *stack, InterpFrame *frame)
{
int infos_len = stack->infos_len;
if (infos_len > 0 && stack->infos [infos_len - 1].frame == frame) {
infos_len--;
stack->current = stack->infos [infos_len].frag;
stack->current->pos = stack->infos [infos_len].pos;
stack->infos_len = infos_len;
}
}
/*
* reinit_frame:
*
* Reinitialize a frame.
*/
static void
reinit_frame (InterpFrame *frame, InterpFrame *parent, InterpMethod *imethod, gpointer retval, gpointer stack)
{
frame->parent = parent;
frame->imethod = imethod;
frame->stack = (stackval*)stack;
frame->retval = (stackval*)retval;
frame->state.ip = NULL;
}
#define STACK_ADD_BYTES(sp,bytes) ((stackval*)((char*)(sp) + ALIGN_TO(bytes, MINT_STACK_SLOT_SIZE)))
#define STACK_SUB_BYTES(sp,bytes) ((stackval*)((char*)(sp) - ALIGN_TO(bytes, MINT_STACK_SLOT_SIZE)))
/*
* List of classes whose methods will be executed by transitioning to JITted code.
* Used for testing.
*/
GSList *mono_interp_jit_classes;
/* Optimizations enabled with interpreter */
int mono_interp_opt = INTERP_OPT_DEFAULT;
/* If TRUE, interpreted code will be interrupted at function entry/backward branches */
static gboolean ss_enabled;
static gboolean interp_init_done = FALSE;
static void
interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs *clause_args);
static MonoException* do_transform_method (InterpMethod *imethod, InterpFrame *method, ThreadContext *context);
static InterpMethod* lookup_method_pointer (gpointer addr);
typedef void (*ICallMethod) (InterpFrame *frame);
static MonoNativeTlsKey thread_context_id;
#define DEBUG_INTERP 0
#define COUNT_OPS 0
#if DEBUG_INTERP
int mono_interp_traceopt = 2;
/* If true, then we output the opcodes as we interpret them */
static int global_tracing = 2;
static int debug_indent_level = 0;
static int break_on_method = 0;
static int nested_trace = 0;
static GList *db_methods = NULL;
static char* dump_args (InterpFrame *inv);
static void
output_indent (void)
{
int h;
for (h = 0; h < debug_indent_level; h++)
g_print (" ");
}
static void
db_match_method (gpointer data, gpointer user_data)
{
MonoMethod *m = (MonoMethod*)user_data;
MonoMethodDesc *desc = (MonoMethodDesc*)data;
if (mono_method_desc_full_match (desc, m))
break_on_method = 1;
}
static void
debug_enter (InterpFrame *frame, int *tracing)
{
if (db_methods) {
g_list_foreach (db_methods, db_match_method, (gpointer)frame->imethod->method);
if (break_on_method)
*tracing = nested_trace ? (global_tracing = 2, 3) : 2;
break_on_method = 0;
}
if (*tracing) {
MonoMethod *method = frame->imethod->method;
char *mn, *args = dump_args (frame);
debug_indent_level++;
output_indent ();
mn = mono_method_full_name (method, FALSE);
g_print ("(%p) Entering %s (", mono_thread_internal_current (), mn);
g_free (mn);
g_print ("%s)\n", args);
g_free (args);
}
}
#define DEBUG_LEAVE() \
if (tracing) { \
char *mn, *args; \
args = dump_retval (frame); \
output_indent (); \
mn = mono_method_full_name (frame->imethod->method, FALSE); \
g_print ("(%p) Leaving %s", mono_thread_internal_current (), mn); \
g_free (mn); \
g_print (" => %s\n", args); \
g_free (args); \
debug_indent_level--; \
if (tracing == 3) global_tracing = 0; \
}
#else
int mono_interp_traceopt = 0;
#define DEBUG_LEAVE()
#endif
#if defined(__GNUC__) && !defined(TARGET_WASM) && !COUNT_OPS && !DEBUG_INTERP && !ENABLE_CHECKED_BUILD && !PROFILE_INTERP
#define USE_COMPUTED_GOTO 1
#endif
#if USE_COMPUTED_GOTO
#define MINT_IN_DISPATCH(op) goto *in_labels [opcode = (MintOpcode)(op)]
#define MINT_IN_SWITCH(op) MINT_IN_DISPATCH (op);
#define MINT_IN_BREAK MINT_IN_DISPATCH (*ip)
#define MINT_IN_CASE(x) LAB_ ## x:
#else
#define MINT_IN_SWITCH(op) COUNT_OP(op); switch (opcode = (MintOpcode)(op))
#define MINT_IN_CASE(x) case x:
#define MINT_IN_BREAK break
#endif
static void
clear_resume_state (ThreadContext *context)
{
context->has_resume_state = 0;
context->handler_frame = NULL;
context->handler_ei = NULL;
g_assert (context->exc_gchandle);
mono_gchandle_free_internal (context->exc_gchandle);
context->exc_gchandle = 0;
}
/*
* If this bit is set, it means the call has thrown the exception, and we
* reached this point because the EH code in mono_handle_exception ()
* unwound all the JITted frames below us. mono_interp_set_resume_state ()
* has set the fields in context to indicate where we have to resume execution.
*/
#define CHECK_RESUME_STATE(context) do { \
if ((context)->has_resume_state) \
goto resume; \
} while (0)
static void
set_context (ThreadContext *context)
{
mono_native_tls_set_value (thread_context_id, context);
if (!context)
return;
MonoJitTlsData *jit_tls = mono_tls_get_jit_tls ();
g_assertf (jit_tls, "ThreadContext needs initialized JIT TLS");
/* jit_tls assumes ownership of 'context' */
jit_tls->interp_context = context;
}
static ThreadContext *
get_context (void)
{
ThreadContext *context = (ThreadContext *) mono_native_tls_get_value (thread_context_id);
if (context == NULL) {
context = g_new0 (ThreadContext, 1);
context->stack_start = (guchar*)mono_valloc (0, INTERP_STACK_SIZE, MONO_MMAP_READ | MONO_MMAP_WRITE, MONO_MEM_ACCOUNT_INTERP_STACK);
context->stack_end = context->stack_start + INTERP_STACK_SIZE - INTERP_REDZONE_SIZE;
context->stack_real_end = context->stack_start + INTERP_STACK_SIZE;
context->stack_pointer = context->stack_start;
frame_data_allocator_init (&context->data_stack, 8192);
/* Make sure all data is initialized before publishing the context */
mono_compiler_barrier ();
set_context (context);
}
return context;
}
static void
interp_free_context (gpointer ctx)
{
ThreadContext *context = (ThreadContext*)ctx;
ThreadContext *current_context = (ThreadContext *) mono_native_tls_get_value (thread_context_id);
/* at thread exit, we can be called from the JIT TLS key destructor with current_context == NULL */
if (current_context != NULL) {
/* check that the context we're freeing is the current one before overwriting TLS */
g_assert (context == current_context);
set_context (NULL);
}
mono_vfree (context->stack_start, INTERP_STACK_SIZE, MONO_MEM_ACCOUNT_INTERP_STACK);
/* Prevent interp_mark_stack from trying to scan the data_stack, before freeing it */
context->stack_start = NULL;
mono_compiler_barrier ();
frame_data_allocator_free (&context->data_stack);
g_free (context);
}
/* Continue unwinding if there is an exception that needs to be handled in an AOTed frame above us */
static void
check_pending_unwind (ThreadContext *context)
{
if (context->has_resume_state && !context->handler_frame)
mono_llvm_cpp_throw_exception ();
}
void
mono_interp_error_cleanup (MonoError* error)
{
mono_error_cleanup (error); /* FIXME: don't swallow the error */
error_init_reuse (error); // one instruction, so this function is good inline candidate
}
static InterpMethod*
lookup_imethod (MonoMethod *method)
{
InterpMethod *imethod;
MonoJitMemoryManager *jit_mm = jit_mm_for_method (method);
jit_mm_lock (jit_mm);
imethod = (InterpMethod*)mono_internal_hash_table_lookup (&jit_mm->interp_code_hash, method);
jit_mm_unlock (jit_mm);
return imethod;
}
InterpMethod*
mono_interp_get_imethod (MonoMethod *method, MonoError *error)
{
InterpMethod *imethod;
MonoMethodSignature *sig;
MonoJitMemoryManager *jit_mm = jit_mm_for_method (method);
int i;
error_init (error);
jit_mm_lock (jit_mm);
imethod = (InterpMethod*)mono_internal_hash_table_lookup (&jit_mm->interp_code_hash, method);
jit_mm_unlock (jit_mm);
if (imethod)
return imethod;
sig = mono_method_signature_internal (method);
imethod = (InterpMethod*)m_method_alloc0 (method, sizeof (InterpMethod));
imethod->method = method;
imethod->param_count = sig->param_count;
imethod->hasthis = sig->hasthis;
imethod->vararg = sig->call_convention == MONO_CALL_VARARG;
imethod->code_type = IMETHOD_CODE_UNKNOWN;
if (imethod->method->string_ctor)
imethod->rtype = m_class_get_byval_arg (mono_defaults.string_class);
else
imethod->rtype = mini_get_underlying_type (sig->ret);
imethod->param_types = (MonoType**)m_method_alloc0 (method, sizeof (MonoType*) * sig->param_count);
for (i = 0; i < sig->param_count; ++i)
imethod->param_types [i] = mini_get_underlying_type (sig->params [i]);
jit_mm_lock (jit_mm);
InterpMethod *old_imethod;
if (!((old_imethod = mono_internal_hash_table_lookup (&jit_mm->interp_code_hash, method))))
mono_internal_hash_table_insert (&jit_mm->interp_code_hash, method, imethod);
else {
imethod = old_imethod; /* leak the newly allocated InterpMethod to the mempool */
}
jit_mm_unlock (jit_mm);
imethod->prof_flags = mono_profiler_get_call_instrumentation_flags (imethod->method);
return imethod;
}
#if defined (MONO_CROSS_COMPILE) || defined (HOST_WASM)
#define INTERP_PUSH_LMF_WITH_CTX_BODY(ext, exit_label) \
(ext).kind = MONO_LMFEXT_INTERP_EXIT;
#elif defined(MONO_ARCH_HAS_NO_PROPER_MONOCTX)
/* some platforms, e.g. appleTV, don't provide us a precise MonoContext
* (registers are not accurate), thus resuming to the label does not work. */
#define INTERP_PUSH_LMF_WITH_CTX_BODY(ext, exit_label) \
(ext).kind = MONO_LMFEXT_INTERP_EXIT;
#elif defined (_MSC_VER)
#define INTERP_PUSH_LMF_WITH_CTX_BODY(ext, exit_label) \
(ext).kind = MONO_LMFEXT_INTERP_EXIT_WITH_CTX; \
(ext).interp_exit_label_set = FALSE; \
MONO_CONTEXT_GET_CURRENT ((ext).ctx); \
if ((ext).interp_exit_label_set == FALSE) \
mono_arch_do_ip_adjustment (&(ext).ctx); \
if ((ext).interp_exit_label_set == TRUE) \
goto exit_label; \
(ext).interp_exit_label_set = TRUE;
#elif defined(MONO_ARCH_HAS_MONO_CONTEXT)
#define INTERP_PUSH_LMF_WITH_CTX_BODY(ext, exit_label) \
(ext).kind = MONO_LMFEXT_INTERP_EXIT_WITH_CTX; \
MONO_CONTEXT_GET_CURRENT ((ext).ctx); \
MONO_CONTEXT_SET_IP (&(ext).ctx, (&&exit_label)); \
mono_arch_do_ip_adjustment (&(ext).ctx);
#else
#define INTERP_PUSH_LMF_WITH_CTX_BODY(ext, exit_label) g_error ("requires working mono-context");
#endif
/* INTERP_PUSH_LMF_WITH_CTX:
*
* same as interp_push_lmf, but retrieving and attaching MonoContext to it.
* This is needed to resume into the interp when the exception is thrown from
* native code (see ./mono/tests/install_eh_callback.exe).
*
* This must be a macro in order to retrieve the right register values for
* MonoContext.
*/
#define INTERP_PUSH_LMF_WITH_CTX(frame, ext, exit_label) \
memset (&(ext), 0, sizeof (MonoLMFExt)); \
(ext).interp_exit_data = (frame); \
INTERP_PUSH_LMF_WITH_CTX_BODY ((ext), exit_label); \
mono_push_lmf (&(ext));
/*
* interp_push_lmf:
*
* Push an LMF frame on the LMF stack
* to mark the transition to native code.
* This is needed for the native code to
* be able to do stack walks.
*/
static void
interp_push_lmf (MonoLMFExt *ext, InterpFrame *frame)
{
memset (ext, 0, sizeof (MonoLMFExt));
ext->kind = MONO_LMFEXT_INTERP_EXIT;
ext->interp_exit_data = frame;
mono_push_lmf (ext);
}
static void
interp_pop_lmf (MonoLMFExt *ext)
{
mono_pop_lmf (&ext->lmf);
}
static InterpMethod*
get_virtual_method (InterpMethod *imethod, MonoVTable *vtable)
{
MonoMethod *m = imethod->method;
InterpMethod *ret = NULL;
if ((m->flags & METHOD_ATTRIBUTE_FINAL) || !(m->flags & METHOD_ATTRIBUTE_VIRTUAL)) {
if (m->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) {
ERROR_DECL (error);
ret = mono_interp_get_imethod (mono_marshal_get_synchronized_wrapper (m), error);
mono_interp_error_cleanup (error); /* FIXME: don't swallow the error */
} else {
ret = imethod;
}
return ret;
}
mono_class_setup_vtable (vtable->klass);
int slot = mono_method_get_vtable_slot (m);
if (mono_class_is_interface (m->klass)) {
g_assert (vtable->klass != m->klass);
/* TODO: interface offset lookup is slow, go through IMT instead */
gboolean non_exact_match;
slot += mono_class_interface_offset_with_variance (vtable->klass, m->klass, &non_exact_match);
}
MonoMethod *virtual_method = m_class_get_vtable (vtable->klass) [slot];
if (m->is_inflated && mono_method_get_context (m)->method_inst) {
MonoGenericContext context = { NULL, NULL };
if (mono_class_is_ginst (virtual_method->klass))
context.class_inst = mono_class_get_generic_class (virtual_method->klass)->context.class_inst;
else if (mono_class_is_gtd (virtual_method->klass))
context.class_inst = mono_class_get_generic_container (virtual_method->klass)->context.class_inst;
context.method_inst = mono_method_get_context (m)->method_inst;
ERROR_DECL (error);
virtual_method = mono_class_inflate_generic_method_checked (virtual_method, &context, error);
mono_error_cleanup (error); /* FIXME: don't swallow the error */
}
if (virtual_method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) {
virtual_method = mono_marshal_get_native_wrapper (virtual_method, FALSE, FALSE);
}
if (virtual_method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) {
virtual_method = mono_marshal_get_synchronized_wrapper (virtual_method);
}
ERROR_DECL (error);
InterpMethod *virtual_imethod = mono_interp_get_imethod (virtual_method, error);
mono_error_cleanup (error); /* FIXME: don't swallow the error */
return virtual_imethod;
}
typedef struct {
InterpMethod *imethod;
InterpMethod *target_imethod;
} InterpVTableEntry;
/* memory manager lock must be held */
static GSList*
append_imethod (MonoMemoryManager *memory_manager, GSList *list, InterpMethod *imethod, InterpMethod *target_imethod)
{
GSList *ret;
InterpVTableEntry *entry;
entry = (InterpVTableEntry*) mono_mem_manager_alloc0 (memory_manager, sizeof (InterpVTableEntry));
entry->imethod = imethod;
entry->target_imethod = target_imethod;
ret = mono_mem_manager_alloc0 (memory_manager, sizeof (GSList));
ret->data = entry;
ret = g_slist_concat (list, ret);
return ret;
}
static InterpMethod*
get_target_imethod (GSList *list, InterpMethod *imethod)
{
while (list != NULL) {
InterpVTableEntry *entry = (InterpVTableEntry*) list->data;
if (entry->imethod == imethod)
return entry->target_imethod;
list = list->next;
}
return NULL;
}
static inline MonoVTableEEData*
get_vtable_ee_data (MonoVTable *vtable)
{
MonoVTableEEData *ee_data = (MonoVTableEEData*)vtable->ee_data;
if (G_UNLIKELY (!ee_data)) {
ee_data = m_class_alloc0 (vtable->klass, sizeof (MonoVTableEEData));
mono_memory_barrier ();
vtable->ee_data = ee_data;
}
return ee_data;
}
static gpointer*
get_method_table (MonoVTable *vtable, int offset)
{
if (offset >= 0)
return get_vtable_ee_data (vtable)->interp_vtable;
else
return (gpointer*)vtable;
}
static gpointer*
alloc_method_table (MonoVTable *vtable, int offset)
{
gpointer *table;
if (offset >= 0) {
table = (gpointer*)m_class_alloc0 (vtable->klass, m_class_get_vtable_size (vtable->klass) * sizeof (gpointer));
get_vtable_ee_data (vtable)->interp_vtable = table;
} else {
table = (gpointer*)vtable;
}
return table;
}
static InterpMethod* // Inlining causes additional stack use in caller.
get_virtual_method_fast (InterpMethod *imethod, MonoVTable *vtable, int offset)
{
gpointer *table;
MonoMemoryManager *memory_manager = NULL;
table = get_method_table (vtable, offset);
if (G_UNLIKELY (!table)) {
memory_manager = m_class_get_mem_manager (vtable->klass);
/* Lazily allocate method table */
mono_mem_manager_lock (memory_manager);
table = get_method_table (vtable, offset);
if (!table)
table = alloc_method_table (vtable, offset);
mono_mem_manager_unlock (memory_manager);
}
if (G_UNLIKELY (!table [offset])) {
InterpMethod *target_imethod = get_virtual_method (imethod, vtable);
if (!memory_manager)
memory_manager = m_class_get_mem_manager (vtable->klass);
/* Lazily initialize the method table slot */
mono_mem_manager_lock (memory_manager);
if (!table [offset]) {
if (imethod->method->is_inflated || offset < 0)
table [offset] = append_imethod (memory_manager, NULL, imethod, target_imethod);
else
table [offset] = (gpointer) ((gsize)target_imethod | 0x1);
}
mono_mem_manager_unlock (memory_manager);
}
if ((gsize)table [offset] & 0x1) {
/* Non generic virtual call. Only one method in slot */
return (InterpMethod*) ((gsize)table [offset] & ~0x1);
} else {
/* Virtual generic or interface call. Multiple methods in slot */
InterpMethod *target_imethod = get_target_imethod ((GSList*)table [offset], imethod);
if (G_UNLIKELY (!target_imethod)) {
target_imethod = get_virtual_method (imethod, vtable);
if (!memory_manager)
memory_manager = m_class_get_mem_manager (vtable->klass);
mono_mem_manager_lock (memory_manager);
if (!get_target_imethod ((GSList*)table [offset], imethod))
table [offset] = append_imethod (memory_manager, (GSList*)table [offset], imethod, target_imethod);
mono_mem_manager_unlock (memory_manager);
}
return target_imethod;
}
}
// Returns the size it uses on the interpreter stack
static int
stackval_size (MonoType *type, gboolean pinvoke)
{
if (m_type_is_byref (type))
return MINT_STACK_SLOT_SIZE;
switch (type->type) {
case MONO_TYPE_VOID:
return 0;
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_CHAR:
case MONO_TYPE_I4:
case MONO_TYPE_U:
case MONO_TYPE_I:
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
case MONO_TYPE_U4:
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_R4:
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_I8:
case MONO_TYPE_U8:
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_R8:
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_STRING:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_ARRAY:
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_VALUETYPE:
if (m_class_is_enumtype (type->data.klass)) {
return stackval_size (mono_class_enum_basetype_internal (type->data.klass), pinvoke);
} else {
int size;
if (pinvoke)
size = mono_class_native_size (type->data.klass, NULL);
else
size = mono_class_value_size (type->data.klass, NULL);
return ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
case MONO_TYPE_GENERICINST: {
if (mono_type_generic_inst_is_valuetype (type)) {
MonoClass *klass = mono_class_from_mono_type_internal (type);
int size;
if (pinvoke)
size = mono_class_native_size (klass, NULL);
else
size = mono_class_value_size (klass, NULL);
return ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
return stackval_size (m_class_get_byval_arg (type->data.generic_class->container_class), pinvoke);
}
default:
g_error ("got type 0x%02x", type->type);
}
}
// Returns the size it uses on the interpreter stack
static int
stackval_from_data (MonoType *type, stackval *result, const void *data, gboolean pinvoke)
{
if (m_type_is_byref (type)) {
result->data.p = *(gpointer*)data;
return MINT_STACK_SLOT_SIZE;
}
switch (type->type) {
case MONO_TYPE_VOID:
return 0;
case MONO_TYPE_I1:
result->data.i = *(gint8*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_U1:
case MONO_TYPE_BOOLEAN:
result->data.i = *(guint8*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_I2:
result->data.i = *(gint16*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_U2:
case MONO_TYPE_CHAR:
result->data.i = *(guint16*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_I4:
result->data.i = *(gint32*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_U:
case MONO_TYPE_I:
result->data.nati = *(mono_i*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
result->data.p = *(gpointer*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_U4:
result->data.i = *(guint32*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_R4:
/* memmove handles unaligned case */
memmove (&result->data.f_r4, data, sizeof (float));
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_I8:
case MONO_TYPE_U8:
memmove (&result->data.l, data, sizeof (gint64));
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_R8:
memmove (&result->data.f, data, sizeof (double));
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_STRING:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_ARRAY:
result->data.p = *(gpointer*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_VALUETYPE:
if (m_class_is_enumtype (type->data.klass)) {
return stackval_from_data (mono_class_enum_basetype_internal (type->data.klass), result, data, pinvoke);
} else {
int size;
if (pinvoke)
size = mono_class_native_size (type->data.klass, NULL);
else
size = mono_class_value_size (type->data.klass, NULL);
memcpy (result, data, size);
return ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
case MONO_TYPE_GENERICINST: {
if (mono_type_generic_inst_is_valuetype (type)) {
MonoClass *klass = mono_class_from_mono_type_internal (type);
int size;
if (pinvoke)
size = mono_class_native_size (klass, NULL);
else
size = mono_class_value_size (klass, NULL);
memcpy (result, data, size);
return ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
return stackval_from_data (m_class_get_byval_arg (type->data.generic_class->container_class), result, data, pinvoke);
}
default:
g_error ("got type 0x%02x", type->type);
}
}
static int
stackval_to_data (MonoType *type, stackval *val, void *data, gboolean pinvoke)
{
if (m_type_is_byref (type)) {
gpointer *p = (gpointer*)data;
*p = val->data.p;
return MINT_STACK_SLOT_SIZE;
}
/* printf ("TODAT0 %p\n", data); */
switch (type->type) {
case MONO_TYPE_I1:
case MONO_TYPE_U1: {
guint8 *p = (guint8*)data;
*p = val->data.i;
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_BOOLEAN: {
guint8 *p = (guint8*)data;
*p = (val->data.i != 0);
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_CHAR: {
guint16 *p = (guint16*)data;
*p = val->data.i;
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_I: {
mono_i *p = (mono_i*)data;
/* In theory the value used by stloc should match the local var type
but in practice it sometimes doesn't (a int32 gets dup'd and stloc'd into
a native int - both by csc and mcs). Not sure what to do about sign extension
as it is outside the spec... doing the obvious */
*p = (mono_i)val->data.nati;
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_U: {
mono_u *p = (mono_u*)data;
/* see above. */
*p = (mono_u)val->data.nati;
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_I4:
case MONO_TYPE_U4: {
gint32 *p = (gint32*)data;
*p = val->data.i;
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_I8:
case MONO_TYPE_U8: {
memmove (data, &val->data.l, sizeof (gint64));
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_R4: {
/* memmove handles unaligned case */
memmove (data, &val->data.f_r4, sizeof (float));
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_R8: {
memmove (data, &val->data.f, sizeof (double));
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_STRING:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_ARRAY: {
gpointer *p = (gpointer *) data;
mono_gc_wbarrier_generic_store_internal (p, val->data.o);
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR: {
gpointer *p = (gpointer *) data;
*p = val->data.p;
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_VALUETYPE:
if (m_class_is_enumtype (type->data.klass)) {
return stackval_to_data (mono_class_enum_basetype_internal (type->data.klass), val, data, pinvoke);
} else {
int size;
if (pinvoke) {
size = mono_class_native_size (type->data.klass, NULL);
memcpy (data, val, size);
} else {
size = mono_class_value_size (type->data.klass, NULL);
mono_value_copy_internal (data, val, type->data.klass);
}
return ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
case MONO_TYPE_GENERICINST: {
MonoClass *container_class = type->data.generic_class->container_class;
if (m_class_is_valuetype (container_class) && !m_class_is_enumtype (container_class)) {
MonoClass *klass = mono_class_from_mono_type_internal (type);
int size;
if (pinvoke) {
size = mono_class_native_size (klass, NULL);
memcpy (data, val, size);
} else {
size = mono_class_value_size (klass, NULL);
mono_value_copy_internal (data, val, klass);
}
return ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
return stackval_to_data (m_class_get_byval_arg (type->data.generic_class->container_class), val, data, pinvoke);
}
default:
g_error ("got type %x", type->type);
}
}
typedef struct {
MonoException *ex;
MonoContext *ctx;
} HandleExceptionCbData;
static void
handle_exception_cb (gpointer arg)
{
HandleExceptionCbData *cb_data = (HandleExceptionCbData*)arg;
mono_handle_exception (cb_data->ctx, (MonoObject*)cb_data->ex);
}
/*
* interp_throw:
* Throw an exception from the interpreter.
*/
static MONO_NEVER_INLINE void
interp_throw (ThreadContext *context, MonoException *ex, InterpFrame *frame, const guint16* ip, gboolean rethrow)
{
ERROR_DECL (error);
MonoLMFExt ext;
/*
* When explicitly throwing exception we pass the ip of the instruction that throws the exception.
* Offset the subtraction from interp_frame_get_ip, so we don't end up in prev instruction.
*/
frame->state.ip = ip + 1;
interp_push_lmf (&ext, frame);
if (mono_object_isinst_checked ((MonoObject *) ex, mono_defaults.exception_class, error)) {
MonoException *mono_ex = ex;
if (!rethrow) {
mono_ex->stack_trace = NULL;
mono_ex->trace_ips = NULL;
}
}
mono_error_assert_ok (error);
MonoContext ctx;
memset (&ctx, 0, sizeof (MonoContext));
MONO_CONTEXT_SET_SP (&ctx, frame);
/*
* Call the JIT EH code. The EH code will call back to us using:
* - mono_interp_set_resume_state ()/run_finally ()/run_filter ().
* Since ctx.ip is 0, this will start unwinding from the LMF frame
* pushed above, which points to our frames.
*/
mono_handle_exception (&ctx, (MonoObject*)ex);
interp_pop_lmf (&ext);
if (MONO_CONTEXT_GET_IP (&ctx) != 0) {
/* We need to unwind into non-interpreter code */
mono_restore_context (&ctx);
g_assert_not_reached ();
}
g_assert (context->has_resume_state);
}
static MONO_NEVER_INLINE MonoException *
interp_error_convert_to_exception (InterpFrame *frame, MonoError *error, const guint16 *ip)
{
MonoLMFExt ext;
MonoException *ex;
/*
* When calling runtime functions we pass the ip of the instruction triggering the runtime call.
* Offset the subtraction from interp_frame_get_ip, so we don't end up in prev instruction.
*/
frame->state.ip = ip + 1;
interp_push_lmf (&ext, frame);
ex = mono_error_convert_to_exception (error);
interp_pop_lmf (&ext);
return ex;
}
#define INTERP_BUILD_EXCEPTION_TYPE_FUNC_NAME(prefix_name, type_name) \
prefix_name ## _ ## type_name
#define INTERP_GET_EXCEPTION(exception_type) \
static MONO_NEVER_INLINE MonoException * \
INTERP_BUILD_EXCEPTION_TYPE_FUNC_NAME(interp_get_exception, exception_type) (InterpFrame *frame, const guint16 *ip)\
{ \
MonoLMFExt ext; \
MonoException *ex; \
frame->state.ip = ip + 1; \
interp_push_lmf (&ext, frame); \
ex = INTERP_BUILD_EXCEPTION_TYPE_FUNC_NAME(mono_get_exception,exception_type) (); \
interp_pop_lmf (&ext); \
return ex; \
}
#define INTERP_GET_EXCEPTION_CHAR_ARG(exception_type) \
static MONO_NEVER_INLINE MonoException * \
INTERP_BUILD_EXCEPTION_TYPE_FUNC_NAME(interp_get_exception, exception_type) (const char *arg, InterpFrame *frame, const guint16 *ip)\
{ \
MonoLMFExt ext; \
MonoException *ex; \
frame->state.ip = ip + 1; \
interp_push_lmf (&ext, frame); \
ex = INTERP_BUILD_EXCEPTION_TYPE_FUNC_NAME(mono_get_exception,exception_type) (arg); \
interp_pop_lmf (&ext); \
return ex; \
}
INTERP_GET_EXCEPTION(null_reference)
INTERP_GET_EXCEPTION(divide_by_zero)
INTERP_GET_EXCEPTION(overflow)
INTERP_GET_EXCEPTION(invalid_cast)
INTERP_GET_EXCEPTION(index_out_of_range)
INTERP_GET_EXCEPTION(array_type_mismatch)
INTERP_GET_EXCEPTION(arithmetic)
INTERP_GET_EXCEPTION_CHAR_ARG(argument_out_of_range)
// We conservatively pin exception object here to avoid tweaking the
// numerous call sites of this macro, even though, in a few cases,
// this is not needed.
#define THROW_EX_GENERAL(exception,ex_ip, rethrow) \
do { \
MonoException *__ex = (exception); \
MONO_HANDLE_ASSIGN_RAW (tmp_handle, (MonoObject*)__ex); \
interp_throw (context, __ex, (frame), (ex_ip), (rethrow)); \
MONO_HANDLE_ASSIGN_RAW (tmp_handle, (MonoObject*)NULL); \
goto resume; \
} while (0)
#define THROW_EX(exception,ex_ip) THROW_EX_GENERAL ((exception), (ex_ip), FALSE)
#define NULL_CHECK(o) do { \
if (G_UNLIKELY (!(o))) \
THROW_EX (interp_get_exception_null_reference (frame, ip), ip); \
} while (0)
#define EXCEPTION_CHECKPOINT \
do { \
if (mono_thread_interruption_request_flag && !mono_threads_is_critical_method (frame->imethod->method)) { \
MonoException *exc = mono_thread_interruption_checkpoint (); \
if (exc) \
THROW_EX_GENERAL (exc, ip, TRUE); \
} \
} while (0)
// Reduce duplicate code in interp_exec_method
static MONO_NEVER_INLINE void
do_safepoint (InterpFrame *frame, ThreadContext *context, const guint16 *ip)
{
MonoLMFExt ext;
/*
* When calling runtime functions we pass the ip of the instruction triggering the runtime call.
* Offset the subtraction from interp_frame_get_ip, so we don't end up in prev instruction.
*/
frame->state.ip = ip + 1;
interp_push_lmf (&ext, frame);
/* Poll safepoint */
mono_threads_safepoint ();
interp_pop_lmf (&ext);
}
#define SAFEPOINT \
do { \
if (G_UNLIKELY (mono_polling_required)) \
do_safepoint (frame, context, ip); \
} while (0)
static MonoObject*
ves_array_create (MonoClass *klass, int param_count, stackval *values, MonoError *error)
{
int rank = m_class_get_rank (klass);
uintptr_t *lengths = g_newa (uintptr_t, rank * 2);
intptr_t *lower_bounds = NULL;
if (param_count > rank && m_class_get_byval_arg (klass)->type == MONO_TYPE_SZARRAY) {
// Special constructor for jagged arrays
for (int i = 0; i < param_count; ++i)
lengths [i] = values [i].data.i;
return (MonoObject*) mono_array_new_jagged_checked (klass, param_count, lengths, error);
} else if (2 * rank == param_count) {
for (int l = 0; l < 2; ++l) {
int src = l;
int dst = l * rank;
for (int r = 0; r < rank; ++r, src += 2, ++dst) {
lengths [dst] = values [src].data.i;
}
}
/* lower bounds are first. */
lower_bounds = (intptr_t *) lengths;
lengths += rank;
} else {
/* Only lengths provided. */
for (int i = 0; i < param_count; ++i) {
lengths [i] = values [i].data.i;
}
}
return (MonoObject*) mono_array_new_full_checked (klass, lengths, lower_bounds, error);
}
static gint32
ves_array_calculate_index (MonoArray *ao, stackval *sp, gboolean safe)
{
MonoClass *ac = ((MonoObject *) ao)->vtable->klass;
guint32 pos = 0;
if (ao->bounds) {
for (gint32 i = 0; i < m_class_get_rank (ac); i++) {
gint32 idx = sp [i].data.i;
gint32 lower = ao->bounds [i].lower_bound;
guint32 len = ao->bounds [i].length;
if (safe && (idx < lower || (guint32)(idx - lower) >= len))
return -1;
pos = (pos * len) + (guint32)(idx - lower);
}
} else {
pos = sp [0].data.i;
if (safe && pos >= ao->max_length)
return -1;
}
return pos;
}
static MonoException*
ves_array_get (InterpFrame *frame, stackval *sp, stackval *retval, MonoMethodSignature *sig, gboolean safe)
{
MonoObject *o = sp->data.o;
MonoArray *ao = (MonoArray *) o;
MonoClass *ac = o->vtable->klass;
g_assert (m_class_get_rank (ac) >= 1);
gint32 pos = ves_array_calculate_index (ao, sp + 1, safe);
if (pos == -1)
return mono_get_exception_index_out_of_range ();
gint32 esize = mono_array_element_size (ac);
gconstpointer ea = mono_array_addr_with_size_fast (ao, esize, pos);
MonoType *mt = sig->ret;
stackval_from_data (mt, retval, ea, FALSE);
return NULL;
}
static MonoException*
ves_array_element_address (InterpFrame *frame, MonoClass *required_type, MonoArray *ao, gpointer *ret, stackval *sp, gboolean needs_typecheck)
{
MonoClass *ac = ((MonoObject *) ao)->vtable->klass;
g_assert (m_class_get_rank (ac) >= 1);
gint32 pos = ves_array_calculate_index (ao, sp, TRUE);
if (pos == -1)
return mono_get_exception_index_out_of_range ();
if (needs_typecheck && !mono_class_is_assignable_from_internal (m_class_get_element_class (mono_object_class ((MonoObject *) ao)), required_type))
return mono_get_exception_array_type_mismatch ();
gint32 esize = mono_array_element_size (ac);
*ret = mono_array_addr_with_size_fast (ao, esize, pos);
return NULL;
}
/* Does not handle `this` argument */
static guint32
compute_arg_offset (MonoMethodSignature *sig, int index, int prev_offset)
{
if (index == 0)
return 0;
if (prev_offset == -1) {
guint32 offset = 0;
for (int i = 0; i < index; i++) {
int size, align;
MonoType *type = sig->params [i];
size = mono_type_size (type, &align);
offset += ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
return offset;
} else {
int size, align;
MonoType *type = sig->params [index - 1];
size = mono_type_size (type, &align);
return prev_offset + ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
}
static guint32*
initialize_arg_offsets (InterpMethod *imethod, MonoMethodSignature *csig)
{
if (imethod->arg_offsets)
return imethod->arg_offsets;
// For pinvokes, csig represents the real signature with marshalled args. If an explicit
// marshalled signature was not provided, we use the managed signature of the method.
MonoMethodSignature *sig = csig;
if (!sig)
sig = mono_method_signature_internal (imethod->method);
int arg_count = sig->hasthis + sig->param_count;
g_assert (arg_count);
guint32 *arg_offsets = (guint32*) g_malloc ((sig->hasthis + sig->param_count) * sizeof (int));
int index = 0, offset_addend = 0, prev_offset = 0;
if (sig->hasthis) {
arg_offsets [index++] = 0;
offset_addend = MINT_STACK_SLOT_SIZE;
}
for (int i = 0; i < sig->param_count; i++) {
prev_offset = compute_arg_offset (sig, i, prev_offset);
arg_offsets [index++] = prev_offset + offset_addend;
}
mono_memory_write_barrier ();
if (mono_atomic_cas_ptr ((gpointer*)&imethod->arg_offsets, arg_offsets, NULL) != NULL)
g_free (arg_offsets);
return imethod->arg_offsets;
}
static guint32
get_arg_offset_fast (InterpMethod *imethod, MonoMethodSignature *sig, int index)
{
guint32 *arg_offsets = imethod->arg_offsets;
if (arg_offsets)
return arg_offsets [index];
arg_offsets = initialize_arg_offsets (imethod, sig);
g_assert (arg_offsets);
return arg_offsets [index];
}
static guint32
get_arg_offset (InterpMethod *imethod, MonoMethodSignature *sig, int index)
{
if (imethod) {
return get_arg_offset_fast (imethod, sig, index);
} else {
g_assert (!sig->hasthis);
return compute_arg_offset (sig, index, -1);
}
}
#ifdef MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE
static MonoFuncV mono_native_to_interp_trampoline = NULL;
#endif
#ifndef MONO_ARCH_HAVE_INTERP_PINVOKE_TRAMP
static InterpMethodArguments*
build_args_from_sig (MonoMethodSignature *sig, InterpFrame *frame)
{
InterpMethodArguments *margs = g_malloc0 (sizeof (InterpMethodArguments));
#ifdef TARGET_ARM
g_assert (mono_arm_eabi_supported ());
int i8_align = mono_arm_i8_align ();
#endif
#ifdef TARGET_WASM
margs->sig = sig;
#endif
if (sig->hasthis)
margs->ilen++;
for (int i = 0; i < sig->param_count; i++) {
guint32 ptype = m_type_is_byref (sig->params [i]) ? MONO_TYPE_PTR : sig->params [i]->type;
switch (ptype) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_CHAR:
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_I:
case MONO_TYPE_U:
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_STRING:
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_GENERICINST:
#if SIZEOF_VOID_P == 8
case MONO_TYPE_I8:
case MONO_TYPE_U8:
#endif
margs->ilen++;
break;
#if SIZEOF_VOID_P == 4
case MONO_TYPE_I8:
case MONO_TYPE_U8:
#ifdef TARGET_ARM
/* pairs begin at even registers */
if (i8_align == 8 && margs->ilen & 1)
margs->ilen++;
#endif
margs->ilen += 2;
break;
#endif
case MONO_TYPE_R4:
case MONO_TYPE_R8:
margs->flen++;
break;
default:
g_error ("build_args_from_sig: not implemented yet (1): 0x%x\n", ptype);
}
}
if (margs->ilen > 0)
margs->iargs = g_malloc0 (sizeof (gpointer) * margs->ilen);
if (margs->flen > 0)
margs->fargs = g_malloc0 (sizeof (double) * margs->flen);
if (margs->ilen > INTERP_ICALL_TRAMP_IARGS)
g_error ("build_args_from_sig: TODO, allocate gregs: %d\n", margs->ilen);
if (margs->flen > INTERP_ICALL_TRAMP_FARGS)
g_error ("build_args_from_sig: TODO, allocate fregs: %d\n", margs->flen);
size_t int_i = 0;
size_t int_f = 0;
if (sig->hasthis) {
margs->iargs [0] = frame->stack [0].data.p;
int_i++;
g_error ("FIXME if hasthis, we incorrectly access the args below");
}
for (int i = 0; i < sig->param_count; i++) {
guint32 offset = get_arg_offset (frame->imethod, sig, i);
stackval *sp_arg = STACK_ADD_BYTES (frame->stack, offset);
MonoType *type = sig->params [i];
guint32 ptype;
retry:
ptype = m_type_is_byref (type) ? MONO_TYPE_PTR : type->type;
switch (ptype) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_CHAR:
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_I:
case MONO_TYPE_U:
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_STRING:
#if SIZEOF_VOID_P == 8
case MONO_TYPE_I8:
case MONO_TYPE_U8:
#endif
margs->iargs [int_i] = sp_arg->data.p;
#if DEBUG_INTERP
g_print ("build_args_from_sig: margs->iargs [%d]: %p (frame @ %d)\n", int_i, margs->iargs [int_i], i);
#endif
int_i++;
break;
case MONO_TYPE_VALUETYPE:
if (m_class_is_enumtype (type->data.klass)) {
type = mono_class_enum_basetype_internal (type->data.klass);
goto retry;
}
margs->iargs [int_i] = sp_arg;
#if DEBUG_INTERP
g_print ("build_args_from_sig: margs->iargs [%d]: %p (vt) (frame @ %d)\n", int_i, margs->iargs [int_i], i);
#endif
#ifdef HOST_WASM
{
/* Scalar vtypes are passed by value */
if (mini_wasm_is_scalar_vtype (sig->params [i]))
margs->iargs [int_i] = *(gpointer*)margs->iargs [int_i];
}
#endif
int_i++;
break;
case MONO_TYPE_GENERICINST: {
MonoClass *container_class = type->data.generic_class->container_class;
type = m_class_get_byval_arg (container_class);
goto retry;
}
#if SIZEOF_VOID_P == 4
case MONO_TYPE_I8:
case MONO_TYPE_U8: {
#ifdef TARGET_ARM
/* pairs begin at even registers */
if (i8_align == 8 && int_i & 1)
int_i++;
#endif
margs->iargs [int_i] = (gpointer) sp_arg->data.pair.lo;
int_i++;
margs->iargs [int_i] = (gpointer) sp_arg->data.pair.hi;
#if DEBUG_INTERP
g_print ("build_args_from_sig: margs->iargs [%d/%d]: 0x%016" PRIx64 ", hi=0x%08x lo=0x%08x (frame @ %d)\n", int_i - 1, int_i, *((guint64 *) &margs->iargs [int_i - 1]), sp_arg->data.pair.hi, sp_arg->data.pair.lo, i);
#endif
int_i++;
break;
}
#endif
case MONO_TYPE_R4:
case MONO_TYPE_R8:
if (ptype == MONO_TYPE_R4)
* (float *) &(margs->fargs [int_f]) = sp_arg->data.f_r4;
else
margs->fargs [int_f] = sp_arg->data.f;
#if DEBUG_INTERP
g_print ("build_args_from_sig: margs->fargs [%d]: %p (%f) (frame @ %d)\n", int_f, margs->fargs [int_f], margs->fargs [int_f], i);
#endif
int_f ++;
break;
default:
g_error ("build_args_from_sig: not implemented yet (2): 0x%x\n", ptype);
}
}
switch (sig->ret->type) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_CHAR:
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_I:
case MONO_TYPE_U:
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_STRING:
case MONO_TYPE_I8:
case MONO_TYPE_U8:
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_GENERICINST:
margs->retval = (gpointer*)frame->retval;
margs->is_float_ret = 0;
break;
case MONO_TYPE_R4:
case MONO_TYPE_R8:
margs->retval = (gpointer*)frame->retval;
margs->is_float_ret = 1;
break;
case MONO_TYPE_VOID:
margs->retval = NULL;
break;
default:
g_error ("build_args_from_sig: ret type not implemented yet: 0x%x\n", sig->ret->type);
}
return margs;
}
#endif
static void
interp_frame_arg_to_data (MonoInterpFrameHandle frame, MonoMethodSignature *sig, int index, gpointer data)
{
InterpFrame *iframe = (InterpFrame*)frame;
InterpMethod *imethod = iframe->imethod;
// If index == -1, we finished executing an InterpFrame and the result is at retval.
if (index == -1)
stackval_to_data (sig->ret, iframe->retval, data, sig->pinvoke && !sig->marshalling_disabled);
else if (sig->hasthis && index == 0)
*(gpointer*)data = iframe->stack->data.p;
else
stackval_to_data (sig->params [index - sig->hasthis], STACK_ADD_BYTES (iframe->stack, get_arg_offset (imethod, sig, index)), data, sig->pinvoke && !sig->marshalling_disabled);
}
static void
interp_data_to_frame_arg (MonoInterpFrameHandle frame, MonoMethodSignature *sig, int index, gconstpointer data)
{
InterpFrame *iframe = (InterpFrame*)frame;
InterpMethod *imethod = iframe->imethod;
// Get result from pinvoke call, put it directly on top of execution stack in the caller frame
if (index == -1)
stackval_from_data (sig->ret, iframe->retval, data, sig->pinvoke && !sig->marshalling_disabled);
else if (sig->hasthis && index == 0)
iframe->stack->data.p = *(gpointer*)data;
else
stackval_from_data (sig->params [index - sig->hasthis], STACK_ADD_BYTES (iframe->stack, get_arg_offset (imethod, sig, index)), data, sig->pinvoke && !sig->marshalling_disabled);
}
static gpointer
interp_frame_arg_to_storage (MonoInterpFrameHandle frame, MonoMethodSignature *sig, int index)
{
InterpFrame *iframe = (InterpFrame*)frame;
InterpMethod *imethod = iframe->imethod;
if (index == -1)
return iframe->retval;
else
return STACK_ADD_BYTES (iframe->stack, get_arg_offset (imethod, sig, index));
}
static MonoPIFunc
get_interp_to_native_trampoline (void)
{
static MonoPIFunc trampoline = NULL;
if (!trampoline) {
if (mono_ee_features.use_aot_trampolines) {
trampoline = (MonoPIFunc) mono_aot_get_trampoline ("interp_to_native_trampoline");
} else {
MonoTrampInfo *info;
trampoline = (MonoPIFunc) mono_arch_get_interp_to_native_trampoline (&info);
mono_tramp_info_register (info, NULL);
}
mono_memory_barrier ();
}
return trampoline;
}
static void
interp_to_native_trampoline (gpointer addr, gpointer ccontext)
{
get_interp_to_native_trampoline () (addr, ccontext);
}
/* MONO_NO_OPTIMIZATION is needed due to usage of INTERP_PUSH_LMF_WITH_CTX. */
#ifdef _MSC_VER
#pragma optimize ("", off)
#endif
static MONO_NO_OPTIMIZATION MONO_NEVER_INLINE gpointer
ves_pinvoke_method (
InterpMethod *imethod,
MonoMethodSignature *sig,
MonoFuncV addr,
ThreadContext *context,
InterpFrame *parent_frame,
stackval *ret_sp,
stackval *sp,
gboolean save_last_error,
gpointer *cache,
gboolean *gc_transitions)
{
InterpFrame frame = {0};
frame.parent = parent_frame;
frame.imethod = imethod;
frame.stack = sp;
frame.retval = ret_sp;
MonoLMFExt ext;
gpointer args;
MONO_REQ_GC_UNSAFE_MODE;
#ifdef HOST_WASM
/*
* Use a per-signature entry function.
* Cache it in imethod->data_items.
* This is GC safe.
*/
MonoPIFunc entry_func = *cache;
if (!entry_func) {
entry_func = (MonoPIFunc)mono_wasm_get_interp_to_native_trampoline (sig);
mono_memory_barrier ();
*cache = entry_func;
}
#else
static MonoPIFunc entry_func = NULL;
if (!entry_func) {
MONO_ENTER_GC_UNSAFE;
#ifdef MONO_ARCH_HAS_NO_PROPER_MONOCTX
ERROR_DECL (error);
entry_func = (MonoPIFunc) mono_jit_compile_method_jit_only (mini_get_interp_lmf_wrapper ("mono_interp_to_native_trampoline", (gpointer) mono_interp_to_native_trampoline), error);
mono_error_assert_ok (error);
#else
entry_func = get_interp_to_native_trampoline ();
#endif
mono_memory_barrier ();
MONO_EXIT_GC_UNSAFE;
}
#endif
if (save_last_error) {
mono_marshal_clear_last_error ();
}
#ifdef MONO_ARCH_HAVE_INTERP_PINVOKE_TRAMP
CallContext ccontext;
mono_arch_set_native_call_context_args (&ccontext, &frame, sig);
args = &ccontext;
#else
InterpMethodArguments *margs = build_args_from_sig (sig, &frame);
args = margs;
#endif
INTERP_PUSH_LMF_WITH_CTX (&frame, ext, exit_pinvoke);
if (*gc_transitions) {
MONO_ENTER_GC_SAFE;
entry_func ((gpointer) addr, args);
MONO_EXIT_GC_SAFE;
*gc_transitions = FALSE;
} else {
entry_func ((gpointer) addr, args);
}
if (save_last_error)
mono_marshal_set_last_error ();
interp_pop_lmf (&ext);
#ifdef MONO_ARCH_HAVE_INTERP_PINVOKE_TRAMP
if (!context->has_resume_state) {
mono_arch_get_native_call_context_ret (&ccontext, &frame, sig);
}
g_free (ccontext.stack);
#else
// Only the vt address has been returned, we need to copy the entire content on interp stack
if (!context->has_resume_state && MONO_TYPE_ISSTRUCT (sig->ret))
stackval_from_data (sig->ret, frame.retval, (char*)frame.retval->data.p, sig->pinvoke && !sig->marshalling_disabled);
g_free (margs->iargs);
g_free (margs->fargs);
g_free (margs);
#endif
goto exit_pinvoke; // prevent unused label warning in some configurations
exit_pinvoke:
return NULL;
}
#ifdef _MSC_VER
#pragma optimize ("", on)
#endif
/*
* interp_init_delegate:
*
* Initialize del->interp_method.
*/
static void
interp_init_delegate (MonoDelegate *del, MonoDelegateTrampInfo **out_info, MonoError *error)
{
MonoMethod *method;
if (del->interp_method) {
/* Delegate created by a call to ves_icall_mono_delegate_ctor_interp () */
del->method = ((InterpMethod *)del->interp_method)->method;
} else if (del->method_ptr && !del->method) {
/* Delegate created from methodInfo.MethodHandle.GetFunctionPointer() */
del->interp_method = (InterpMethod *)del->method_ptr;
if (mono_llvm_only)
// FIXME:
g_assert_not_reached ();
} else if (del->method) {
/* Delegate created dynamically */
del->interp_method = mono_interp_get_imethod (del->method, error);
} else {
/* Created from JITted code */
g_assert_not_reached ();
}
method = ((InterpMethod*)del->interp_method)->method;
if (del->target &&
method &&
method->flags & METHOD_ATTRIBUTE_VIRTUAL &&
method->flags & METHOD_ATTRIBUTE_ABSTRACT &&
mono_class_is_abstract (method->klass))
del->interp_method = get_virtual_method ((InterpMethod*)del->interp_method, del->target->vtable);
method = ((InterpMethod*)del->interp_method)->method;
if (method && m_class_get_parent (method->klass) == mono_defaults.multicastdelegate_class) {
const char *name = method->name;
if (*name == 'I' && (strcmp (name, "Invoke") == 0)) {
/*
* When invoking the delegate interp_method is executed directly. If it's an
* invoke make sure we replace it with the appropriate delegate invoke wrapper.
*
* FIXME We should do this later, when we also know the delegate on which the
* target method is called.
*/
del->interp_method = mono_interp_get_imethod (mono_marshal_get_delegate_invoke (method, NULL), error);
mono_error_assert_ok (error);
}
}
if (!((InterpMethod *) del->interp_method)->transformed && method_is_dynamic (method)) {
/* Return any errors from method compilation */
mono_interp_transform_method ((InterpMethod *) del->interp_method, get_context (), error);
return_if_nok (error);
}
/*
* Compute a MonoDelegateTrampInfo for this delegate if possible and pass it back to
* the caller.
* Keep a 1 element cache in imethod->del_info. This should be good enough since most methods
* are only associated with one delegate type.
*/
if (out_info)
*out_info = NULL;
if (mono_llvm_only) {
InterpMethod *imethod = del->interp_method;
method = imethod->method;
if (imethod->del_info && imethod->del_info->klass == del->object.vtable->klass) {
*out_info = imethod->del_info;
} else if (!imethod->del_info) {
imethod->del_info = mono_create_delegate_trampoline_info (del->object.vtable->klass, method);
*out_info = imethod->del_info;
}
}
}
/* Convert a function pointer for a managed method to an InterpMethod* */
static InterpMethod*
ftnptr_to_imethod (gpointer addr, gboolean *need_unbox)
{
InterpMethod *imethod;
if (mono_llvm_only) {
ERROR_DECL (error);
/* Function pointers are represented by a MonoFtnDesc structure */
MonoFtnDesc *ftndesc = (MonoFtnDesc*)addr;
g_assert (ftndesc);
g_assert (ftndesc->method);
if (!ftndesc->interp_method) {
imethod = mono_interp_get_imethod (ftndesc->method, error);
mono_error_assert_ok (error);
mono_memory_barrier ();
// FIXME Handle unboxing here ?
ftndesc->interp_method = imethod;
}
*need_unbox = INTERP_IMETHOD_IS_TAGGED_UNBOX (ftndesc->interp_method);
imethod = INTERP_IMETHOD_UNTAG_UNBOX (ftndesc->interp_method);
} else {
/* Function pointers are represented by their InterpMethod */
*need_unbox = INTERP_IMETHOD_IS_TAGGED_UNBOX (addr);
imethod = INTERP_IMETHOD_UNTAG_UNBOX (addr);
}
return imethod;
}
static gpointer
imethod_to_ftnptr (InterpMethod *imethod, gboolean need_unbox)
{
if (mono_llvm_only) {
ERROR_DECL (error);
/* Function pointers are represented by a MonoFtnDesc structure */
MonoFtnDesc **ftndesc_p;
if (need_unbox)
ftndesc_p = &imethod->ftndesc_unbox;
else
ftndesc_p = &imethod->ftndesc;
if (!*ftndesc_p) {
MonoFtnDesc *ftndesc = mini_llvmonly_load_method_ftndesc (imethod->method, FALSE, need_unbox, error);
mono_error_assert_ok (error);
if (need_unbox)
ftndesc->interp_method = INTERP_IMETHOD_TAG_UNBOX (imethod);
else
ftndesc->interp_method = imethod;
mono_memory_barrier ();
*ftndesc_p = ftndesc;
}
return *ftndesc_p;
} else {
if (need_unbox)
return INTERP_IMETHOD_TAG_UNBOX (imethod);
else
return imethod;
}
}
static void
interp_delegate_ctor (MonoObjectHandle this_obj, MonoObjectHandle target, gpointer addr, MonoError *error)
{
gboolean need_unbox;
/* addr is the result of an LDFTN opcode */
InterpMethod *imethod = ftnptr_to_imethod (addr, &need_unbox);
if (!(imethod->method->flags & METHOD_ATTRIBUTE_STATIC)) {
MonoMethod *invoke = mono_get_delegate_invoke_internal (mono_handle_class (this_obj));
/* virtual invoke delegates must not have null check */
if (mono_method_signature_internal (imethod->method)->param_count == mono_method_signature_internal (invoke)->param_count
&& MONO_HANDLE_IS_NULL (target)) {
mono_error_set_argument (error, "this", "Delegate to an instance method cannot have null 'this'");
return;
}
}
g_assert (imethod->method);
gpointer entry = mini_get_interp_callbacks ()->create_method_pointer (imethod->method, FALSE, error);
return_if_nok (error);
MONO_HANDLE_SETVAL (MONO_HANDLE_CAST (MonoDelegate, this_obj), interp_method, gpointer, imethod);
mono_delegate_ctor (this_obj, target, entry, imethod->method, error);
}
#if DEBUG_INTERP
static void
dump_stackval (GString *str, stackval *s, MonoType *type)
{
switch (type->type) {
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_CHAR:
case MONO_TYPE_BOOLEAN:
g_string_append_printf (str, "[%d] ", s->data.i);
break;
case MONO_TYPE_STRING:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_ARRAY:
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
case MONO_TYPE_I:
case MONO_TYPE_U:
g_string_append_printf (str, "[%p] ", s->data.p);
break;
case MONO_TYPE_VALUETYPE:
if (m_class_is_enumtype (type->data.klass))
g_string_append_printf (str, "[%d] ", s->data.i);
else
g_string_append_printf (str, "[vt:%p] ", s->data.p);
break;
case MONO_TYPE_R4:
g_string_append_printf (str, "[%g] ", s->data.f_r4);
break;
case MONO_TYPE_R8:
g_string_append_printf (str, "[%g] ", s->data.f);
break;
case MONO_TYPE_I8:
case MONO_TYPE_U8:
default: {
GString *res = g_string_new ("");
mono_type_get_desc (res, type, TRUE);
g_string_append_printf (str, "[{%s} %" PRId64 "/0x%0" PRIx64 "] ", res->str, (gint64)s->data.l, (guint64)s->data.l);
g_string_free (res, TRUE);
break;
}
}
}
static char*
dump_retval (InterpFrame *inv)
{
GString *str = g_string_new ("");
MonoType *ret = mono_method_signature_internal (inv->imethod->method)->ret;
if (ret->type != MONO_TYPE_VOID)
dump_stackval (str, inv->stack, ret);
return g_string_free (str, FALSE);
}
static char*
dump_args (InterpFrame *inv)
{
GString *str = g_string_new ("");
int i;
MonoMethodSignature *signature = mono_method_signature_internal (inv->imethod->method);
if (signature->param_count == 0 && !signature->hasthis)
return g_string_free (str, FALSE);
if (signature->hasthis) {
MonoMethod *method = inv->imethod->method;
dump_stackval (str, inv->stack, m_class_get_byval_arg (method->klass));
}
for (i = 0; i < signature->param_count; ++i)
dump_stackval (str, inv->stack + (!!signature->hasthis) + i, signature->params [i]);
return g_string_free (str, FALSE);
}
#endif
#define CHECK_ADD_OVERFLOW(a,b) \
(gint32)(b) >= 0 ? (gint32)(G_MAXINT32) - (gint32)(b) < (gint32)(a) ? -1 : 0 \
: (gint32)(G_MININT32) - (gint32)(b) > (gint32)(a) ? +1 : 0
#define CHECK_SUB_OVERFLOW(a,b) \
(gint32)(b) < 0 ? (gint32)(G_MAXINT32) + (gint32)(b) < (gint32)(a) ? -1 : 0 \
: (gint32)(G_MININT32) + (gint32)(b) > (gint32)(a) ? +1 : 0
#define CHECK_ADD_OVERFLOW_UN(a,b) \
(guint32)(G_MAXUINT32) - (guint32)(b) < (guint32)(a) ? -1 : 0
#define CHECK_SUB_OVERFLOW_UN(a,b) \
(guint32)(a) < (guint32)(b) ? -1 : 0
#define CHECK_ADD_OVERFLOW64(a,b) \
(gint64)(b) >= 0 ? (gint64)(G_MAXINT64) - (gint64)(b) < (gint64)(a) ? -1 : 0 \
: (gint64)(G_MININT64) - (gint64)(b) > (gint64)(a) ? +1 : 0
#define CHECK_SUB_OVERFLOW64(a,b) \
(gint64)(b) < 0 ? (gint64)(G_MAXINT64) + (gint64)(b) < (gint64)(a) ? -1 : 0 \
: (gint64)(G_MININT64) + (gint64)(b) > (gint64)(a) ? +1 : 0
#define CHECK_ADD_OVERFLOW64_UN(a,b) \
(guint64)(G_MAXUINT64) - (guint64)(b) < (guint64)(a) ? -1 : 0
#define CHECK_SUB_OVERFLOW64_UN(a,b) \
(guint64)(a) < (guint64)(b) ? -1 : 0
#if SIZEOF_VOID_P == 4
#define CHECK_ADD_OVERFLOW_NAT(a,b) CHECK_ADD_OVERFLOW(a,b)
#define CHECK_ADD_OVERFLOW_NAT_UN(a,b) CHECK_ADD_OVERFLOW_UN(a,b)
#else
#define CHECK_ADD_OVERFLOW_NAT(a,b) CHECK_ADD_OVERFLOW64(a,b)
#define CHECK_ADD_OVERFLOW_NAT_UN(a,b) CHECK_ADD_OVERFLOW64_UN(a,b)
#endif
/* Resolves to TRUE if the operands would overflow */
#define CHECK_MUL_OVERFLOW(a,b) \
((gint32)(a) == 0) || ((gint32)(b) == 0) ? 0 : \
(((gint32)(a) > 0) && ((gint32)(b) == -1)) ? FALSE : \
(((gint32)(a) < 0) && ((gint32)(b) == -1)) ? (a == G_MININT32) : \
(((gint32)(a) > 0) && ((gint32)(b) > 0)) ? (gint32)(a) > ((G_MAXINT32) / (gint32)(b)) : \
(((gint32)(a) > 0) && ((gint32)(b) < 0)) ? (gint32)(a) > ((G_MININT32) / (gint32)(b)) : \
(((gint32)(a) < 0) && ((gint32)(b) > 0)) ? (gint32)(a) < ((G_MININT32) / (gint32)(b)) : \
(gint32)(a) < ((G_MAXINT32) / (gint32)(b))
#define CHECK_MUL_OVERFLOW_UN(a,b) \
((guint32)(a) == 0) || ((guint32)(b) == 0) ? 0 : \
(guint32)(b) > ((G_MAXUINT32) / (guint32)(a))
#define CHECK_MUL_OVERFLOW64(a,b) \
((gint64)(a) == 0) || ((gint64)(b) == 0) ? 0 : \
(((gint64)(a) > 0) && ((gint64)(b) == -1)) ? FALSE : \
(((gint64)(a) < 0) && ((gint64)(b) == -1)) ? (a == G_MININT64) : \
(((gint64)(a) > 0) && ((gint64)(b) > 0)) ? (gint64)(a) > ((G_MAXINT64) / (gint64)(b)) : \
(((gint64)(a) > 0) && ((gint64)(b) < 0)) ? (gint64)(a) > ((G_MININT64) / (gint64)(b)) : \
(((gint64)(a) < 0) && ((gint64)(b) > 0)) ? (gint64)(a) < ((G_MININT64) / (gint64)(b)) : \
(gint64)(a) < ((G_MAXINT64) / (gint64)(b))
#define CHECK_MUL_OVERFLOW64_UN(a,b) \
((guint64)(a) == 0) || ((guint64)(b) == 0) ? 0 : \
(guint64)(b) > ((G_MAXUINT64) / (guint64)(a))
#if SIZEOF_VOID_P == 4
#define CHECK_MUL_OVERFLOW_NAT(a,b) CHECK_MUL_OVERFLOW(a,b)
#define CHECK_MUL_OVERFLOW_NAT_UN(a,b) CHECK_MUL_OVERFLOW_UN(a,b)
#else
#define CHECK_MUL_OVERFLOW_NAT(a,b) CHECK_MUL_OVERFLOW64(a,b)
#define CHECK_MUL_OVERFLOW_NAT_UN(a,b) CHECK_MUL_OVERFLOW64_UN(a,b)
#endif
// Do not inline in case order of frame addresses matters.
static MONO_NEVER_INLINE MonoObject*
interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc, MonoError *error)
{
ThreadContext *context = get_context ();
MonoMethodSignature *sig = mono_method_signature_internal (method);
stackval *sp = (stackval*)context->stack_pointer;
MonoMethod *target_method = method;
error_init (error);
if (exc)
*exc = NULL;
if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
target_method = mono_marshal_get_native_wrapper (target_method, FALSE, FALSE);
MonoMethod *invoke_wrapper = mono_marshal_get_runtime_invoke_full (target_method, FALSE, TRUE);
//* <code>MonoObject *runtime_invoke (MonoObject *this_obj, void **params, MonoObject **exc, void* method)</code>
if (sig->hasthis)
sp [0].data.p = obj;
else
sp [0].data.p = NULL;
sp [1].data.p = params;
sp [2].data.p = exc;
sp [3].data.p = target_method;
InterpMethod *imethod = mono_interp_get_imethod (invoke_wrapper, error);
mono_error_assert_ok (error);
InterpFrame frame = {0};
frame.imethod = imethod;
frame.stack = sp;
frame.retval = sp;
// The method to execute might not be transformed yet, so we don't know how much stack
// it uses. We bump the stack_pointer here so any code triggered by method compilation
// will not attempt to use the space that we used to push the args for this method.
// The real top of stack for this method will be set in interp_exec_method once the
// method is transformed.
context->stack_pointer = (guchar*)(sp + 4);
g_assert (context->stack_pointer < context->stack_end);
MONO_ENTER_GC_UNSAFE;
interp_exec_method (&frame, context, NULL);
MONO_EXIT_GC_UNSAFE;
context->stack_pointer = (guchar*)sp;
check_pending_unwind (context);
if (context->has_resume_state) {
/*
* This can happen on wasm where native frames cannot be skipped during EH.
* EH processing will continue when control returns to the interpreter.
*/
return NULL;
}
// The return value is at the bottom of the stack
return frame.stack->data.o;
}
typedef struct {
InterpMethod *rmethod;
gpointer this_arg;
gpointer res;
gpointer args [16];
gpointer *many_args;
} InterpEntryData;
/* Main function for entering the interpreter from compiled code */
// Do not inline in case order of frame addresses matters.
static MONO_NEVER_INLINE void
interp_entry (InterpEntryData *data)
{
InterpMethod *rmethod;
ThreadContext *context;
stackval *sp, *sp_args;
MonoMethod *method;
MonoMethodSignature *sig;
MonoType *type;
gpointer orig_domain = NULL, attach_cookie;
int i;
if ((gsize)data->rmethod & 1) {
/* Unbox */
data->this_arg = mono_object_unbox_internal ((MonoObject*)data->this_arg);
data->rmethod = (InterpMethod*)(gpointer)((gsize)data->rmethod & ~1);
}
rmethod = data->rmethod;
if (rmethod->needs_thread_attach)
orig_domain = mono_threads_attach_coop (mono_domain_get (), &attach_cookie);
context = get_context ();
sp_args = sp = (stackval*)context->stack_pointer;
method = rmethod->method;
if (m_class_get_parent (method->klass) == mono_defaults.multicastdelegate_class && !strcmp (method->name, "Invoke")) {
/*
* This happens when AOT code for the invoke wrapper is not found.
* Have to replace the method with the wrapper here, since the wrapper depends on the delegate.
*/
ERROR_DECL (error);
MonoDelegate *del = (MonoDelegate*)data->this_arg;
// FIXME: This is slow
method = mono_marshal_get_delegate_invoke (method, del);
data->rmethod = mono_interp_get_imethod (method, error);
mono_error_assert_ok (error);
}
sig = mono_method_signature_internal (method);
// FIXME: Optimize this
if (sig->hasthis) {
sp_args->data.p = data->this_arg;
sp_args++;
}
gpointer *params;
if (data->many_args)
params = data->many_args;
else
params = data->args;
for (i = 0; i < sig->param_count; ++i) {
if (m_type_is_byref (sig->params [i])) {
sp_args->data.p = params [i];
sp_args++;
} else {
int size = stackval_from_data (sig->params [i], sp_args, params [i], FALSE);
sp_args = STACK_ADD_BYTES (sp_args, size);
}
}
InterpFrame frame = {0};
frame.imethod = data->rmethod;
frame.stack = sp;
frame.retval = sp;
context->stack_pointer = (guchar*)sp_args;
g_assert (context->stack_pointer < context->stack_end);
MONO_ENTER_GC_UNSAFE;
interp_exec_method (&frame, context, NULL);
MONO_EXIT_GC_UNSAFE;
context->stack_pointer = (guchar*)sp;
if (rmethod->needs_thread_attach)
mono_threads_detach_coop (orig_domain, &attach_cookie);
check_pending_unwind (context);
if (mono_llvm_only) {
if (context->has_resume_state)
/* The exception will be handled in a frame above us */
mono_llvm_cpp_throw_exception ();
} else {
g_assert (!context->has_resume_state);
}
// The return value is at the bottom of the stack, after the locals space
type = rmethod->rtype;
if (type->type != MONO_TYPE_VOID)
stackval_to_data (type, frame.stack, data->res, FALSE);
}
static void
do_icall (MonoMethodSignature *sig, int op, stackval *ret_sp, stackval *sp, gpointer ptr, gboolean save_last_error)
{
if (save_last_error)
mono_marshal_clear_last_error ();
switch (op) {
case MINT_ICALL_V_V: {
typedef void (*T)(void);
T func = (T)ptr;
func ();
break;
}
case MINT_ICALL_V_P: {
typedef gpointer (*T)(void);
T func = (T)ptr;
ret_sp->data.p = func ();
break;
}
case MINT_ICALL_P_V: {
typedef void (*T)(gpointer);
T func = (T)ptr;
func (sp [0].data.p);
break;
}
case MINT_ICALL_P_P: {
typedef gpointer (*T)(gpointer);
T func = (T)ptr;
ret_sp->data.p = func (sp [0].data.p);
break;
}
case MINT_ICALL_PP_V: {
typedef void (*T)(gpointer,gpointer);
T func = (T)ptr;
func (sp [0].data.p, sp [1].data.p);
break;
}
case MINT_ICALL_PP_P: {
typedef gpointer (*T)(gpointer,gpointer);
T func = (T)ptr;
ret_sp->data.p = func (sp [0].data.p, sp [1].data.p);
break;
}
case MINT_ICALL_PPP_V: {
typedef void (*T)(gpointer,gpointer,gpointer);
T func = (T)ptr;
func (sp [0].data.p, sp [1].data.p, sp [2].data.p);
break;
}
case MINT_ICALL_PPP_P: {
typedef gpointer (*T)(gpointer,gpointer,gpointer);
T func = (T)ptr;
ret_sp->data.p = func (sp [0].data.p, sp [1].data.p, sp [2].data.p);
break;
}
case MINT_ICALL_PPPP_V: {
typedef void (*T)(gpointer,gpointer,gpointer,gpointer);
T func = (T)ptr;
func (sp [0].data.p, sp [1].data.p, sp [2].data.p, sp [3].data.p);
break;
}
case MINT_ICALL_PPPP_P: {
typedef gpointer (*T)(gpointer,gpointer,gpointer,gpointer);
T func = (T)ptr;
ret_sp->data.p = func (sp [0].data.p, sp [1].data.p, sp [2].data.p, sp [3].data.p);
break;
}
case MINT_ICALL_PPPPP_V: {
typedef void (*T)(gpointer,gpointer,gpointer,gpointer,gpointer);
T func = (T)ptr;
func (sp [0].data.p, sp [1].data.p, sp [2].data.p, sp [3].data.p, sp [4].data.p);
break;
}
case MINT_ICALL_PPPPP_P: {
typedef gpointer (*T)(gpointer,gpointer,gpointer,gpointer,gpointer);
T func = (T)ptr;
ret_sp->data.p = func (sp [0].data.p, sp [1].data.p, sp [2].data.p, sp [3].data.p, sp [4].data.p);
break;
}
case MINT_ICALL_PPPPPP_V: {
typedef void (*T)(gpointer,gpointer,gpointer,gpointer,gpointer,gpointer);
T func = (T)ptr;
func (sp [0].data.p, sp [1].data.p, sp [2].data.p, sp [3].data.p, sp [4].data.p, sp [5].data.p);
break;
}
case MINT_ICALL_PPPPPP_P: {
typedef gpointer (*T)(gpointer,gpointer,gpointer,gpointer,gpointer,gpointer);
T func = (T)ptr;
ret_sp->data.p = func (sp [0].data.p, sp [1].data.p, sp [2].data.p, sp [3].data.p, sp [4].data.p, sp [5].data.p);
break;
}
default:
g_assert_not_reached ();
}
if (save_last_error)
mono_marshal_set_last_error ();
/* convert the native representation to the stackval representation */
if (sig)
stackval_from_data (sig->ret, ret_sp, (char*) &ret_sp->data.p, sig->pinvoke && !sig->marshalling_disabled);
}
/* MONO_NO_OPTIMIZATION is needed due to usage of INTERP_PUSH_LMF_WITH_CTX. */
#ifdef _MSC_VER
#pragma optimize ("", off)
#endif
// Do not inline in case order of frame addresses matters, and maybe other reasons.
static MONO_NO_OPTIMIZATION MONO_NEVER_INLINE gpointer
do_icall_wrapper (InterpFrame *frame, MonoMethodSignature *sig, int op, stackval *ret_sp, stackval *sp, gpointer ptr, gboolean save_last_error, gboolean *gc_transitions)
{
MonoLMFExt ext;
INTERP_PUSH_LMF_WITH_CTX (frame, ext, exit_icall);
if (*gc_transitions) {
MONO_ENTER_GC_SAFE;
do_icall (sig, op, ret_sp, sp, ptr, save_last_error);
MONO_EXIT_GC_SAFE;
*gc_transitions = FALSE;
} else {
do_icall (sig, op, ret_sp, sp, ptr, save_last_error);
}
interp_pop_lmf (&ext);
goto exit_icall; // prevent unused label warning in some configurations
/* If an exception is thrown from native code, execution will continue here */
exit_icall:
return NULL;
}
#ifdef _MSC_VER
#pragma optimize ("", on)
#endif
typedef struct {
int pindex;
gpointer jit_wrapper;
gpointer *args;
gpointer extra_arg;
MonoFtnDesc ftndesc;
} JitCallCbData;
/* Callback called by mono_llvm_cpp_catch_exception () */
static void
jit_call_cb (gpointer arg)
{
JitCallCbData *cb_data = (JitCallCbData*)arg;
gpointer jit_wrapper = cb_data->jit_wrapper;
int pindex = cb_data->pindex;
gpointer *args = cb_data->args;
gpointer ftndesc = cb_data->extra_arg;
switch (pindex) {
case 0: {
typedef void (*T)(gpointer);
T func = (T)jit_wrapper;
func (ftndesc);
break;
}
case 1: {
typedef void (*T)(gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], ftndesc);
break;
}
case 2: {
typedef void (*T)(gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], ftndesc);
break;
}
case 3: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], args [2], ftndesc);
break;
}
case 4: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], args [2], args [3], ftndesc);
break;
}
case 5: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], args [2], args [3], args [4], ftndesc);
break;
}
case 6: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], args [2], args [3], args [4], args [5], ftndesc);
break;
}
case 7: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], args [2], args [3], args [4], args [5], args [6], ftndesc);
break;
}
case 8: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], ftndesc);
break;
}
default:
g_assert_not_reached ();
break;
}
}
enum {
/* Pass stackval->data.p */
JIT_ARG_BYVAL,
/* Pass &stackval->data.p */
JIT_ARG_BYREF
};
enum {
JIT_RET_VOID,
JIT_RET_SCALAR,
JIT_RET_VTYPE
};
typedef struct _JitCallInfo JitCallInfo;
struct _JitCallInfo {
gpointer addr;
gpointer extra_arg;
gpointer wrapper;
MonoMethodSignature *sig;
guint8 *arginfo;
gint32 res_size;
int ret_mt;
gboolean no_wrapper;
};
static MONO_NEVER_INLINE void
init_jit_call_info (InterpMethod *rmethod, MonoError *error)
{
MonoMethodSignature *sig;
JitCallInfo *cinfo;
//printf ("jit_call: %s\n", mono_method_full_name (rmethod->method, 1));
MonoMethod *method = rmethod->method;
// FIXME: Memory management
cinfo = g_new0 (JitCallInfo, 1);
sig = mono_method_signature_internal (method);
g_assert (sig);
gpointer addr = mono_jit_compile_method_jit_only (method, error);
return_if_nok (error);
g_assert (addr);
gboolean need_wrapper = TRUE;
if (mono_llvm_only) {
MonoAotMethodFlags flags = mono_aot_get_method_flags (addr);
if (flags & MONO_AOT_METHOD_FLAG_GSHAREDVT_VARIABLE) {
/*
* The callee already has a gsharedvt signature, we can call it directly
* instead of through a gsharedvt out wrapper.
*/
need_wrapper = FALSE;
cinfo->no_wrapper = TRUE;
}
}
gpointer jit_wrapper = NULL;
if (need_wrapper) {
MonoMethod *wrapper = mini_get_gsharedvt_out_sig_wrapper (sig);
jit_wrapper = mono_jit_compile_method_jit_only (wrapper, error);
mono_error_assert_ok (error);
}
if (mono_llvm_only) {
gboolean caller_gsharedvt = !need_wrapper;
cinfo->addr = mini_llvmonly_add_method_wrappers (method, addr, caller_gsharedvt, FALSE, &cinfo->extra_arg);
} else {
cinfo->addr = addr;
}
cinfo->sig = sig;
cinfo->wrapper = jit_wrapper;
if (sig->ret->type != MONO_TYPE_VOID) {
int mt = mint_type (sig->ret);
if (mt == MINT_TYPE_VT) {
MonoClass *klass = mono_class_from_mono_type_internal (sig->ret);
/*
* We cache this size here, instead of the instruction stream of the
* calling instruction, to save space for common callvirt instructions
* that could end up doing a jit call.
*/
gint32 size = mono_class_value_size (klass, NULL);
cinfo->res_size = ALIGN_TO (size, MINT_VT_ALIGNMENT);
} else {
cinfo->res_size = MINT_STACK_SLOT_SIZE;
}
cinfo->ret_mt = mt;
} else {
cinfo->ret_mt = -1;
}
if (sig->param_count) {
cinfo->arginfo = g_new0 (guint8, sig->param_count);
for (int i = 0; i < rmethod->param_count; ++i) {
MonoType *t = rmethod->param_types [i];
int mt = mint_type (t);
if (m_type_is_byref (sig->params [i])) {
cinfo->arginfo [i] = JIT_ARG_BYVAL;
} else if (mt == MINT_TYPE_O) {
cinfo->arginfo [i] = JIT_ARG_BYREF;
} else {
/* stackval->data is an union */
cinfo->arginfo [i] = JIT_ARG_BYREF;
}
}
}
mono_memory_barrier ();
rmethod->jit_call_info = cinfo;
}
static MONO_NEVER_INLINE void
do_jit_call (ThreadContext *context, stackval *ret_sp, stackval *sp, InterpFrame *frame, InterpMethod *rmethod, MonoError *error)
{
MonoLMFExt ext;
JitCallInfo *cinfo;
//printf ("jit_call: %s\n", mono_method_full_name (rmethod->method, 1));
/*
* Call JITted code through a gsharedvt_out wrapper. These wrappers receive every argument
* by ref and return a return value using an explicit return value argument.
*/
if (G_UNLIKELY (!rmethod->jit_call_info)) {
init_jit_call_info (rmethod, error);
mono_error_assert_ok (error);
}
cinfo = (JitCallInfo*)rmethod->jit_call_info;
/*
* Convert the arguments on the interpeter stack to the format expected by the gsharedvt_out wrapper.
*/
gpointer args [32];
int pindex = 0;
int stack_index = 0;
if (rmethod->hasthis) {
args [pindex ++] = sp [0].data.p;
stack_index ++;
}
/* return address */
if (cinfo->ret_mt != -1)
args [pindex ++] = ret_sp;
for (int i = 0; i < rmethod->param_count; ++i) {
stackval *sval = STACK_ADD_BYTES (sp, get_arg_offset_fast (rmethod, NULL, stack_index + i));
if (cinfo->arginfo [i] == JIT_ARG_BYVAL)
args [pindex ++] = sval->data.p;
else
/* data is an union, so can use 'p' for all types */
args [pindex ++] = sval;
}
JitCallCbData cb_data;
memset (&cb_data, 0, sizeof (cb_data));
cb_data.pindex = pindex;
cb_data.args = args;
if (cinfo->no_wrapper) {
cb_data.jit_wrapper = cinfo->addr;
cb_data.extra_arg = cinfo->extra_arg;
} else {
cb_data.ftndesc.addr = cinfo->addr;
cb_data.ftndesc.arg = cinfo->extra_arg;
cb_data.jit_wrapper = cinfo->wrapper;
cb_data.extra_arg = &cb_data.ftndesc;
}
interp_push_lmf (&ext, frame);
gboolean thrown = FALSE;
if (mono_aot_mode == MONO_AOT_MODE_LLVMONLY_INTERP) {
/* Catch the exception thrown by the native code using a try-catch */
mono_llvm_cpp_catch_exception (jit_call_cb, &cb_data, &thrown);
} else {
jit_call_cb (&cb_data);
}
interp_pop_lmf (&ext);
if (thrown) {
if (context->has_resume_state)
/*
* This happens when interp_entry calls mono_llvm_reraise_exception ().
*/
return;
MonoJitTlsData *jit_tls = mono_get_jit_tls ();
if (jit_tls->resume_state.il_state) {
/*
* This c++ exception is going to be caught by an AOTed frame above us.
* We can't rethrow here, since that will skip the cleanup of the
* interpreter stack space etc. So instruct the interpreter to unwind.
*/
context->has_resume_state = TRUE;
context->handler_frame = NULL;
return;
}
MonoObject *obj = mini_llvmonly_load_exception ();
g_assert (obj);
mini_llvmonly_clear_exception ();
mono_error_set_exception_instance (error, (MonoException*)obj);
return;
}
if (cinfo->ret_mt != -1) {
// Sign/zero extend if necessary
switch (cinfo->ret_mt) {
case MINT_TYPE_I1:
ret_sp->data.i = *(gint8*)ret_sp;
break;
case MINT_TYPE_U1:
ret_sp->data.i = *(guint8*)ret_sp;
break;
case MINT_TYPE_I2:
ret_sp->data.i = *(gint16*)ret_sp;
break;
case MINT_TYPE_U2:
ret_sp->data.i = *(guint16*)ret_sp;
break;
case MINT_TYPE_I4:
case MINT_TYPE_I8:
case MINT_TYPE_R4:
case MINT_TYPE_R8:
case MINT_TYPE_VT:
case MINT_TYPE_O:
/* The result was written to ret_sp */
break;
default:
g_assert_not_reached ();
}
}
}
static MONO_NEVER_INLINE void
do_debugger_tramp (void (*tramp) (void), InterpFrame *frame)
{
MonoLMFExt ext;
interp_push_lmf (&ext, frame);
tramp ();
interp_pop_lmf (&ext);
}
static MONO_NEVER_INLINE MonoException*
do_transform_method (InterpMethod *imethod, InterpFrame *frame, ThreadContext *context)
{
MonoLMFExt ext;
/* Don't push lmf if we have no interp data */
gboolean push_lmf = frame->parent != NULL;
MonoException *ex = NULL;
ERROR_DECL (error);
/* Use the parent frame as the current frame is not complete yet */
if (push_lmf)
interp_push_lmf (&ext, frame->parent);
#if DEBUG_INTERP
if (imethod->method) {
char* mn = mono_method_full_name (imethod->method, TRUE);
g_print ("(%p) Transforming %s\n", mono_thread_internal_current (), mn);
g_free (mn);
}
#endif
mono_interp_transform_method (imethod, context, error);
if (!is_ok (error))
ex = mono_error_convert_to_exception (error);
if (push_lmf)
interp_pop_lmf (&ext);
return ex;
}
static void
init_arglist (InterpFrame *frame, MonoMethodSignature *sig, stackval *sp, char *arglist)
{
*(gpointer*)arglist = sig;
arglist += sizeof (gpointer);
for (int i = sig->sentinelpos; i < sig->param_count; i++) {
int align, arg_size, sv_size;
arg_size = mono_type_stack_size (sig->params [i], &align);
arglist = (char*)ALIGN_PTR_TO (arglist, align);
sv_size = stackval_to_data (sig->params [i], sp, arglist, FALSE);
arglist += arg_size;
sp = STACK_ADD_BYTES (sp, sv_size);
}
}
/*
* These functions are the entry points into the interpreter from compiled code.
* They are called by the interp_in wrappers. They have the following signature:
* void (<optional this_arg>, <optional retval pointer>, <arg1>, ..., <argn>, <method ptr>)
* They pack up their arguments into an InterpEntryData structure and call interp_entry ().
* It would be possible for the wrappers to pack up the arguments etc, but that would make them bigger, and there are
* more wrappers then these functions.
* this/static * ret/void * 16 arguments -> 64 functions.
*/
#define INTERP_ENTRY_BASE(_method, _this_arg, _res) \
InterpEntryData data; \
(data).rmethod = (_method); \
(data).res = (_res); \
(data).this_arg = (_this_arg); \
(data).many_args = NULL;
#define INTERP_ENTRY0(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
interp_entry (&data); \
}
#define INTERP_ENTRY1(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
interp_entry (&data); \
}
#define INTERP_ENTRY2(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
interp_entry (&data); \
}
#define INTERP_ENTRY3(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
(data).args [2] = arg3; \
interp_entry (&data); \
}
#define INTERP_ENTRY4(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
(data).args [2] = arg3; \
(data).args [3] = arg4; \
interp_entry (&data); \
}
#define INTERP_ENTRY5(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
(data).args [2] = arg3; \
(data).args [3] = arg4; \
(data).args [4] = arg5; \
interp_entry (&data); \
}
#define INTERP_ENTRY6(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
(data).args [2] = arg3; \
(data).args [3] = arg4; \
(data).args [4] = arg5; \
(data).args [5] = arg6; \
interp_entry (&data); \
}
#define INTERP_ENTRY7(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
(data).args [2] = arg3; \
(data).args [3] = arg4; \
(data).args [4] = arg5; \
(data).args [5] = arg6; \
(data).args [6] = arg7; \
interp_entry (&data); \
}
#define INTERP_ENTRY8(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
(data).args [2] = arg3; \
(data).args [3] = arg4; \
(data).args [4] = arg5; \
(data).args [5] = arg6; \
(data).args [6] = arg7; \
(data).args [7] = arg8; \
interp_entry (&data); \
}
#define ARGLIST0 InterpMethod *rmethod
#define ARGLIST1 gpointer arg1, InterpMethod *rmethod
#define ARGLIST2 gpointer arg1, gpointer arg2, InterpMethod *rmethod
#define ARGLIST3 gpointer arg1, gpointer arg2, gpointer arg3, InterpMethod *rmethod
#define ARGLIST4 gpointer arg1, gpointer arg2, gpointer arg3, gpointer arg4, InterpMethod *rmethod
#define ARGLIST5 gpointer arg1, gpointer arg2, gpointer arg3, gpointer arg4, gpointer arg5, InterpMethod *rmethod
#define ARGLIST6 gpointer arg1, gpointer arg2, gpointer arg3, gpointer arg4, gpointer arg5, gpointer arg6, InterpMethod *rmethod
#define ARGLIST7 gpointer arg1, gpointer arg2, gpointer arg3, gpointer arg4, gpointer arg5, gpointer arg6, gpointer arg7, InterpMethod *rmethod
#define ARGLIST8 gpointer arg1, gpointer arg2, gpointer arg3, gpointer arg4, gpointer arg5, gpointer arg6, gpointer arg7, gpointer arg8, InterpMethod *rmethod
static void interp_entry_static_0 (ARGLIST0) INTERP_ENTRY0 (NULL, NULL, rmethod)
static void interp_entry_static_1 (ARGLIST1) INTERP_ENTRY1 (NULL, NULL, rmethod)
static void interp_entry_static_2 (ARGLIST2) INTERP_ENTRY2 (NULL, NULL, rmethod)
static void interp_entry_static_3 (ARGLIST3) INTERP_ENTRY3 (NULL, NULL, rmethod)
static void interp_entry_static_4 (ARGLIST4) INTERP_ENTRY4 (NULL, NULL, rmethod)
static void interp_entry_static_5 (ARGLIST5) INTERP_ENTRY5 (NULL, NULL, rmethod)
static void interp_entry_static_6 (ARGLIST6) INTERP_ENTRY6 (NULL, NULL, rmethod)
static void interp_entry_static_7 (ARGLIST7) INTERP_ENTRY7 (NULL, NULL, rmethod)
static void interp_entry_static_8 (ARGLIST8) INTERP_ENTRY8 (NULL, NULL, rmethod)
static void interp_entry_static_ret_0 (gpointer res, ARGLIST0) INTERP_ENTRY0 (NULL, res, rmethod)
static void interp_entry_static_ret_1 (gpointer res, ARGLIST1) INTERP_ENTRY1 (NULL, res, rmethod)
static void interp_entry_static_ret_2 (gpointer res, ARGLIST2) INTERP_ENTRY2 (NULL, res, rmethod)
static void interp_entry_static_ret_3 (gpointer res, ARGLIST3) INTERP_ENTRY3 (NULL, res, rmethod)
static void interp_entry_static_ret_4 (gpointer res, ARGLIST4) INTERP_ENTRY4 (NULL, res, rmethod)
static void interp_entry_static_ret_5 (gpointer res, ARGLIST5) INTERP_ENTRY5 (NULL, res, rmethod)
static void interp_entry_static_ret_6 (gpointer res, ARGLIST6) INTERP_ENTRY6 (NULL, res, rmethod)
static void interp_entry_static_ret_7 (gpointer res, ARGLIST7) INTERP_ENTRY7 (NULL, res, rmethod)
static void interp_entry_static_ret_8 (gpointer res, ARGLIST8) INTERP_ENTRY8 (NULL, res, rmethod)
static void interp_entry_instance_0 (gpointer this_arg, ARGLIST0) INTERP_ENTRY0 (this_arg, NULL, rmethod)
static void interp_entry_instance_1 (gpointer this_arg, ARGLIST1) INTERP_ENTRY1 (this_arg, NULL, rmethod)
static void interp_entry_instance_2 (gpointer this_arg, ARGLIST2) INTERP_ENTRY2 (this_arg, NULL, rmethod)
static void interp_entry_instance_3 (gpointer this_arg, ARGLIST3) INTERP_ENTRY3 (this_arg, NULL, rmethod)
static void interp_entry_instance_4 (gpointer this_arg, ARGLIST4) INTERP_ENTRY4 (this_arg, NULL, rmethod)
static void interp_entry_instance_5 (gpointer this_arg, ARGLIST5) INTERP_ENTRY5 (this_arg, NULL, rmethod)
static void interp_entry_instance_6 (gpointer this_arg, ARGLIST6) INTERP_ENTRY6 (this_arg, NULL, rmethod)
static void interp_entry_instance_7 (gpointer this_arg, ARGLIST7) INTERP_ENTRY7 (this_arg, NULL, rmethod)
static void interp_entry_instance_8 (gpointer this_arg, ARGLIST8) INTERP_ENTRY8 (this_arg, NULL, rmethod)
static void interp_entry_instance_ret_0 (gpointer this_arg, gpointer res, ARGLIST0) INTERP_ENTRY0 (this_arg, res, rmethod)
static void interp_entry_instance_ret_1 (gpointer this_arg, gpointer res, ARGLIST1) INTERP_ENTRY1 (this_arg, res, rmethod)
static void interp_entry_instance_ret_2 (gpointer this_arg, gpointer res, ARGLIST2) INTERP_ENTRY2 (this_arg, res, rmethod)
static void interp_entry_instance_ret_3 (gpointer this_arg, gpointer res, ARGLIST3) INTERP_ENTRY3 (this_arg, res, rmethod)
static void interp_entry_instance_ret_4 (gpointer this_arg, gpointer res, ARGLIST4) INTERP_ENTRY4 (this_arg, res, rmethod)
static void interp_entry_instance_ret_5 (gpointer this_arg, gpointer res, ARGLIST5) INTERP_ENTRY5 (this_arg, res, rmethod)
static void interp_entry_instance_ret_6 (gpointer this_arg, gpointer res, ARGLIST6) INTERP_ENTRY6 (this_arg, res, rmethod)
static void interp_entry_instance_ret_7 (gpointer this_arg, gpointer res, ARGLIST7) INTERP_ENTRY7 (this_arg, res, rmethod)
static void interp_entry_instance_ret_8 (gpointer this_arg, gpointer res, ARGLIST8) INTERP_ENTRY8 (this_arg, res, rmethod)
#define INTERP_ENTRY_FUNCLIST(type) (gpointer)interp_entry_ ## type ## _0, (gpointer)interp_entry_ ## type ## _1, (gpointer)interp_entry_ ## type ## _2, (gpointer)interp_entry_ ## type ## _3, (gpointer)interp_entry_ ## type ## _4, (gpointer)interp_entry_ ## type ## _5, (gpointer)interp_entry_ ## type ## _6, (gpointer)interp_entry_ ## type ## _7, (gpointer)interp_entry_ ## type ## _8
static gpointer entry_funcs_static [MAX_INTERP_ENTRY_ARGS + 1] = { INTERP_ENTRY_FUNCLIST (static) };
static gpointer entry_funcs_static_ret [MAX_INTERP_ENTRY_ARGS + 1] = { INTERP_ENTRY_FUNCLIST (static_ret) };
static gpointer entry_funcs_instance [MAX_INTERP_ENTRY_ARGS + 1] = { INTERP_ENTRY_FUNCLIST (instance) };
static gpointer entry_funcs_instance_ret [MAX_INTERP_ENTRY_ARGS + 1] = { INTERP_ENTRY_FUNCLIST (instance_ret) };
/* General version for methods with more than MAX_INTERP_ENTRY_ARGS arguments */
static void
interp_entry_general (gpointer this_arg, gpointer res, gpointer *args, gpointer rmethod)
{
INTERP_ENTRY_BASE ((InterpMethod*)rmethod, this_arg, res);
data.many_args = args;
interp_entry (&data);
}
#ifdef MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE
// Do not inline in case order of frame addresses matters.
static MONO_NEVER_INLINE void
interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untyped)
{
ThreadContext *context;
stackval *sp;
MonoMethod *method;
MonoMethodSignature *sig;
CallContext *ccontext = (CallContext*) ccontext_untyped;
InterpMethod *rmethod = (InterpMethod*) rmethod_untyped;
gpointer orig_domain = NULL, attach_cookie;
int i;
if (rmethod->needs_thread_attach)
orig_domain = mono_threads_attach_coop (mono_domain_get (), &attach_cookie);
context = get_context ();
sp = (stackval*)context->stack_pointer;
method = rmethod->method;
sig = mono_method_signature_internal (method);
if (method->string_ctor) {
MonoMethodSignature *newsig = (MonoMethodSignature*)g_alloca (MONO_SIZEOF_METHOD_SIGNATURE + ((sig->param_count + 2) * sizeof (MonoType*)));
memcpy (newsig, sig, mono_metadata_signature_size (sig));
newsig->ret = m_class_get_byval_arg (mono_defaults.string_class);
sig = newsig;
}
InterpFrame frame = {0};
frame.imethod = rmethod;
frame.stack = sp;
frame.retval = sp;
/* Copy the args saved in the trampoline to the frame stack */
gpointer retp = mono_arch_get_native_call_context_args (ccontext, &frame, sig);
/* Allocate storage for value types */
stackval *newsp = sp;
/* FIXME we should reuse computation on imethod for this */
if (sig->hasthis)
newsp++;
for (i = 0; i < sig->param_count; i++) {
MonoType *type = sig->params [i];
int size;
if (type->type == MONO_TYPE_GENERICINST && !MONO_TYPE_IS_REFERENCE (type)) {
size = mono_class_value_size (mono_class_from_mono_type_internal (type), NULL);
} else if (type->type == MONO_TYPE_VALUETYPE) {
if (sig->pinvoke && !sig->marshalling_disabled)
size = mono_class_native_size (type->data.klass, NULL);
else
size = mono_class_value_size (type->data.klass, NULL);
} else {
size = MINT_STACK_SLOT_SIZE;
}
newsp = STACK_ADD_BYTES (newsp, size);
}
context->stack_pointer = (guchar*)newsp;
g_assert (context->stack_pointer < context->stack_end);
MONO_ENTER_GC_UNSAFE;
interp_exec_method (&frame, context, NULL);
MONO_EXIT_GC_UNSAFE;
context->stack_pointer = (guchar*)sp;
g_assert (!context->has_resume_state);
if (rmethod->needs_thread_attach)
mono_threads_detach_coop (orig_domain, &attach_cookie);
check_pending_unwind (context);
/* Write back the return value */
/* 'frame' is still valid */
mono_arch_set_native_call_context_ret (ccontext, &frame, sig, retp);
}
#else
static void
interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untyped)
{
g_assert_not_reached ();
}
#endif /* MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE */
static void
interp_entry_llvmonly (gpointer res, gpointer *args, gpointer imethod_untyped)
{
InterpMethod *imethod = (InterpMethod*)imethod_untyped;
if (imethod->hasthis)
interp_entry_general (*(gpointer*)(args [0]), res, args + 1, imethod);
else
interp_entry_general (NULL, res, args, imethod);
}
static gpointer
interp_get_interp_method (MonoMethod *method, MonoError *error)
{
return mono_interp_get_imethod (method, error);
}
static MonoJitInfo*
interp_compile_interp_method (MonoMethod *method, MonoError *error)
{
InterpMethod *imethod = mono_interp_get_imethod (method, error);
return_val_if_nok (error, NULL);
if (!imethod->transformed) {
mono_interp_transform_method (imethod, get_context (), error);
return_val_if_nok (error, NULL);
}
return imethod->jinfo;
}
static InterpMethod*
lookup_method_pointer (gpointer addr)
{
InterpMethod *res = NULL;
MonoJitMemoryManager *jit_mm = get_default_jit_mm ();
jit_mm_lock (jit_mm);
if (jit_mm->interp_method_pointer_hash)
res = (InterpMethod*)g_hash_table_lookup (jit_mm->interp_method_pointer_hash, addr);
jit_mm_unlock (jit_mm);
return res;
}
#ifndef MONO_ARCH_HAVE_INTERP_NATIVE_TO_MANAGED
static void
interp_no_native_to_managed (void)
{
g_error ("interpreter: native-to-managed transition not available on this platform");
}
#endif
static void
no_llvmonly_interp_method_pointer (void)
{
g_assert_not_reached ();
}
/*
* interp_create_method_pointer_llvmonly:
*
* Return an ftndesc for entering the interpreter and executing METHOD.
*/
static MonoFtnDesc*
interp_create_method_pointer_llvmonly (MonoMethod *method, gboolean unbox, MonoError *error)
{
gpointer addr, entry_func, entry_wrapper;
MonoMethodSignature *sig;
MonoMethod *wrapper;
InterpMethod *imethod;
imethod = mono_interp_get_imethod (method, error);
return_val_if_nok (error, NULL);
if (unbox) {
if (imethod->llvmonly_unbox_entry)
return (MonoFtnDesc*)imethod->llvmonly_unbox_entry;
} else {
if (imethod->jit_entry)
return (MonoFtnDesc*)imethod->jit_entry;
}
sig = mono_method_signature_internal (method);
/*
* The entry functions need access to the method to call, so we have
* to use a ftndesc. The caller uses a normal signature, while the
* entry functions use a gsharedvt_in signature, so wrap the entry function in
* a gsharedvt_in_sig wrapper.
* We use a gsharedvt_in_sig wrapper instead of an interp_in wrapper, because they
* are mostly the same, and they are already generated. The exception is the
* wrappers for methods with more than 8 arguments, those are different.
*/
if (sig->param_count > MAX_INTERP_ENTRY_ARGS)
wrapper = mini_get_interp_in_wrapper (sig);
else
wrapper = mini_get_gsharedvt_in_sig_wrapper (sig);
entry_wrapper = mono_jit_compile_method_jit_only (wrapper, error);
mono_error_assertf_ok (error, "couldn't compile wrapper \"%s\" for \"%s\"",
mono_method_get_name_full (wrapper, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL),
mono_method_get_name_full (method, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL));
if (sig->param_count > MAX_INTERP_ENTRY_ARGS) {
entry_func = (gpointer)interp_entry_general;
} else if (sig->hasthis) {
if (sig->ret->type == MONO_TYPE_VOID)
entry_func = entry_funcs_instance [sig->param_count];
else
entry_func = entry_funcs_instance_ret [sig->param_count];
} else {
if (sig->ret->type == MONO_TYPE_VOID)
entry_func = entry_funcs_static [sig->param_count];
else
entry_func = entry_funcs_static_ret [sig->param_count];
}
g_assert (entry_func);
/* Encode unbox in the lower bit of imethod */
gpointer entry_arg = imethod;
if (unbox)
entry_arg = (gpointer)(((gsize)entry_arg) | 1);
MonoFtnDesc *entry_ftndesc = mini_llvmonly_create_ftndesc (method, entry_func, entry_arg);
addr = mini_llvmonly_create_ftndesc (method, entry_wrapper, entry_ftndesc);
// FIXME:
MonoJitMemoryManager *jit_mm = get_default_jit_mm ();
jit_mm_lock (jit_mm);
if (!jit_mm->interp_method_pointer_hash)
jit_mm->interp_method_pointer_hash = g_hash_table_new (NULL, NULL);
g_hash_table_insert (jit_mm->interp_method_pointer_hash, addr, imethod);
jit_mm_unlock (jit_mm);
mono_memory_barrier ();
if (unbox)
imethod->llvmonly_unbox_entry = addr;
else
imethod->jit_entry = addr;
return (MonoFtnDesc*)addr;
}
/*
* interp_create_method_pointer:
*
* Return a function pointer which can be used to call METHOD using the
* interpreter. Return NULL for methods which are not supported.
*/
static gpointer
interp_create_method_pointer (MonoMethod *method, gboolean compile, MonoError *error)
{
gpointer addr, entry_func, entry_wrapper = NULL;
InterpMethod *imethod = mono_interp_get_imethod (method, error);
if (imethod->jit_entry)
return imethod->jit_entry;
if (compile && !imethod->transformed) {
/* Return any errors from method compilation */
mono_interp_transform_method (imethod, get_context (), error);
return_val_if_nok (error, NULL);
}
MonoMethodSignature *sig = mono_method_signature_internal (method);
if (method->string_ctor) {
MonoMethodSignature *newsig = (MonoMethodSignature*)g_alloca (MONO_SIZEOF_METHOD_SIGNATURE + ((sig->param_count + 2) * sizeof (MonoType*)));
memcpy (newsig, sig, mono_metadata_signature_size (sig));
newsig->ret = m_class_get_byval_arg (mono_defaults.string_class);
sig = newsig;
}
if (sig->param_count > MAX_INTERP_ENTRY_ARGS) {
entry_func = (gpointer)interp_entry_general;
} else if (sig->hasthis) {
if (sig->ret->type == MONO_TYPE_VOID)
entry_func = entry_funcs_instance [sig->param_count];
else
entry_func = entry_funcs_instance_ret [sig->param_count];
} else {
if (sig->ret->type == MONO_TYPE_VOID)
entry_func = entry_funcs_static [sig->param_count];
else
entry_func = entry_funcs_static_ret [sig->param_count];
}
#ifndef MONO_ARCH_HAVE_INTERP_NATIVE_TO_MANAGED
#ifdef HOST_WASM
if (method->wrapper_type == MONO_WRAPPER_NATIVE_TO_MANAGED) {
WrapperInfo *info = mono_marshal_get_wrapper_info (method);
MonoMethod *orig_method = info->d.native_to_managed.method;
/*
* These are called from native code. Ask the host app for a trampoline.
*/
MonoFtnDesc *ftndesc = g_new0 (MonoFtnDesc, 1);
ftndesc->addr = entry_func;
ftndesc->arg = imethod;
addr = mono_wasm_get_native_to_interp_trampoline (orig_method, ftndesc);
if (addr) {
mono_memory_barrier ();
imethod->jit_entry = addr;
return addr;
}
/*
* The runtime expects a function pointer unique to method and
* the native caller expects a function pointer with the
* right signature, so fail right away.
*/
char *s = mono_method_get_full_name (orig_method);
char *msg = g_strdup_printf ("No native to managed transition for method '%s', missing [UnmanagedCallersOnly] attribute.", s);
mono_error_set_platform_not_supported (error, msg);
g_free (s);
g_free (msg);
return NULL;
}
#endif
return (gpointer)interp_no_native_to_managed;
#endif
if (mono_llvm_only) {
/* The caller should call interp_create_method_pointer_llvmonly */
//g_assert_not_reached ();
return (gpointer)no_llvmonly_interp_method_pointer;
}
if (method->wrapper_type && method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE)
return imethod;
#ifndef MONO_ARCH_HAVE_FTNPTR_ARG_TRAMPOLINE
/*
* Interp in wrappers get the argument in the rgctx register. If
* MONO_ARCH_HAVE_FTNPTR_ARG_TRAMPOLINE is defined it means that
* on that arch the rgctx register is not scratch, so we use a
* separate temp register. We should update the wrappers for this
* if we really care about those architectures (arm).
*/
MonoMethod *wrapper = mini_get_interp_in_wrapper (sig);
entry_wrapper = mono_jit_compile_method_jit_only (wrapper, error);
#endif
if (!entry_wrapper) {
#ifndef MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE
g_assertion_message ("couldn't compile wrapper \"%s\" for \"%s\"",
mono_method_get_name_full (wrapper, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL),
mono_method_get_name_full (method, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL));
#else
mono_interp_error_cleanup (error);
if (!mono_native_to_interp_trampoline) {
if (mono_aot_only) {
mono_native_to_interp_trampoline = (MonoFuncV)mono_aot_get_trampoline ("native_to_interp_trampoline");
} else {
MonoTrampInfo *info;
mono_native_to_interp_trampoline = (MonoFuncV)mono_arch_get_native_to_interp_trampoline (&info);
mono_tramp_info_register (info, NULL);
}
}
entry_wrapper = (gpointer)mono_native_to_interp_trampoline;
/* We need the lmf wrapper only when being called from mixed mode */
if (sig->pinvoke)
entry_func = (gpointer)interp_entry_from_trampoline;
else {
static gpointer cached_func = NULL;
if (!cached_func) {
cached_func = mono_jit_compile_method_jit_only (mini_get_interp_lmf_wrapper ("mono_interp_entry_from_trampoline", (gpointer) mono_interp_entry_from_trampoline), error);
mono_memory_barrier ();
}
entry_func = cached_func;
}
#endif
}
g_assert (entry_func);
/* This is the argument passed to the interp_in wrapper by the static rgctx trampoline */
MonoFtnDesc *ftndesc = g_new0 (MonoFtnDesc, 1);
ftndesc->addr = entry_func;
ftndesc->arg = imethod;
mono_error_assert_ok (error);
/*
* The wrapper is called by compiled code, which doesn't pass the extra argument, so we pass it in the
* rgctx register using a trampoline.
*/
addr = mono_create_ftnptr_arg_trampoline (ftndesc, entry_wrapper);
MonoJitMemoryManager *jit_mm = get_default_jit_mm ();
jit_mm_lock (jit_mm);
if (!jit_mm->interp_method_pointer_hash)
jit_mm->interp_method_pointer_hash = g_hash_table_new (NULL, NULL);
g_hash_table_insert (jit_mm->interp_method_pointer_hash, addr, imethod);
jit_mm_unlock (jit_mm);
mono_memory_barrier ();
imethod->jit_entry = addr;
return addr;
}
static void
interp_free_method (MonoMethod *method)
{
MonoJitMemoryManager *jit_mm = jit_mm_for_method (method);
jit_mm_lock (jit_mm);
/* InterpMethod is allocated in the domain mempool. We might haven't
* allocated an InterpMethod for this instance yet */
mono_internal_hash_table_remove (&jit_mm->interp_code_hash, method);
jit_mm_unlock (jit_mm);
}
#if COUNT_OPS
static long opcode_counts[MINT_LASTOP];
#define COUNT_OP(op) opcode_counts[op]++
#else
#define COUNT_OP(op)
#endif
#if DEBUG_INTERP
#define DUMP_INSTR() \
if (tracing > 1) { \
output_indent (); \
char *mn = mono_method_full_name (frame->imethod->method, FALSE); \
char *disasm = mono_interp_dis_mintop ((gint32)(ip - frame->imethod->code), TRUE, ip + 1, *ip); \
g_print ("(%p) %s -> %s\n", mono_thread_internal_current (), mn, disasm); \
g_free (mn); \
g_free (disasm); \
}
#else
#define DUMP_INSTR()
#endif
static MONO_NEVER_INLINE MonoException*
do_init_vtable (MonoVTable *vtable, MonoError *error, InterpFrame *frame, const guint16 *ip)
{
MonoLMFExt ext;
MonoException *ex = NULL;
/*
* When calling runtime functions we pass the ip of the instruction triggering the runtime call.
* Offset the subtraction from interp_frame_get_ip, so we don't end up in prev instruction.
*/
frame->state.ip = ip + 1;
interp_push_lmf (&ext, frame);
mono_runtime_class_init_full (vtable, error);
if (!is_ok (error))
ex = mono_error_convert_to_exception (error);
interp_pop_lmf (&ext);
return ex;
}
#define INIT_VTABLE(vtable) do { \
if (G_UNLIKELY (!(vtable)->initialized)) { \
MonoException *__init_vtable_ex = do_init_vtable ((vtable), error, frame, ip); \
if (G_UNLIKELY (__init_vtable_ex)) \
THROW_EX (__init_vtable_ex, ip); \
} \
} while (0);
static MonoObject*
mono_interp_new (MonoClass* klass)
{
ERROR_DECL (error);
MonoObject* const object = mono_object_new_checked (klass, error);
mono_error_cleanup (error); // FIXME: do not swallow the error
return object;
}
static gboolean
mono_interp_isinst (MonoObject* object, MonoClass* klass)
{
ERROR_DECL (error);
gboolean isinst;
MonoClass *obj_class = mono_object_class (object);
mono_class_is_assignable_from_checked (klass, obj_class, &isinst, error);
mono_error_cleanup (error); // FIXME: do not swallow the error
return isinst;
}
static MONO_NEVER_INLINE InterpMethod*
mono_interp_get_native_func_wrapper (InterpMethod* imethod, MonoMethodSignature* csignature, guchar* code)
{
ERROR_DECL(error);
/* Pinvoke call is missing the wrapper. See mono_get_native_calli_wrapper */
MonoMarshalSpec** mspecs = g_newa0 (MonoMarshalSpec*, csignature->param_count + 1);
MonoMethodPInvoke iinfo;
memset (&iinfo, 0, sizeof (iinfo));
MonoMethod *method = imethod->method;
MonoImage *image = NULL;
if (imethod->method->dynamic)
image = ((MonoDynamicMethod*)method)->assembly->image;
else
image = m_class_get_image (method->klass);
MonoMethod* m = mono_marshal_get_native_func_wrapper (image, csignature, &iinfo, mspecs, code);
for (int i = csignature->param_count; i >= 0; i--)
if (mspecs [i])
mono_metadata_free_marshal_spec (mspecs [i]);
InterpMethod *cmethod = mono_interp_get_imethod (m, error);
mono_error_cleanup (error); /* FIXME: don't swallow the error */
return cmethod;
}
// Do not inline in case order of frame addresses matters.
static MONO_NEVER_INLINE MonoException*
mono_interp_leave (InterpFrame* parent_frame)
{
InterpFrame frame = {parent_frame};
gboolean gc_transitions = FALSE;
stackval tmp_sp;
/*
* We need for mono_thread_get_undeniable_exception to be able to unwind
* to check the abort threshold. For this to work we use frame as a
* dummy frame that is stored in the lmf and serves as the transition frame
*/
do_icall_wrapper (&frame, NULL, MINT_ICALL_V_P, &tmp_sp, &tmp_sp, (gpointer)mono_thread_get_undeniable_exception, FALSE, &gc_transitions);
return (MonoException*)tmp_sp.data.p;
}
static gint32
mono_interp_enum_hasflag (stackval *sp1, stackval *sp2, MonoClass* klass)
{
guint64 a_val = 0, b_val = 0;
stackval_to_data (m_class_get_byval_arg (klass), sp1, &a_val, FALSE);
stackval_to_data (m_class_get_byval_arg (klass), sp2, &b_val, FALSE);
return (a_val & b_val) == b_val;
}
// varargs in wasm consumes extra linear stack per call-site.
// These g_warning/g_error wrappers fix that. It is not the
// small wasm stack, but conserving it is still desirable.
static void
g_warning_d (const char *format, int d)
{
g_warning (format, d);
}
#if !USE_COMPUTED_GOTO
static void
interp_error_xsx (const char *format, int x1, const char *s, int x2)
{
g_error (format, x1, s, x2);
}
#endif
static MONO_ALWAYS_INLINE gboolean
method_entry (ThreadContext *context, InterpFrame *frame,
#if DEBUG_INTERP
int *out_tracing,
#endif
MonoException **out_ex)
{
gboolean slow = FALSE;
#if DEBUG_INTERP
debug_enter (frame, out_tracing);
#endif
#if PROFILE_INTERP
frame->imethod->calls++;
#endif
*out_ex = NULL;
if (!G_UNLIKELY (frame->imethod->transformed)) {
slow = TRUE;
MonoException *ex = do_transform_method (frame->imethod, frame, context);
if (ex) {
*out_ex = ex;
/*
* Initialize the stack base pointer here, in the uncommon branch, so we don't
* need to check for it everytime when exitting a frame.
*/
frame->stack = (stackval*)context->stack_pointer;
return slow;
}
}
return slow;
}
/* Save the state of the interpeter main loop into FRAME */
#define SAVE_INTERP_STATE(frame) do { \
frame->state.ip = ip; \
} while (0)
/* Load and clear state from FRAME */
#define LOAD_INTERP_STATE(frame) do { \
ip = frame->state.ip; \
locals = (unsigned char *)frame->stack; \
frame->state.ip = NULL; \
} while (0)
/* Initialize interpreter state for executing FRAME */
#define INIT_INTERP_STATE(frame, _clause_args) do { \
ip = _clause_args ? ((FrameClauseArgs *)_clause_args)->start_with_ip : (frame)->imethod->code; \
locals = (unsigned char *)(frame)->stack; \
} while (0)
#if PROFILE_INTERP
static long total_executed_opcodes;
#endif
#define LOCAL_VAR(offset,type) (*(type*)(locals + (offset)))
/*
* If CLAUSE_ARGS is non-null, start executing from it.
* The ERROR argument is used to avoid declaring an error object for every interp frame, its not used
* to return error information.
* FRAME is only valid until the next call to alloc_frame ().
*/
static MONO_NEVER_INLINE void
interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs *clause_args)
{
InterpMethod *cmethod;
MonoException *ex;
ERROR_DECL(error);
/* Interpreter main loop state (InterpState) */
const guint16 *ip = NULL;
unsigned char *locals = NULL;
int call_args_offset;
int return_offset;
gboolean gc_transitions = FALSE;
#if DEBUG_INTERP
int tracing = global_tracing;
#endif
#if USE_COMPUTED_GOTO
static void * const in_labels[] = {
#define OPDEF(a,b,c,d,e,f) &&LAB_ ## a,
#include "mintops.def"
};
#endif
HANDLE_FUNCTION_ENTER ();
/*
* GC SAFETY:
*
* The interpreter executes in gc unsafe (non-preempt) mode. On wasm, we cannot rely on
* scanning the stack or any registers. In order to make the code GC safe, every objref
* handled by the code needs to be kept alive and pinned in any of the following ways:
* - the object needs to be stored on the interpreter stack. In order to make sure the
* object actually gets stored on the interp stack and the store is not optimized out,
* the store/variable should be volatile.
* - if the execution of an opcode requires an object not coming from interp stack to be
* kept alive, the tmp_handle below can be used. This handle will keep only one object
* pinned by the GC. Ideally, once this object is no longer needed, the handle should be
* cleared. If we will need to have more objects pinned simultaneously, additional handles
* can be reserved here.
*/
MonoObjectHandle tmp_handle = MONO_HANDLE_NEW (MonoObject, NULL);
if (method_entry (context, frame,
#if DEBUG_INTERP
&tracing,
#endif
&ex)) {
if (ex)
THROW_EX (ex, NULL);
EXCEPTION_CHECKPOINT;
}
if (!clause_args) {
context->stack_pointer = (guchar*)frame->stack + frame->imethod->alloca_size;
g_assert (context->stack_pointer < context->stack_end);
/* Make sure the stack pointer is bumped before we store any references on the stack */
mono_compiler_barrier ();
}
INIT_INTERP_STATE (frame, clause_args);
#ifdef ENABLE_EXPERIMENT_TIERED
mini_tiered_inc (frame->imethod->method, &frame->imethod->tiered_counter, 0);
#endif
//g_print ("(%p) Call %s\n", mono_thread_internal_current (), mono_method_get_full_name (frame->imethod->method));
#if defined(ENABLE_HYBRID_SUSPEND) || defined(ENABLE_COOP_SUSPEND)
mono_threads_safepoint ();
#endif
main_loop:
/*
* using while (ip < end) may result in a 15% performance drop,
* but it may be useful for debug
*/
while (1) {
#if PROFILE_INTERP
frame->imethod->opcounts++;
total_executed_opcodes++;
#endif
MintOpcode opcode;
DUMP_INSTR();
MINT_IN_SWITCH (*ip) {
MINT_IN_CASE(MINT_INITLOCAL)
MINT_IN_CASE(MINT_INITLOCALS)
memset (locals + ip [1], 0, ip [2]);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NOP)
MINT_IN_CASE(MINT_IL_SEQ_POINT)
MINT_IN_CASE(MINT_NIY)
MINT_IN_CASE(MINT_DEF)
MINT_IN_CASE(MINT_DUMMY_USE)
g_assert_not_reached ();
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BREAK)
++ip;
SAVE_INTERP_STATE (frame);
do_debugger_tramp (mono_component_debugger ()->user_break, frame);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BREAKPOINT)
++ip;
mono_break ();
MINT_IN_BREAK;
MINT_IN_CASE(MINT_INIT_ARGLIST) {
const guint16 *call_ip = frame->parent->state.ip - 6;
g_assert_checked (*call_ip == MINT_CALL_VARARG);
int params_stack_size = call_ip [5];
MonoMethodSignature *sig = (MonoMethodSignature*)frame->parent->imethod->data_items [call_ip [4]];
// we are being overly conservative with the size here, for simplicity
gpointer arglist = frame_data_allocator_alloc (&context->data_stack, frame, params_stack_size + MINT_STACK_SLOT_SIZE);
init_arglist (frame, sig, STACK_ADD_BYTES (frame->stack, ip [2]), (char*)arglist);
// save the arglist for future access with MINT_ARGLIST
LOCAL_VAR (ip [1], gpointer) = arglist;
ip += 3;
MINT_IN_BREAK;
}
#define LDC(n) do { LOCAL_VAR (ip [1], gint32) = (n); ip += 2; } while (0)
MINT_IN_CASE(MINT_LDC_I4_M1)
LDC(-1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_0)
LDC(0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_1)
LDC(1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_2)
LDC(2);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_3)
LDC(3);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_4)
LDC(4);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_5)
LDC(5);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_6)
LDC(6);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_7)
LDC(7);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_8)
LDC(8);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_S)
LOCAL_VAR (ip [1], gint32) = (short)ip [2];
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4)
LOCAL_VAR (ip [1], gint32) = READ32 (ip + 2);
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I8_0)
LOCAL_VAR (ip [1], gint64) = 0;
ip += 2;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I8)
LOCAL_VAR (ip [1], gint64) = READ64 (ip + 2);
ip += 6;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I8_S)
LOCAL_VAR (ip [1], gint64) = (short)ip [2];
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_R4) {
LOCAL_VAR (ip [1], gint32) = READ32(ip + 2); /* not union usage */
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDC_R8)
LOCAL_VAR (ip [1], gint64) = READ64 (ip + 2); /* note union usage */
ip += 6;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_TAILCALL)
MINT_IN_CASE(MINT_TAILCALL_VIRT)
MINT_IN_CASE(MINT_JMP) {
gboolean is_tailcall = *ip != MINT_JMP;
InterpMethod *new_method;
if (is_tailcall) {
guint16 params_offset = ip [1];
guint16 params_size = ip [3];
// Copy the params to their location at the start of the frame
memmove (frame->stack, (guchar*)frame->stack + params_offset, params_size);
new_method = (InterpMethod*)frame->imethod->data_items [ip [2]];
if (*ip == MINT_TAILCALL_VIRT) {
gint16 slot = (gint16)ip [4];
MonoObject *this_arg = LOCAL_VAR (0, MonoObject*);
new_method = get_virtual_method_fast (new_method, this_arg->vtable, slot);
if (m_class_is_valuetype (this_arg->vtable->klass) && m_class_is_valuetype (new_method->method->klass)) {
/* unbox */
gpointer unboxed = mono_object_unbox_internal (this_arg);
LOCAL_VAR (0, gpointer) = unboxed;
}
}
} else {
new_method = (InterpMethod*)frame->imethod->data_items [ip [1]];
}
if (frame->imethod->prof_flags & MONO_PROFILER_CALL_INSTRUMENTATION_TAIL_CALL)
MONO_PROFILER_RAISE (method_tail_call, (frame->imethod->method, new_method->method));
if (!new_method->transformed) {
MonoException *ex = do_transform_method (new_method, frame, context);
if (ex)
THROW_EX (ex, ip);
EXCEPTION_CHECKPOINT;
}
/*
* It's possible for the caller stack frame to be smaller
* than the callee stack frame (at the interp level)
*/
context->stack_pointer = (guchar*)frame->stack + new_method->alloca_size;
if (G_UNLIKELY (context->stack_pointer >= context->stack_end)) {
context->stack_end = context->stack_real_end;
THROW_EX (mono_domain_get ()->stack_overflow_ex, ip);
}
frame->imethod = new_method;
ip = frame->imethod->code;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CALL_DELEGATE) {
// FIXME We don't need to encode the whole signature, just param_count
MonoMethodSignature *csignature = (MonoMethodSignature*)frame->imethod->data_items [ip [4]];
int param_count = csignature->param_count;
return_offset = ip [1];
call_args_offset = ip [2];
MonoDelegate *del = LOCAL_VAR (call_args_offset, MonoDelegate*);
gboolean is_multicast = del->method == NULL;
InterpMethod *del_imethod = (InterpMethod*)del->interp_invoke_impl;
if (!del_imethod) {
// FIXME push/pop LMF
if (is_multicast) {
error_init_reuse (error);
MonoMethod *invoke = mono_get_delegate_invoke_internal (del->object.vtable->klass);
del_imethod = mono_interp_get_imethod (mono_marshal_get_delegate_invoke (invoke, del), error);
del->interp_invoke_impl = del_imethod;
mono_error_assert_ok (error);
} else if (!del->interp_method) {
// Not created from interpreted code
error_init_reuse (error);
g_assert (del->method);
del_imethod = mono_interp_get_imethod (del->method, error);
del->interp_method = del_imethod;
del->interp_invoke_impl = del_imethod;
mono_error_assert_ok (error);
} else {
del_imethod = (InterpMethod*)del->interp_method;
if (del_imethod->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
error_init_reuse (error);
del_imethod = mono_interp_get_imethod (mono_marshal_get_native_wrapper (del_imethod->method, FALSE, FALSE), error);
mono_error_assert_ok (error);
del->interp_invoke_impl = del_imethod;
} else if (del_imethod->method->flags & METHOD_ATTRIBUTE_VIRTUAL && !del->target && !m_class_is_valuetype (del_imethod->method->klass)) {
// 'this' is passed dynamically, we need to recompute the target method
// with each call
del_imethod = get_virtual_method (del_imethod, LOCAL_VAR (call_args_offset + MINT_STACK_SLOT_SIZE, MonoObject*)->vtable);
} else {
del->interp_invoke_impl = del_imethod;
}
}
}
cmethod = del_imethod;
if (!is_multicast) {
if (cmethod->param_count == param_count + 1) {
// Target method is static but the delegate has a target object. We handle
// this separately from the case below, because, for these calls, the instance
// is allowed to be null.
LOCAL_VAR (call_args_offset, MonoObject*) = del->target;
} else if (del->target) {
MonoObject *this_arg = del->target;
// replace the MonoDelegate* on the stack with 'this' pointer
if (m_class_is_valuetype (this_arg->vtable->klass) && m_class_is_valuetype (cmethod->method->klass)) {
gpointer unboxed = mono_object_unbox_internal (this_arg);
LOCAL_VAR (call_args_offset, gpointer) = unboxed;
} else {
LOCAL_VAR (call_args_offset, MonoObject*) = this_arg;
}
} else {
// skip the delegate pointer for static calls
// FIXME we could avoid memmove
memmove (locals + call_args_offset, locals + call_args_offset + MINT_STACK_SLOT_SIZE, ip [3]);
}
}
ip += 5;
goto call;
}
MINT_IN_CASE(MINT_CALLI) {
gboolean need_unbox;
/* In mixed mode, stay in the interpreter for simplicity even if there is an AOT version of the callee */
cmethod = ftnptr_to_imethod (LOCAL_VAR (ip [2], gpointer), &need_unbox);
if (cmethod->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
// FIXME push/pop LMF
cmethod = mono_interp_get_imethod (mono_marshal_get_native_wrapper (cmethod->method, FALSE, FALSE), error);
mono_interp_error_cleanup (error); /* FIXME: don't swallow the error */
}
return_offset = ip [1];
call_args_offset = ip [3];
if (need_unbox) {
MonoObject *this_arg = LOCAL_VAR (call_args_offset, MonoObject*);
LOCAL_VAR (call_args_offset, gpointer) = mono_object_unbox_internal (this_arg);
}
ip += 4;
goto call;
}
MINT_IN_CASE(MINT_CALLI_NAT_FAST) {
MonoMethodSignature *csignature = (MonoMethodSignature*)frame->imethod->data_items [ip [4]];
int opcode = ip [5];
gboolean save_last_error = ip [6];
stackval *ret = (stackval*)(locals + ip [1]);
gpointer target_ip = LOCAL_VAR (ip [2], gpointer);
stackval *args = (stackval*)(locals + ip [3]);
/* for calls, have ip pointing at the start of next instruction */
frame->state.ip = ip + 7;
do_icall_wrapper (frame, csignature, opcode, ret, args, target_ip, save_last_error, &gc_transitions);
EXCEPTION_CHECKPOINT;
CHECK_RESUME_STATE (context);
ip += 7;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CALLI_NAT_DYNAMIC) {
MonoMethodSignature* csignature = (MonoMethodSignature*)frame->imethod->data_items [ip [4]];
return_offset = ip [1];
guchar* code = LOCAL_VAR (ip [2], guchar*);
call_args_offset = ip [3];
// FIXME push/pop LMF
cmethod = mono_interp_get_native_func_wrapper (frame->imethod, csignature, code);
ip += 5;
goto call;
}
MINT_IN_CASE(MINT_CALLI_NAT) {
MonoMethodSignature *csignature = (MonoMethodSignature*)frame->imethod->data_items [ip [4]];
InterpMethod *imethod = (InterpMethod*)frame->imethod->data_items [ip [5]];
guchar *code = LOCAL_VAR (ip [2], guchar*);
gboolean save_last_error = ip [6];
gpointer *cache = (gpointer*)&frame->imethod->data_items [ip [7]];
/* for calls, have ip pointing at the start of next instruction */
frame->state.ip = ip + 8;
ves_pinvoke_method (imethod, csignature, (MonoFuncV)code, context, frame, (stackval*)(locals + ip [1]), (stackval*)(locals + ip [3]), save_last_error, cache, &gc_transitions);
EXCEPTION_CHECKPOINT;
CHECK_RESUME_STATE (context);
ip += 8;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CALLVIRT_FAST) {
MonoObject *this_arg;
int slot;
cmethod = (InterpMethod*)frame->imethod->data_items [ip [3]];
return_offset = ip [1];
call_args_offset = ip [2];
this_arg = LOCAL_VAR (call_args_offset, MonoObject*);
slot = (gint16)ip [4];
ip += 5;
// FIXME push/pop LMF
cmethod = get_virtual_method_fast (cmethod, this_arg->vtable, slot);
if (m_class_is_valuetype (this_arg->vtable->klass) && m_class_is_valuetype (cmethod->method->klass)) {
/* unbox */
gpointer unboxed = mono_object_unbox_internal (this_arg);
LOCAL_VAR (call_args_offset, gpointer) = unboxed;
}
InterpMethodCodeType code_type = cmethod->code_type;
g_assert (code_type == IMETHOD_CODE_UNKNOWN ||
code_type == IMETHOD_CODE_INTERP ||
code_type == IMETHOD_CODE_COMPILED);
if (G_UNLIKELY (code_type == IMETHOD_CODE_UNKNOWN)) {
// FIXME push/pop LMF
MonoMethodSignature *sig = mono_method_signature_internal (cmethod->method);
if (mono_interp_jit_call_supported (cmethod->method, sig))
code_type = IMETHOD_CODE_COMPILED;
else
code_type = IMETHOD_CODE_INTERP;
cmethod->code_type = code_type;
}
if (code_type == IMETHOD_CODE_INTERP) {
goto call;
} else if (code_type == IMETHOD_CODE_COMPILED) {
frame->state.ip = ip;
error_init_reuse (error);
do_jit_call (context, (stackval*)(locals + return_offset), (stackval*)(locals + call_args_offset), frame, cmethod, error);
if (!is_ok (error)) {
MonoException *ex = interp_error_convert_to_exception (frame, error, ip);
THROW_EX (ex, ip);
}
CHECK_RESUME_STATE (context);
}
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CALL_VARARG) {
// Same as MINT_CALL, except at ip [4] we have the index for the csignature,
// which is required by the called method to set up the arglist.
cmethod = (InterpMethod*)frame->imethod->data_items [ip [3]];
return_offset = ip [1];
call_args_offset = ip [2];
ip += 6;
goto call;
}
MINT_IN_CASE(MINT_CALLVIRT) {
// FIXME CALLVIRT opcodes are not used on netcore. We should kill them.
cmethod = (InterpMethod*)frame->imethod->data_items [ip [3]];
return_offset = ip [1];
call_args_offset = ip [2];
MonoObject *this_arg = LOCAL_VAR (call_args_offset, MonoObject*);
// FIXME push/pop LMF
cmethod = get_virtual_method (cmethod, this_arg->vtable);
if (m_class_is_valuetype (this_arg->vtable->klass) && m_class_is_valuetype (cmethod->method->klass)) {
/* unbox */
gpointer unboxed = mono_object_unbox_internal (this_arg);
LOCAL_VAR (call_args_offset, gpointer) = unboxed;
}
#ifdef ENABLE_EXPERIMENT_TIERED
ip += 5;
#else
ip += 4;
#endif
goto call;
}
MINT_IN_CASE(MINT_CALL) {
cmethod = (InterpMethod*)frame->imethod->data_items [ip [3]];
return_offset = ip [1];
call_args_offset = ip [2];
#ifdef ENABLE_EXPERIMENT_TIERED
ip += 5;
#else
ip += 4;
#endif
call:
/*
* Make a non-recursive call by loading the new interpreter state based on child frame,
* and going back to the main loop.
*/
SAVE_INTERP_STATE (frame);
// Allocate child frame.
// FIXME: Add stack overflow checks
{
InterpFrame *child_frame = frame->next_free;
if (!child_frame) {
child_frame = g_newa0 (InterpFrame, 1);
// Not free currently, but will be when allocation attempted.
frame->next_free = child_frame;
}
reinit_frame (child_frame, frame, cmethod, locals + return_offset, locals + call_args_offset);
frame = child_frame;
}
if (method_entry (context, frame,
#if DEBUG_INTERP
&tracing,
#endif
&ex)) {
if (ex)
THROW_EX (ex, NULL);
EXCEPTION_CHECKPOINT;
}
context->stack_pointer = (guchar*)frame->stack + cmethod->alloca_size;
if (G_UNLIKELY (context->stack_pointer >= context->stack_end)) {
context->stack_end = context->stack_real_end;
THROW_EX (mono_domain_get ()->stack_overflow_ex, ip);
}
/* Make sure the stack pointer is bumped before we store any references on the stack */
mono_compiler_barrier ();
INIT_INTERP_STATE (frame, NULL);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_JIT_CALL) {
InterpMethod *rmethod = (InterpMethod*)frame->imethod->data_items [ip [3]];
error_init_reuse (error);
/* for calls, have ip pointing at the start of next instruction */
frame->state.ip = ip + 4;
do_jit_call (context, (stackval*)(locals + ip [1]), (stackval*)(locals + ip [2]), frame, rmethod, error);
if (!is_ok (error)) {
MonoException *ex = interp_error_convert_to_exception (frame, error, ip);
THROW_EX (ex, ip);
}
CHECK_RESUME_STATE (context);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_JIT_CALL2) {
#ifdef ENABLE_EXPERIMENT_TIERED
InterpMethod *rmethod = (InterpMethod *) READ64 (ip + 2);
error_init_reuse (error);
frame->state.ip = ip + 6;
do_jit_call (context, (stackval*)(locals + ip [1]), frame, rmethod, error);
if (!is_ok (error)) {
MonoException *ex = interp_error_convert_to_exception (frame, error);
THROW_EX (ex, ip);
}
CHECK_RESUME_STATE (context);
ip += 6;
#else
g_error ("MINT_JIT_ICALL2 shouldn't be used");
#endif
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CALLRUN) {
g_assert_not_reached ();
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_RET)
frame->retval [0] = LOCAL_VAR (ip [1], stackval);
goto exit_frame;
MINT_IN_CASE(MINT_RET_I4_IMM)
frame->retval [0].data.i = (gint16)ip [1];
goto exit_frame;
MINT_IN_CASE(MINT_RET_I8_IMM)
frame->retval [0].data.l = (gint16)ip [1];
goto exit_frame;
MINT_IN_CASE(MINT_RET_VOID)
goto exit_frame;
MINT_IN_CASE(MINT_RET_VT) {
memmove (frame->retval, locals + ip [1], ip [2]);
goto exit_frame;
}
MINT_IN_CASE(MINT_RET_LOCALLOC)
frame->retval [0] = LOCAL_VAR (ip [1], stackval);
frame_data_allocator_pop (&context->data_stack, frame);
goto exit_frame;
MINT_IN_CASE(MINT_RET_VOID_LOCALLOC)
frame_data_allocator_pop (&context->data_stack, frame);
goto exit_frame;
MINT_IN_CASE(MINT_RET_VT_LOCALLOC) {
memmove (frame->retval, locals + ip [1], ip [2]);
frame_data_allocator_pop (&context->data_stack, frame);
goto exit_frame;
}
#ifdef ENABLE_EXPERIMENT_TIERED
#define BACK_BRANCH_PROFILE(offset) do { \
if (offset < 0) \
mini_tiered_inc (frame->imethod->method, &frame->imethod->tiered_counter, 0); \
} while (0);
#else
#define BACK_BRANCH_PROFILE(offset)
#endif
MINT_IN_CASE(MINT_BR_S) {
short br_offset = (short) *(ip + 1);
BACK_BRANCH_PROFILE (br_offset);
ip += br_offset;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BR) {
gint32 br_offset = (gint32) READ32(ip + 1);
BACK_BRANCH_PROFILE (br_offset);
ip += br_offset;
MINT_IN_BREAK;
}
#define ZEROP_S(datatype, op) \
if (LOCAL_VAR (ip [1], datatype) op 0) { \
gint16 br_offset = (gint16) ip [2]; \
BACK_BRANCH_PROFILE (br_offset); \
ip += br_offset; \
} else \
ip += 3;
#define ZEROP(datatype, op) \
if (LOCAL_VAR (ip [1], datatype) op 0) { \
gint32 br_offset = (gint32)READ32(ip + 2); \
BACK_BRANCH_PROFILE (br_offset); \
ip += br_offset; \
} else \
ip += 4;
MINT_IN_CASE(MINT_BRFALSE_I4_S)
ZEROP_S(gint32, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_I8_S)
ZEROP_S(gint64, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_R4_S)
ZEROP_S(float, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_R8_S)
ZEROP_S(double, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_I4)
ZEROP(gint32, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_I8)
ZEROP(gint64, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_R4)
ZEROP_S(float, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_R8)
ZEROP_S(double, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_I4_S)
ZEROP_S(gint32, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_I8_S)
ZEROP_S(gint64, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_R4_S)
ZEROP_S(float, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_R8_S)
ZEROP_S(double, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_I4)
ZEROP(gint32, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_I8)
ZEROP(gint64, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_R4)
ZEROP(float, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_R8)
ZEROP(double, !=);
MINT_IN_BREAK;
#define CONDBR_S(cond) \
if (cond) { \
gint16 br_offset = (gint16) ip [3]; \
BACK_BRANCH_PROFILE (br_offset); \
ip += br_offset; \
} else \
ip += 4;
#define BRELOP_S(datatype, op) \
CONDBR_S(LOCAL_VAR (ip [1], datatype) op LOCAL_VAR (ip [2], datatype))
#define CONDBR(cond) \
if (cond) { \
gint32 br_offset = (gint32) READ32 (ip + 3); \
BACK_BRANCH_PROFILE (br_offset); \
ip += br_offset; \
} else \
ip += 5;
#define BRELOP(datatype, op) \
CONDBR(LOCAL_VAR (ip [1], datatype) op LOCAL_VAR (ip [2], datatype))
MINT_IN_CASE(MINT_BEQ_I4_S)
BRELOP_S(gint32, ==)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BEQ_I8_S)
BRELOP_S(gint64, ==)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BEQ_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(!isunordered (f1, f2) && f1 == f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BEQ_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(!mono_isunordered (d1, d2) && d1 == d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BEQ_I4)
BRELOP(gint32, ==)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BEQ_I8)
BRELOP(gint64, ==)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BEQ_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(!isunordered (f1, f2) && f1 == f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BEQ_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(!mono_isunordered (d1, d2) && d1 == d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_I4_S)
BRELOP_S(gint32, >=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_I8_S)
BRELOP_S(gint64, >=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(!isunordered (f1, f2) && f1 >= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(!mono_isunordered (d1, d2) && d1 >= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_I4)
BRELOP(gint32, >=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_I8)
BRELOP(gint64, >=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(!isunordered (f1, f2) && f1 >= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(!mono_isunordered (d1, d2) && d1 >= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_I4_S)
BRELOP_S(gint32, >)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_I8_S)
BRELOP_S(gint64, >)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(!isunordered (f1, f2) && f1 > f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(!mono_isunordered (d1, d2) && d1 > d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_I4)
BRELOP(gint32, >)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_I8)
BRELOP(gint64, >)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(!isunordered (f1, f2) && f1 > f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(!mono_isunordered (d1, d2) && d1 > d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_I4_S)
BRELOP_S(gint32, <)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_I8_S)
BRELOP_S(gint64, <)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(!isunordered (f1, f2) && f1 < f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(!mono_isunordered (d1, d2) && d1 < d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_I4)
BRELOP(gint32, <)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_I8)
BRELOP(gint64, <)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(!isunordered (f1, f2) && f1 < f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(!mono_isunordered (d1, d2) && d1 < d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_I4_S)
BRELOP_S(gint32, <=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_I8_S)
BRELOP_S(gint64, <=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(!isunordered (f1, f2) && f1 <= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(!mono_isunordered (d1, d2) && d1 <= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_I4)
BRELOP(gint32, <=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_I8)
BRELOP(gint64, <=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(!isunordered (f1, f2) && f1 <= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(!mono_isunordered (d1, d2) && d1 <= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BNE_UN_I4_S)
BRELOP_S(gint32, !=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_I8_S)
BRELOP_S(gint64, !=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(isunordered (f1, f2) || f1 != f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BNE_UN_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(mono_isunordered (d1, d2) || d1 != d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BNE_UN_I4)
BRELOP(gint32, !=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_I8)
BRELOP(gint64, !=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(isunordered (f1, f2) || f1 != f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BNE_UN_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(mono_isunordered (d1, d2) || d1 != d2)
MINT_IN_BREAK;
}
#define BRELOP_S_CAST(datatype, op) \
if (LOCAL_VAR (ip [1], datatype) op LOCAL_VAR (ip [2], datatype)) { \
gint16 br_offset = (gint16) ip [3]; \
BACK_BRANCH_PROFILE (br_offset); \
ip += br_offset; \
} else \
ip += 4;
#define BRELOP_CAST(datatype, op) \
if (LOCAL_VAR (ip [1], datatype) op LOCAL_VAR (ip [2], datatype)) { \
gint32 br_offset = (gint32)READ32(ip + 3); \
BACK_BRANCH_PROFILE (br_offset); \
ip += br_offset; \
} else \
ip += 5;
MINT_IN_CASE(MINT_BGE_UN_I4_S)
BRELOP_S_CAST(guint32, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_I8_S)
BRELOP_S_CAST(guint64, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(isunordered (f1, f2) || f1 >= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_UN_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(mono_isunordered (d1, d2) || d1 >= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_UN_I4)
BRELOP_CAST(guint32, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_I8)
BRELOP_CAST(guint64, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(isunordered (f1, f2) || f1 >= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_UN_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(mono_isunordered (d1, d2) || d1 >= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_UN_I4_S)
BRELOP_S_CAST(guint32, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_I8_S)
BRELOP_S_CAST(guint64, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(isunordered (f1, f2) || f1 > f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_UN_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(mono_isunordered (d1, d2) || d1 > d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_UN_I4)
BRELOP_CAST(guint32, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_I8)
BRELOP_CAST(guint64, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(isunordered (f1, f2) || f1 > f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_UN_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(mono_isunordered (d1, d2) || d1 > d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_UN_I4_S)
BRELOP_S_CAST(guint32, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_I8_S)
BRELOP_S_CAST(guint64, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(isunordered (f1, f2) || f1 <= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_UN_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(mono_isunordered (d1, d2) || d1 <= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_UN_I4)
BRELOP_CAST(guint32, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_I8)
BRELOP_CAST(guint64, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(isunordered (f1, f2) || f1 <= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_UN_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(mono_isunordered (d1, d2) || d1 <= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_UN_I4_S)
BRELOP_S_CAST(guint32, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_I8_S)
BRELOP_S_CAST(guint64, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(isunordered (f1, f2) || f1 < f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_UN_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(mono_isunordered (d1, d2) || d1 < d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_UN_I4)
BRELOP_CAST(guint32, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_I8)
BRELOP_CAST(guint64, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(isunordered (f1, f2) || f1 < f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_UN_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(mono_isunordered (d1, d2) || d1 < d2)
MINT_IN_BREAK;
}
#define ZEROP_SP(datatype, op) \
if (LOCAL_VAR (ip [1], datatype) op 0) { \
gint16 br_offset = (gint16) ip [2]; \
BACK_BRANCH_PROFILE (br_offset); \
SAFEPOINT; \
ip += br_offset; \
} else \
ip += 3;
MINT_IN_CASE(MINT_BRFALSE_I4_SP) ZEROP_SP(gint32, ==); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_I8_SP) ZEROP_SP(gint64, ==); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_I4_SP) ZEROP_SP(gint32, !=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK;
#define CONDBR_SP(cond) \
if (cond) { \
gint16 br_offset = (gint16) ip [3]; \
BACK_BRANCH_PROFILE (br_offset); \
SAFEPOINT; \
ip += br_offset; \
} else \
ip += 4;
#define BRELOP_SP(datatype, op) \
CONDBR_SP(LOCAL_VAR (ip [1], datatype) op LOCAL_VAR (ip [2], datatype))
MINT_IN_CASE(MINT_BEQ_I4_SP) BRELOP_SP(gint32, ==); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BEQ_I8_SP) BRELOP_SP(gint64, ==); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_I4_SP) BRELOP_SP(gint32, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_I8_SP) BRELOP_SP(gint64, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_I4_SP) BRELOP_SP(gint32, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_I8_SP) BRELOP_SP(gint64, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_I4_SP) BRELOP_SP(gint32, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_I8_SP) BRELOP_SP(gint64, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_I4_SP) BRELOP_SP(gint32, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_I8_SP) BRELOP_SP(gint64, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_I4_SP) BRELOP_SP(guint32, !=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_I8_SP) BRELOP_SP(guint64, !=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_I4_SP) BRELOP_SP(guint32, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_I8_SP) BRELOP_SP(guint64, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_I4_SP) BRELOP_SP(guint32, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_I8_SP) BRELOP_SP(guint64, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_I4_SP) BRELOP_SP(guint32, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_I8_SP) BRELOP_SP(guint64, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_I4_SP) BRELOP_SP(guint32, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_I8_SP) BRELOP_SP(guint64, <); MINT_IN_BREAK;
#define BRELOP_IMM_SP(datatype, op) \
CONDBR_SP(LOCAL_VAR (ip [1], datatype) op (datatype)(gint16)ip [2])
MINT_IN_CASE(MINT_BEQ_I4_IMM_SP) BRELOP_IMM_SP(gint32, ==); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BEQ_I8_IMM_SP) BRELOP_IMM_SP(gint64, ==); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_I4_IMM_SP) BRELOP_IMM_SP(gint32, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_I8_IMM_SP) BRELOP_IMM_SP(gint64, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_I4_IMM_SP) BRELOP_IMM_SP(gint32, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_I8_IMM_SP) BRELOP_IMM_SP(gint64, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_I4_IMM_SP) BRELOP_IMM_SP(gint32, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_I8_IMM_SP) BRELOP_IMM_SP(gint64, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_I4_IMM_SP) BRELOP_IMM_SP(gint32, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_I8_IMM_SP) BRELOP_IMM_SP(gint64, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_I4_IMM_SP) BRELOP_IMM_SP(guint32, !=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_I8_IMM_SP) BRELOP_IMM_SP(guint64, !=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_I4_IMM_SP) BRELOP_IMM_SP(guint32, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_I8_IMM_SP) BRELOP_IMM_SP(guint64, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_I4_IMM_SP) BRELOP_IMM_SP(guint32, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_I8_IMM_SP) BRELOP_IMM_SP(guint64, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_I4_IMM_SP) BRELOP_IMM_SP(guint32, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_I8_IMM_SP) BRELOP_IMM_SP(guint64, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_I4_IMM_SP) BRELOP_IMM_SP(guint32, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_I8_IMM_SP) BRELOP_IMM_SP(guint64, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SWITCH) {
guint32 val = LOCAL_VAR (ip [1], guint32);
guint32 n = READ32 (ip + 2);
ip += 4;
if (val < n) {
ip += 2 * val;
int offset = READ32 (ip);
ip += offset;
} else {
ip += 2 * n;
}
MINT_IN_BREAK;
}
#define LDIND(datatype,casttype,unaligned) do { \
gpointer ptr = LOCAL_VAR (ip [2], gpointer); \
NULL_CHECK (ptr); \
if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \
memcpy (locals + ip [1], ptr, sizeof (datatype)); \
else \
LOCAL_VAR (ip [1], datatype) = *(casttype*)ptr; \
ip += 3; \
} while (0)
MINT_IN_CASE(MINT_LDIND_I1)
LDIND(int, gint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_U1)
LDIND(int, guint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_I2)
LDIND(int, gint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_U2)
LDIND(int, guint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_I4) {
LDIND(int, gint32, FALSE);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDIND_I8)
#ifdef NO_UNALIGNED_ACCESS
LDIND(gint64, gint64, TRUE);
#else
LDIND(gint64, gint64, FALSE);
#endif
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_R4)
LDIND(float, gfloat, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_R8)
#ifdef NO_UNALIGNED_ACCESS
LDIND(double, gdouble, TRUE);
#else
LDIND(double, gdouble, FALSE);
#endif
MINT_IN_BREAK;
#define LDIND_OFFSET(datatype,casttype,unaligned) do { \
gpointer ptr = LOCAL_VAR (ip [2], gpointer); \
NULL_CHECK (ptr); \
ptr = (char*)ptr + LOCAL_VAR (ip [3], mono_i); \
if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \
memcpy (locals + ip [1], ptr, sizeof (datatype)); \
else \
LOCAL_VAR (ip [1], datatype) = *(casttype*)ptr; \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_LDIND_OFFSET_I1)
LDIND_OFFSET(int, gint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_U1)
LDIND_OFFSET(int, guint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_I2)
LDIND_OFFSET(int, gint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_U2)
LDIND_OFFSET(int, guint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_I4)
LDIND_OFFSET(int, gint32, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_I8)
#ifdef NO_UNALIGNED_ACCESS
LDIND_OFFSET(gint64, gint64, TRUE);
#else
LDIND_OFFSET(gint64, gint64, FALSE);
#endif
MINT_IN_BREAK;
#define LDIND_OFFSET_IMM(datatype,casttype,unaligned) do { \
gpointer ptr = LOCAL_VAR (ip [2], gpointer); \
NULL_CHECK (ptr); \
ptr = (char*)ptr + (gint16)ip [3]; \
if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \
memcpy (locals + ip [1], ptr, sizeof (datatype)); \
else \
LOCAL_VAR (ip [1], datatype) = *(casttype*)ptr; \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_LDIND_OFFSET_IMM_I1)
LDIND_OFFSET_IMM(int, gint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_IMM_U1)
LDIND_OFFSET_IMM(int, guint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_IMM_I2)
LDIND_OFFSET_IMM(int, gint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_IMM_U2)
LDIND_OFFSET_IMM(int, guint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_IMM_I4)
LDIND_OFFSET_IMM(int, gint32, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_IMM_I8)
#ifdef NO_UNALIGNED_ACCESS
LDIND_OFFSET_IMM(gint64, gint64, TRUE);
#else
LDIND_OFFSET_IMM(gint64, gint64, FALSE);
#endif
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_REF) {
gpointer ptr = LOCAL_VAR (ip [1], gpointer);
NULL_CHECK (ptr);
mono_gc_wbarrier_generic_store_internal (ptr, LOCAL_VAR (ip [2], MonoObject*));
ip += 3;
MINT_IN_BREAK;
}
#define STIND(datatype,unaligned) do { \
gpointer ptr = LOCAL_VAR (ip [1], gpointer); \
NULL_CHECK (ptr); \
if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \
memcpy (ptr, locals + ip [2], sizeof (datatype)); \
else \
*(datatype*)ptr = LOCAL_VAR (ip [2], datatype); \
ip += 3; \
} while (0)
MINT_IN_CASE(MINT_STIND_I1)
STIND(gint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_I2)
STIND(gint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_I4)
STIND(gint32, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_I8)
#ifdef NO_UNALIGNED_ACCESS
STIND(gint64, TRUE);
#else
STIND(gint64, FALSE);
#endif
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_R4)
STIND(float, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_R8)
#ifdef NO_UNALIGNED_ACCESS
STIND(double, TRUE);
#else
STIND(double, FALSE);
#endif
MINT_IN_BREAK;
#define STIND_OFFSET(datatype,unaligned) do { \
gpointer ptr = LOCAL_VAR (ip [1], gpointer); \
NULL_CHECK (ptr); \
ptr = (char*)ptr + LOCAL_VAR (ip [2], mono_i); \
if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \
memcpy (ptr, locals + ip [3], sizeof (datatype)); \
else \
*(datatype*)ptr = LOCAL_VAR (ip [3], datatype); \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_STIND_OFFSET_I1)
STIND_OFFSET(gint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_OFFSET_I2)
STIND_OFFSET(gint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_OFFSET_I4)
STIND_OFFSET(gint32, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_OFFSET_I8)
#ifdef NO_UNALIGNED_ACCESS
STIND_OFFSET(gint64, TRUE);
#else
STIND_OFFSET(gint64, FALSE);
#endif
MINT_IN_BREAK;
#define STIND_OFFSET_IMM(datatype,unaligned) do { \
gpointer ptr = LOCAL_VAR (ip [1], gpointer); \
NULL_CHECK (ptr); \
ptr = (char*)ptr + (gint16)ip [3]; \
if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \
memcpy (ptr, locals + ip [2], sizeof (datatype)); \
else \
*(datatype*)ptr = LOCAL_VAR (ip [2], datatype); \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_STIND_OFFSET_IMM_I1)
STIND_OFFSET_IMM(gint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_OFFSET_IMM_I2)
STIND_OFFSET_IMM(gint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_OFFSET_IMM_I4)
STIND_OFFSET_IMM(gint32, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_OFFSET_IMM_I8)
#ifdef NO_UNALIGNED_ACCESS
STIND_OFFSET_IMM(gint64, TRUE);
#else
STIND_OFFSET_IMM(gint64, FALSE);
#endif
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MONO_ATOMIC_STORE_I4)
mono_atomic_store_i32 (LOCAL_VAR (ip [1], gint32*), LOCAL_VAR (ip [2], gint32));
ip += 3;
MINT_IN_BREAK;
#define BINOP(datatype, op) \
LOCAL_VAR (ip [1], datatype) = LOCAL_VAR (ip [2], datatype) op LOCAL_VAR (ip [3], datatype); \
ip += 4;
MINT_IN_CASE(MINT_ADD_I4)
BINOP(gint32, +);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_I8)
BINOP(gint64, +);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_R4)
BINOP(float, +);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_R8)
BINOP(double, +);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD1_I4)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) + 1;
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_I4_IMM)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) + (gint16)ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD1_I8)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) + 1;
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_I8_IMM)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) + (gint16)ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SUB_I4)
BINOP(gint32, -);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SUB_I8)
BINOP(gint64, -);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SUB_R4)
BINOP(float, -);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SUB_R8)
BINOP(double, -);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SUB1_I4)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) - 1;
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SUB1_I8)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) - 1;
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MUL_I4)
BINOP(gint32, *);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MUL_I8)
BINOP(gint64, *);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MUL_I4_IMM)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) * (gint16)ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MUL_I8_IMM)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) * (gint16)ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MUL_R4)
BINOP(float, *);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MUL_R8)
BINOP(double, *);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_DIV_I4) {
gint32 i1 = LOCAL_VAR (ip [2], gint32);
gint32 i2 = LOCAL_VAR (ip [3], gint32);
if (i2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
if (i2 == (-1) && i1 == G_MININT32)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = i1 / i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_DIV_I8) {
gint64 l1 = LOCAL_VAR (ip [2], gint64);
gint64 l2 = LOCAL_VAR (ip [3], gint64);
if (l2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
if (l2 == (-1) && l1 == G_MININT64)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = l1 / l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_DIV_R4)
BINOP(float, /);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_DIV_R8)
BINOP(double, /);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_DIV_UN_I4) {
guint32 i2 = LOCAL_VAR (ip [3], guint32);
if (i2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
LOCAL_VAR (ip [1], guint32) = LOCAL_VAR (ip [2], guint32) / i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_DIV_UN_I8) {
guint64 l2 = LOCAL_VAR (ip [3], guint64);
if (l2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
LOCAL_VAR (ip [1], guint64) = LOCAL_VAR (ip [2], guint64) / l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_REM_I4) {
gint32 i1 = LOCAL_VAR (ip [2], gint32);
gint32 i2 = LOCAL_VAR (ip [3], gint32);
if (i2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
if (i2 == (-1) && i1 == G_MININT32)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = i1 % i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_REM_I8) {
gint64 l1 = LOCAL_VAR (ip [2], gint64);
gint64 l2 = LOCAL_VAR (ip [3], gint64);
if (l2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
if (l2 == (-1) && l1 == G_MININT64)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = l1 % l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_REM_R4)
LOCAL_VAR (ip [1], float) = fmodf (LOCAL_VAR (ip [2], float), LOCAL_VAR (ip [3], float));
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_REM_R8)
LOCAL_VAR (ip [1], double) = fmod (LOCAL_VAR (ip [2], double), LOCAL_VAR (ip [3], double));
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_REM_UN_I4) {
guint32 i2 = LOCAL_VAR (ip [3], guint32);
if (i2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
LOCAL_VAR (ip [1], guint32) = LOCAL_VAR (ip [2], guint32) % i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_REM_UN_I8) {
guint64 l2 = LOCAL_VAR (ip [3], guint64);
if (l2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
LOCAL_VAR (ip [1], guint64) = LOCAL_VAR (ip [2], guint64) % l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_AND_I4)
BINOP(gint32, &);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_AND_I8)
BINOP(gint64, &);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_OR_I4)
BINOP(gint32, |);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_OR_I8)
BINOP(gint64, |);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_XOR_I4)
BINOP(gint32, ^);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_XOR_I8)
BINOP(gint64, ^);
MINT_IN_BREAK;
#define SHIFTOP(datatype, op) \
LOCAL_VAR (ip [1], datatype) = LOCAL_VAR (ip [2], datatype) op LOCAL_VAR (ip [3], gint32); \
ip += 4;
MINT_IN_CASE(MINT_SHL_I4)
SHIFTOP(gint32, <<);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHL_I8)
SHIFTOP(gint64, <<);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_I4)
SHIFTOP(gint32, >>);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_I8)
SHIFTOP(gint64, >>);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_UN_I4)
SHIFTOP(guint32, >>);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_UN_I8)
SHIFTOP(guint64, >>);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHL_I4_IMM)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) << ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHL_I8_IMM)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) << ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_I4_IMM)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) >> ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_I8_IMM)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) >> ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_UN_I4_IMM)
LOCAL_VAR (ip [1], guint32) = LOCAL_VAR (ip [2], guint32) >> ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_UN_I8_IMM)
LOCAL_VAR (ip [1], guint64) = LOCAL_VAR (ip [2], guint64) >> ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NEG_I4)
LOCAL_VAR (ip [1], gint32) = - LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NEG_I8)
LOCAL_VAR (ip [1], gint64) = - LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NEG_R4)
LOCAL_VAR (ip [1], float) = - LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NEG_R8)
LOCAL_VAR (ip [1], double) = - LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NOT_I4)
LOCAL_VAR (ip [1], gint32) = ~ LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NOT_I8)
LOCAL_VAR (ip [1], gint64) = ~ LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I1_I4)
// FIXME read casted var directly and remove redundant conv opcodes
LOCAL_VAR (ip [1], gint32) = (gint8)LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I1_I8)
LOCAL_VAR (ip [1], gint32) = (gint8)LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I1_R4)
LOCAL_VAR (ip [1], gint32) = (gint8) (gint32) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I1_R8)
/* without gint32 cast, C compiler is allowed to use undefined
* behaviour if data.f is bigger than >255. See conv.fpint section
* in C standard:
* > The conversion truncates; that is, the fractional part
* > is discarded. The behavior is undefined if the truncated
* > value cannot be represented in the destination type.
* */
LOCAL_VAR (ip [1], gint32) = (gint8) (gint32) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U1_I4)
LOCAL_VAR (ip [1], gint32) = (guint8) LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U1_I8)
LOCAL_VAR (ip [1], gint32) = (guint8) LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U1_R4)
LOCAL_VAR (ip [1], gint32) = (guint8) (guint32) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U1_R8)
LOCAL_VAR (ip [1], gint32) = (guint8) (guint32) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I2_I4)
LOCAL_VAR (ip [1], gint32) = (gint16) LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I2_I8)
LOCAL_VAR (ip [1], gint32) = (gint16) LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I2_R4)
LOCAL_VAR (ip [1], gint32) = (gint16) (gint32) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I2_R8)
LOCAL_VAR (ip [1], gint32) = (gint16) (gint32) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U2_I4)
LOCAL_VAR (ip [1], gint32) = (guint16) LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U2_I8)
LOCAL_VAR (ip [1], gint32) = (guint16) LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U2_R4)
LOCAL_VAR (ip [1], gint32) = (guint16) (guint32) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U2_R8)
LOCAL_VAR (ip [1], gint32) = (guint16) (guint32) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I4_R4)
LOCAL_VAR (ip [1], gint32) = (gint32) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I4_R8)
LOCAL_VAR (ip [1], gint32) = (gint32) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U4_R4)
#ifdef MONO_ARCH_EMULATE_FCONV_TO_U4
LOCAL_VAR (ip [1], gint32) = mono_rconv_u4 (LOCAL_VAR (ip [2], float));
#else
LOCAL_VAR (ip [1], gint32) = (guint32) LOCAL_VAR (ip [2], float);
#endif
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U4_R8)
#ifdef MONO_ARCH_EMULATE_FCONV_TO_U4
LOCAL_VAR (ip [1], gint32) = mono_fconv_u4 (LOCAL_VAR (ip [2], double));
#else
LOCAL_VAR (ip [1], gint32) = (guint32) LOCAL_VAR (ip [2], double);
#endif
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I8_I4)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I8_U4)
LOCAL_VAR (ip [1], gint64) = (guint32) LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I8_R4)
LOCAL_VAR (ip [1], gint64) = (gint64) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I8_R8)
LOCAL_VAR (ip [1], gint64) = (gint64) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R4_I4)
LOCAL_VAR (ip [1], float) = (float) LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R4_I8)
LOCAL_VAR (ip [1], float) = (float) LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R4_R8)
LOCAL_VAR (ip [1], float) = (float) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R8_I4)
LOCAL_VAR (ip [1], double) = (double) LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R8_I8)
LOCAL_VAR (ip [1], double) = (double) LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R8_R4)
LOCAL_VAR (ip [1], double) = (double) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U8_R4)
#ifdef MONO_ARCH_EMULATE_FCONV_TO_U8
LOCAL_VAR (ip [1], gint64) = mono_rconv_u8 (LOCAL_VAR (ip [2], float));
#else
LOCAL_VAR (ip [1], gint64) = (guint64) LOCAL_VAR (ip [2], float);
#endif
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U8_R8)
#ifdef MONO_ARCH_EMULATE_FCONV_TO_U8
LOCAL_VAR (ip [1], gint64) = mono_fconv_u8 (LOCAL_VAR (ip [2], double));
#else
LOCAL_VAR (ip [1], gint64) = (guint64) LOCAL_VAR (ip [2], double);
#endif
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CPOBJ) {
MonoClass* const c = (MonoClass*)frame->imethod->data_items[ip [3]];
g_assert (m_class_is_valuetype (c));
/* if this assertion fails, we need to add a write barrier */
g_assert (!MONO_TYPE_IS_REFERENCE (m_class_get_byval_arg (c)));
stackval_from_data (m_class_get_byval_arg (c), (stackval*)LOCAL_VAR (ip [1], gpointer), LOCAL_VAR (ip [2], gpointer), FALSE);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CPOBJ_VT) {
MonoClass* const c = (MonoClass*)frame->imethod->data_items[ip [3]];
mono_value_copy_internal (LOCAL_VAR (ip [1], gpointer), LOCAL_VAR (ip [2], gpointer), c);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDOBJ_VT) {
guint16 size = ip [3];
memcpy (locals + ip [1], LOCAL_VAR (ip [2], gpointer), size);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDSTR)
LOCAL_VAR (ip [1], gpointer) = frame->imethod->data_items [ip [2]];
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSTR_TOKEN) {
MonoString *s = NULL;
guint32 strtoken = (guint32)(gsize)frame->imethod->data_items [ip [2]];
MonoMethod *method = frame->imethod->method;
if (method->wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD) {
s = (MonoString*)mono_method_get_wrapper_data (method, strtoken);
} else if (method->wrapper_type != MONO_WRAPPER_NONE) {
// FIXME push/pop LMF
s = mono_string_new_wrapper_internal ((const char*)mono_method_get_wrapper_data (method, strtoken));
} else {
g_assert_not_reached ();
}
LOCAL_VAR (ip [1], gpointer) = s;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWOBJ_ARRAY) {
MonoClass *newobj_class;
guint32 token = ip [3];
guint16 param_count = ip [4];
newobj_class = (MonoClass*) frame->imethod->data_items [token];
// FIXME push/pop LMF
LOCAL_VAR (ip [1], MonoObject*) = ves_array_create (newobj_class, param_count, (stackval*)(locals + ip [2]), error);
if (!is_ok (error))
THROW_EX (interp_error_convert_to_exception (frame, error, ip), ip);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWOBJ_STRING) {
cmethod = (InterpMethod*)frame->imethod->data_items [ip [3]];
return_offset = ip [1];
call_args_offset = ip [2];
// `this` is implicit null. The created string will be returned
// by the call, even though the call has void return (?!).
LOCAL_VAR (call_args_offset, gpointer) = NULL;
ip += 4;
goto call;
}
MINT_IN_CASE(MINT_NEWOBJ) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [4]];
INIT_VTABLE (vtable);
guint16 imethod_index = ip [3];
return_offset = ip [1];
call_args_offset = ip [2];
// FIXME push/pop LMF
MonoObject *o = mono_gc_alloc_obj (vtable, m_class_get_instance_size (vtable->klass));
if (G_UNLIKELY (!o)) {
mono_error_set_out_of_memory (error, "Could not allocate %i bytes", m_class_get_instance_size (vtable->klass));
THROW_EX (interp_error_convert_to_exception (frame, error, ip), ip);
}
// This is return value
LOCAL_VAR (return_offset, MonoObject*) = o;
// Set `this` arg for ctor call
LOCAL_VAR (call_args_offset, MonoObject*) = o;
ip += 5;
cmethod = (InterpMethod*)frame->imethod->data_items [imethod_index];
goto call;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWOBJ_INLINED) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [2]];
INIT_VTABLE (vtable);
// FIXME push/pop LMF
MonoObject *o = mono_gc_alloc_obj (vtable, m_class_get_instance_size (vtable->klass));
if (G_UNLIKELY (!o)) {
mono_error_set_out_of_memory (error, "Could not allocate %i bytes", m_class_get_instance_size (vtable->klass));
THROW_EX (interp_error_convert_to_exception (frame, error, ip), ip);
}
// This is return value
LOCAL_VAR (ip [1], MonoObject*) = o;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWOBJ_VT) {
guint16 imethod_index = ip [3];
guint16 ret_size = ip [4];
return_offset = ip [1];
call_args_offset = ip [2];
gpointer this_vt = locals + return_offset;
// clear the valuetype
memset (this_vt, 0, ret_size);
// pass the address of the valuetype
LOCAL_VAR (call_args_offset, gpointer) = this_vt;
ip += 5;
cmethod = (InterpMethod*)frame->imethod->data_items [imethod_index];
goto call;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWOBJ_VT_INLINED) {
guint16 ret_size = ip [3];
gpointer this_vt = locals + ip [2];
memset (this_vt, 0, ret_size);
LOCAL_VAR (ip [1], gpointer) = this_vt;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWOBJ_SLOW) {
guint32 const token = ip [3];
return_offset = ip [1];
call_args_offset = ip [2];
cmethod = (InterpMethod*)frame->imethod->data_items [token];
MonoClass * const newobj_class = cmethod->method->klass;
/*
* First arg is the object.
* a constructor returns void, but we need to return the object we created
*/
g_assert (!m_class_is_valuetype (newobj_class));
// FIXME push/pop LMF
MonoVTable *vtable = mono_class_vtable_checked (newobj_class, error);
if (!is_ok (error) || !mono_runtime_class_init_full (vtable, error)) {
MonoException *exc = interp_error_convert_to_exception (frame, error, ip);
g_assert (exc);
THROW_EX (exc, ip);
}
error_init_reuse (error);
MonoObject* o = mono_object_new_checked (newobj_class, error);
LOCAL_VAR (return_offset, MonoObject*) = o; // return value
LOCAL_VAR (call_args_offset, MonoObject*) = o; // first parameter
mono_interp_error_cleanup (error); // FIXME: do not swallow the error
EXCEPTION_CHECKPOINT;
ip += 4;
goto call;
}
MINT_IN_CASE(MINT_INTRINS_SPAN_CTOR) {
gpointer ptr = LOCAL_VAR (ip [2], gpointer);
int len = LOCAL_VAR (ip [3], gint32);
if (len < 0)
THROW_EX (interp_get_exception_argument_out_of_range ("length", frame, ip), ip);
gpointer span = locals + ip [1];
*(gpointer*)span = ptr;
*(gint32*)((gpointer*)span + 1) = len;
ip += 4;;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_CLEAR_WITH_REFERENCES) {
gpointer p = LOCAL_VAR (ip [1], gpointer);
size_t size = LOCAL_VAR (ip [2], mono_u) * sizeof (gpointer);
mono_gc_bzero_aligned (p, size);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_MARVIN_BLOCK) {
interp_intrins_marvin_block ((guint32*)(locals + ip [1]), (guint32*)(locals + ip [2]));
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_ASCII_CHARS_TO_UPPERCASE) {
LOCAL_VAR (ip [1], gint32) = interp_intrins_ascii_chars_to_uppercase (LOCAL_VAR (ip [2], guint32));
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_MEMORYMARSHAL_GETARRAYDATAREF) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], gpointer) = (guint8*)o + MONO_STRUCT_OFFSET (MonoArray, vector);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_ORDINAL_IGNORE_CASE_ASCII) {
LOCAL_VAR (ip [1], gint32) = interp_intrins_ordinal_ignore_case_ascii (LOCAL_VAR (ip [2], guint32), LOCAL_VAR (ip [3], guint32));
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_64ORDINAL_IGNORE_CASE_ASCII) {
LOCAL_VAR (ip [1], gint32) = interp_intrins_64ordinal_ignore_case_ascii (LOCAL_VAR (ip [2], guint64), LOCAL_VAR (ip [3], guint64));
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_U32_TO_DECSTR) {
MonoArray **cache_addr = (MonoArray**)frame->imethod->data_items [ip [3]];
MonoVTable *string_vtable = (MonoVTable*)frame->imethod->data_items [ip [4]];
LOCAL_VAR (ip [1], MonoObject*) = (MonoObject*)interp_intrins_u32_to_decstr (LOCAL_VAR (ip [2], guint32), *cache_addr, string_vtable);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_WIDEN_ASCII_TO_UTF16) {
LOCAL_VAR (ip [1], mono_u) = interp_intrins_widen_ascii_to_utf16 (LOCAL_VAR (ip [2], guint8*), LOCAL_VAR (ip [3], mono_unichar2*), LOCAL_VAR (ip [4], mono_u));
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_UNSAFE_BYTE_OFFSET) {
LOCAL_VAR (ip [1], mono_u) = LOCAL_VAR (ip [3], guint8*) - LOCAL_VAR (ip [2], guint8*);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_RUNTIMEHELPERS_OBJECT_HAS_COMPONENT_SIZE) {
MonoObject *obj = LOCAL_VAR (ip [2], MonoObject*);
LOCAL_VAR (ip [1], gint32) = (obj->vtable->flags & MONO_VT_FLAG_ARRAY_OR_STRING) != 0;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CASTCLASS_INTERFACE)
MINT_IN_CASE(MINT_ISINST_INTERFACE) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
if (o) {
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
gboolean isinst;
if (MONO_VTABLE_IMPLEMENTS_INTERFACE (o->vtable, m_class_get_interface_id (c))) {
isinst = TRUE;
} else if (m_class_is_array_special_interface (c)) {
/* slow path */
// FIXME push/pop LMF
isinst = mono_interp_isinst (o, c); // FIXME: do not swallow the error
} else {
isinst = FALSE;
}
if (!isinst) {
gboolean const isinst_instr = *ip == MINT_ISINST_INTERFACE;
if (isinst_instr)
LOCAL_VAR (ip [1], MonoObject*) = NULL;
else
THROW_EX (interp_get_exception_invalid_cast (frame, ip), ip);
} else {
LOCAL_VAR (ip [1], MonoObject*) = o;
}
} else {
LOCAL_VAR (ip [1], MonoObject*) = NULL;
}
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CASTCLASS_COMMON)
MINT_IN_CASE(MINT_ISINST_COMMON) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
if (o) {
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
gboolean isinst = mono_class_has_parent_fast (o->vtable->klass, c);
if (!isinst) {
gboolean const isinst_instr = *ip == MINT_ISINST_COMMON;
if (isinst_instr)
LOCAL_VAR (ip [1], MonoObject*) = NULL;
else
THROW_EX (interp_get_exception_invalid_cast (frame, ip), ip);
} else {
LOCAL_VAR (ip [1], MonoObject*) = o;
}
} else {
LOCAL_VAR (ip [1], MonoObject*) = NULL;
}
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CASTCLASS)
MINT_IN_CASE(MINT_ISINST) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
if (o) {
MonoClass* const c = (MonoClass*)frame->imethod->data_items [ip [3]];
// FIXME push/pop LMF
if (!mono_interp_isinst (o, c)) { // FIXME: do not swallow the error
gboolean const isinst_instr = *ip == MINT_ISINST;
if (isinst_instr)
LOCAL_VAR (ip [1], MonoObject*) = NULL;
else
THROW_EX (interp_get_exception_invalid_cast (frame, ip), ip);
} else {
LOCAL_VAR (ip [1], MonoObject*) = o;
}
} else {
LOCAL_VAR (ip [1], MonoObject*) = NULL;
}
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_R_UN_I4)
LOCAL_VAR (ip [1], double) = (double)LOCAL_VAR (ip [2], guint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R_UN_I8)
LOCAL_VAR (ip [1], double) = (double)LOCAL_VAR (ip [2], guint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_UNBOX) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
if (!(m_class_get_rank (o->vtable->klass) == 0 && m_class_get_element_class (o->vtable->klass) == m_class_get_element_class (c)))
THROW_EX (interp_get_exception_invalid_cast (frame, ip), ip);
LOCAL_VAR (ip [1], gpointer) = mono_object_unbox_internal (o);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_THROW) {
MonoException *ex = LOCAL_VAR (ip [1], MonoException*);
if (!ex)
ex = interp_get_exception_null_reference (frame, ip);
THROW_EX (ex, ip);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_SAFEPOINT)
SAFEPOINT;
++ip;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLDA_UNSAFE) {
LOCAL_VAR (ip [1], gpointer) = (char*)LOCAL_VAR (ip [2], gpointer) + ip [3];
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDFLDA) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], gpointer) = (char *)o + ip [3];
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CKNULL) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], MonoObject*) = o;
ip += 3;
MINT_IN_BREAK;
}
#define LDFLD_UNALIGNED(datatype, fieldtype, unaligned) do { \
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*); \
NULL_CHECK (o); \
if (unaligned) \
memcpy (locals + ip [1], (char *)o + ip [3], sizeof (fieldtype)); \
else \
LOCAL_VAR (ip [1], datatype) = * (fieldtype *)((char *)o + ip [3]) ; \
ip += 4; \
} while (0)
#define LDFLD(datamem, fieldtype) LDFLD_UNALIGNED(datamem, fieldtype, FALSE)
MINT_IN_CASE(MINT_LDFLD_I1) LDFLD(gint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_U1) LDFLD(gint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_I2) LDFLD(gint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_U2) LDFLD(gint32, guint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_I4) LDFLD(gint32, gint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_I8) LDFLD(gint64, gint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_R4) LDFLD(float, float); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_R8) LDFLD(double, double); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_O) LDFLD(gpointer, gpointer); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_I8_UNALIGNED) LDFLD_UNALIGNED(gint64, gint64, TRUE); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_R8_UNALIGNED) LDFLD_UNALIGNED(double, double, TRUE); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_VT) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
memcpy (locals + ip [1], (char *)o + ip [3], ip [4]);
ip += 5;
MINT_IN_BREAK;
}
#define STFLD_UNALIGNED(datatype, fieldtype, unaligned) do { \
MonoObject *o = LOCAL_VAR (ip [1], MonoObject*); \
NULL_CHECK (o); \
if (unaligned) \
memcpy ((char *)o + ip [3], locals + ip [2], sizeof (fieldtype)); \
else \
* (fieldtype *)((char *)o + ip [3]) = LOCAL_VAR (ip [2], datatype); \
ip += 4; \
} while (0)
#define STFLD(datamem, fieldtype) STFLD_UNALIGNED(datamem, fieldtype, FALSE)
MINT_IN_CASE(MINT_STFLD_I1) STFLD(gint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_U1) STFLD(gint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_I2) STFLD(gint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_U2) STFLD(gint32, guint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_I4) STFLD(gint32, gint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_I8) STFLD(gint64, gint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_R4) STFLD(float, float); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_R8) STFLD(double, double); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_O) {
MonoObject *o = LOCAL_VAR (ip [1], MonoObject*);
NULL_CHECK (o);
mono_gc_wbarrier_set_field_internal (o, (char*)o + ip [3], LOCAL_VAR (ip [2], MonoObject*));
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_STFLD_I8_UNALIGNED) STFLD_UNALIGNED(gint64, gint64, TRUE); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_R8_UNALIGNED) STFLD_UNALIGNED(double, double, TRUE); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_VT_NOREF) {
MonoObject *o = LOCAL_VAR (ip [1], MonoObject*);
NULL_CHECK (o);
memcpy ((char*)o + ip [3], locals + ip [2], ip [4]);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_STFLD_VT) {
MonoClass *klass = (MonoClass*)frame->imethod->data_items [ip [4]];
MonoObject *o = LOCAL_VAR (ip [1], MonoObject*);
NULL_CHECK (o);
mono_value_copy_internal ((char*)o + ip [3], locals + ip [2], klass);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDSFLDA) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [2]];
INIT_VTABLE (vtable);
LOCAL_VAR (ip [1], gpointer) = frame->imethod->data_items [ip [3]];
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDTSFLDA) {
MonoInternalThread *thread = mono_thread_internal_current ();
guint32 offset = READ32 (ip + 2);
LOCAL_VAR (ip [1], gpointer) = ((char*)thread->static_data [offset & 0x3f]) + (offset >> 6);
ip += 4;
MINT_IN_BREAK;
}
/* We init class here to preserve cctor order */
#define LDSFLD(datatype, fieldtype) { \
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [2]]; \
INIT_VTABLE (vtable); \
LOCAL_VAR (ip [1], datatype) = * (fieldtype *)(frame->imethod->data_items [ip [3]]) ; \
ip += 4; \
}
MINT_IN_CASE(MINT_LDSFLD_I1) LDSFLD(gint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_U1) LDSFLD(gint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_I2) LDSFLD(gint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_U2) LDSFLD(gint32, guint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_I4) LDSFLD(gint32, gint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_I8) LDSFLD(gint64, gint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_R4) LDSFLD(float, float); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_R8) LDSFLD(double, double); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_O) LDSFLD(gpointer, gpointer); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_VT) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [2]];
INIT_VTABLE (vtable);
gpointer addr = frame->imethod->data_items [ip [3]];
guint16 size = ip [4];
memcpy (locals + ip [1], addr, size);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDSFLD_W) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [READ32 (ip + 2)];
INIT_VTABLE (vtable);
gpointer addr = frame->imethod->data_items [READ32 (ip + 4)];
MonoClass *klass = frame->imethod->data_items [READ32 (ip + 6)];
stackval_from_data (m_class_get_byval_arg (klass), (stackval*)(locals + ip [1]), addr, FALSE);
ip += 8;
MINT_IN_BREAK;
}
#define STSFLD(datatype, fieldtype) { \
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [2]]; \
INIT_VTABLE (vtable); \
* (fieldtype *)(frame->imethod->data_items [ip [3]]) = LOCAL_VAR (ip [1], datatype); \
ip += 4; \
}
MINT_IN_CASE(MINT_STSFLD_I1) STSFLD(gint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_U1) STSFLD(gint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_I2) STSFLD(gint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_U2) STSFLD(gint32, guint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_I4) STSFLD(gint32, gint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_I8) STSFLD(gint64, gint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_R4) STSFLD(float, float); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_R8) STSFLD(double, double); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_O) STSFLD(gpointer, gpointer); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_VT) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [2]];
INIT_VTABLE (vtable);
gpointer addr = frame->imethod->data_items [ip [3]];
memcpy (addr, locals + ip [1], ip [4]);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_STSFLD_W) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [READ32 (ip + 2)];
INIT_VTABLE (vtable);
gpointer addr = frame->imethod->data_items [READ32 (ip + 4)];
MonoClass *klass = frame->imethod->data_items [READ32 (ip + 6)];
stackval_to_data (m_class_get_byval_arg (klass), (stackval*)(locals + ip [1]), addr, FALSE);
ip += 8;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_STOBJ_VT) {
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
mono_value_copy_internal (LOCAL_VAR (ip [1], gpointer), locals + ip [2], c);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U8_I4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint64) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U8_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < 0)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint64) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I8_U8) {
guint64 val = LOCAL_VAR (ip [2], guint64);
if (val > G_MAXINT64)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U8_R4) {
float val = LOCAL_VAR (ip [2], float);
if (!mono_try_trunc_u64 (val, (guint64*)(locals + ip [1])))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U8_R8) {
double val = LOCAL_VAR (ip [2], double);
if (!mono_try_trunc_u64 (val, (guint64*)(locals + ip [1])))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I8_R4) {
float val = LOCAL_VAR (ip [2], float);
if (!mono_try_trunc_i64 (val, (gint64*)(locals + ip [1])))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I8_R8) {
double val = LOCAL_VAR (ip [2], double);
if (!mono_try_trunc_i64 (val, (gint64*)(locals + ip [1])))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BOX) {
MonoVTable *vtable = (MonoVTable*)frame->imethod->data_items [ip [3]];
// FIXME push/pop LMF
MonoObject *o = mono_gc_alloc_obj (vtable, m_class_get_instance_size (vtable->klass));
MONO_HANDLE_ASSIGN_RAW (tmp_handle, o);
stackval_to_data (m_class_get_byval_arg (vtable->klass), (stackval*)(locals + ip [2]), mono_object_get_data (o), FALSE);
MONO_HANDLE_ASSIGN_RAW (tmp_handle, NULL);
LOCAL_VAR (ip [1], MonoObject*) = o;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BOX_VT) {
MonoVTable *vtable = (MonoVTable*)frame->imethod->data_items [ip [3]];
MonoClass *c = vtable->klass;
// FIXME push/pop LMF
MonoObject* o = mono_gc_alloc_obj (vtable, m_class_get_instance_size (c));
MONO_HANDLE_ASSIGN_RAW (tmp_handle, o);
mono_value_copy_internal (mono_object_get_data (o), locals + ip [2], c);
MONO_HANDLE_ASSIGN_RAW (tmp_handle, NULL);
LOCAL_VAR (ip [1], MonoObject*) = o;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BOX_PTR) {
MonoVTable *vtable = (MonoVTable*)frame->imethod->data_items [ip [3]];
MonoClass *c = vtable->klass;
// FIXME push/pop LMF
MonoObject* o = mono_gc_alloc_obj (vtable, m_class_get_instance_size (c));
MONO_HANDLE_ASSIGN_RAW (tmp_handle, o);
mono_value_copy_internal (mono_object_get_data (o), LOCAL_VAR (ip [2], gpointer), c);
MONO_HANDLE_ASSIGN_RAW (tmp_handle, NULL);
LOCAL_VAR (ip [1], MonoObject*) = o;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BOX_NULLABLE_PTR) {
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
// FIXME push/pop LMF
LOCAL_VAR (ip [1], MonoObject*) = mono_nullable_box (LOCAL_VAR (ip [2], gpointer), c, error);
mono_interp_error_cleanup (error); /* FIXME: don't swallow the error */
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWARR) {
// FIXME push/pop LMF
MonoVTable *vtable = (MonoVTable*)frame->imethod->data_items [ip [3]];
LOCAL_VAR (ip [1], MonoObject*) = (MonoObject*) mono_array_new_specific_checked (vtable, LOCAL_VAR (ip [2], gint32), error);
if (!is_ok (error)) {
THROW_EX (interp_error_convert_to_exception (frame, error, ip), ip);
}
ip += 4;
/*if (profiling_classes) {
guint count = GPOINTER_TO_UINT (g_hash_table_lookup (profiling_classes, o->vtable->klass));
count++;
g_hash_table_insert (profiling_classes, o->vtable->klass, GUINT_TO_POINTER (count));
}*/
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDLEN) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], mono_u) = mono_array_length_internal ((MonoArray *)o);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDLEN_SPAN) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
// FIXME What's the point of this opcode ? It's just a LDFLD
gsize offset_length = (gsize)(gint16)ip [3];
LOCAL_VAR (ip [1], mono_u) = *(gint32 *) ((guint8 *) o + offset_length);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_GETCHR) {
MonoString *s = LOCAL_VAR (ip [2], MonoString*);
NULL_CHECK (s);
int i32 = LOCAL_VAR (ip [3], int);
if (i32 < 0 || i32 >= mono_string_length_internal (s))
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = mono_string_chars_internal (s)[i32];
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_GETITEM_SPAN) {
guint8 *span = LOCAL_VAR (ip [2], guint8*);
int index = LOCAL_VAR (ip [3], int);
NULL_CHECK (span);
gsize offset_length = (gsize)(gint16)ip [5];
const gint32 length = *(gint32 *) (span + offset_length);
if (index < 0 || index >= length)
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip);
gsize element_size = (gsize)(gint16)ip [4];
gsize offset_pointer = (gsize)(gint16)ip [6];
const gpointer pointer = *(gpointer *)(span + offset_pointer);
LOCAL_VAR (ip [1], gpointer) = (guint8 *) pointer + index * element_size;
ip += 7;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_STRLEN) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], gint32) = mono_string_length_internal ((MonoString*) o);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ARRAY_RANK) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], gint32) = m_class_get_rank (mono_object_class (o));
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ARRAY_ELEMENT_SIZE) {
// FIXME push/pop LMF
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], gint32) = mono_array_element_size (mono_object_class (o));
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ARRAY_IS_PRIMITIVE) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], gint32) = m_class_is_primitive (m_class_get_element_class (mono_object_class (o)));
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDELEMA1) {
/* No bounds, one direction */
MonoArray *ao = LOCAL_VAR (ip [2], MonoArray*);
NULL_CHECK (ao);
gint32 index = LOCAL_VAR (ip [3], gint32);
if (index >= ao->max_length)
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip);
guint16 size = ip [4];
LOCAL_VAR (ip [1], gpointer) = mono_array_addr_with_size_fast (ao, size, index);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDELEMA) {
guint16 rank = ip [3];
guint16 esize = ip [4];
stackval *sp = (stackval*)(locals + ip [2]);
MonoArray *ao = (MonoArray*) sp [0].data.o;
NULL_CHECK (ao);
g_assert (ao->bounds);
guint32 pos = 0;
for (int i = 0; i < rank; i++) {
gint32 idx = sp [i + 1].data.i;
gint32 lower = ao->bounds [i].lower_bound;
guint32 len = ao->bounds [i].length;
if (idx < lower || (guint32)(idx - lower) >= len)
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip);
pos = (pos * len) + (guint32)(idx - lower);
}
LOCAL_VAR (ip [1], gpointer) = mono_array_addr_with_size_fast (ao, esize, pos);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDELEMA_TC) {
// FIXME push/pop LMF
stackval *sp = (stackval*)(locals + ip [2]);
MonoObject *o = (MonoObject*) sp [0].data.o;
NULL_CHECK (o);
MonoClass *klass = (MonoClass*)frame->imethod->data_items [ip [3]];
MonoException *ex = ves_array_element_address (frame, klass, (MonoArray *) o, (gpointer*)(locals + ip [1]), sp + 1, TRUE);
if (ex)
THROW_EX (ex, ip);
ip += 4;
MINT_IN_BREAK;
}
#define LDELEM(datatype,elemtype) do { \
MonoArray *o = LOCAL_VAR (ip [2], MonoArray*); \
NULL_CHECK (o); \
gint32 aindex = LOCAL_VAR (ip [3], gint32); \
if (aindex >= mono_array_length_internal (o)) \
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip); \
LOCAL_VAR (ip [1], datatype) = mono_array_get_fast (o, elemtype, aindex); \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_LDELEM_I1) LDELEM(gint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_U1) LDELEM(gint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_I2) LDELEM(gint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_U2) LDELEM(gint32, guint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_I4) LDELEM(gint32, gint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_U4) LDELEM(gint32, guint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_I8) LDELEM(gint64, guint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_I) LDELEM(mono_u, mono_i); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_R4) LDELEM(float, float); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_R8) LDELEM(double, double); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_REF) LDELEM(gpointer, gpointer); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_VT) {
MonoArray *o = LOCAL_VAR (ip [2], MonoArray*);
NULL_CHECK (o);
mono_u aindex = LOCAL_VAR (ip [3], gint32);
if (aindex >= mono_array_length_internal (o))
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip);
guint16 size = ip [4];
char *src_addr = mono_array_addr_with_size_fast ((MonoArray *) o, size, aindex);
memcpy (locals + ip [1], src_addr, size);
ip += 5;
MINT_IN_BREAK;
}
#define STELEM_PROLOG(o, aindex) do { \
o = LOCAL_VAR (ip [1], MonoArray*); \
NULL_CHECK (o); \
aindex = LOCAL_VAR (ip [2], gint32); \
if (aindex >= mono_array_length_internal (o)) \
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip); \
} while (0)
#define STELEM(datatype, elemtype) do { \
MonoArray *o; \
gint32 aindex; \
STELEM_PROLOG(o, aindex); \
mono_array_set_fast (o, elemtype, aindex, LOCAL_VAR (ip [3], datatype)); \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_STELEM_I1) STELEM(gint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_U1) STELEM(gint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_I2) STELEM(gint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_U2) STELEM(gint32, guint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_I4) STELEM(gint32, gint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_I8) STELEM(gint64, gint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_I) STELEM(mono_u, mono_i); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_R4) STELEM(float, float); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_R8) STELEM(double, double); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_REF) {
MonoArray *o;
gint32 aindex;
STELEM_PROLOG(o, aindex);
MonoObject *ref = LOCAL_VAR (ip [3], MonoObject*);
if (ref) {
// FIXME push/pop LMF
gboolean isinst = mono_interp_isinst (ref, m_class_get_element_class (mono_object_class (o)));
if (!isinst)
THROW_EX (interp_get_exception_array_type_mismatch (frame, ip), ip);
}
mono_array_setref_fast ((MonoArray *) o, aindex, ref);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_STELEM_VT) {
MonoArray *o = LOCAL_VAR (ip [1], MonoArray*);
NULL_CHECK (o);
gint32 aindex = LOCAL_VAR (ip [2], gint32);
if (aindex >= mono_array_length_internal (o))
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip);
guint16 size = ip [5];
char *dst_addr = mono_array_addr_with_size_fast ((MonoArray *) o, size, aindex);
MonoClass *klass_vt = (MonoClass*)frame->imethod->data_items [ip [4]];
mono_value_copy_internal (dst_addr, locals + ip [3], klass_vt);
ip += 6;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I4_U4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I4_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < G_MININT32 || val > G_MAXINT32)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint32) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I4_U8) {
guint64 val = LOCAL_VAR (ip [2], guint64);
if (val > G_MAXINT32)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint32) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I4_R4) {
float val = LOCAL_VAR (ip [2], float);
double val_r8 = (double)val;
if (val_r8 > ((double)G_MININT32 - 1) && val_r8 < ((double)G_MAXINT32 + 1))
LOCAL_VAR (ip [1], gint32) = (gint32) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I4_R8) {
double val = LOCAL_VAR (ip [2], double);
if (val > ((double)G_MININT32 - 1) && val < ((double)G_MAXINT32 + 1))
LOCAL_VAR (ip [1], gint32) = (gint32) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U4_I4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U4_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < 0 || val > G_MAXUINT32)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (guint32) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U4_R4) {
float val = LOCAL_VAR (ip [2], float);
double val_r8 = val;
if (val_r8 > -1.0 && val_r8 < ((double)G_MAXUINT32 + 1))
LOCAL_VAR (ip [1], gint32) = (guint32)val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U4_R8) {
double val = LOCAL_VAR (ip [2], double);
if (val > -1.0 && val < ((double)G_MAXUINT32 + 1))
LOCAL_VAR (ip [1], gint32) = (guint32)val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I2_I4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < G_MININT16 || val > G_MAXINT16)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint16)val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I2_U4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0 || val > G_MAXINT16)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint16)val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I2_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < G_MININT16 || val > G_MAXINT16)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint16) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I2_U8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < 0 || val > G_MAXINT16)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint16) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I2_R4) {
float val = LOCAL_VAR (ip [2], float);
if (val > (G_MININT16 - 1) && val < (G_MAXINT16 + 1))
LOCAL_VAR (ip [1], gint32) = (gint16) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I2_R8) {
double val = LOCAL_VAR (ip [2], double);
if (val > (G_MININT16 - 1) && val < (G_MAXINT16 + 1))
LOCAL_VAR (ip [1], gint32) = (gint16) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U2_I4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0 || val > G_MAXUINT16)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U2_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < 0 || val > G_MAXUINT16)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (guint16) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U2_R4) {
float val = LOCAL_VAR (ip [2], float);
if (val > -1.0f && val < (G_MAXUINT16 + 1))
LOCAL_VAR (ip [1], gint32) = (guint16) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U2_R8) {
double val = LOCAL_VAR (ip [2], double);
if (val > -1.0 && val < (G_MAXUINT16 + 1))
LOCAL_VAR (ip [1], gint32) = (guint16) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I1_I4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < G_MININT8 || val > G_MAXINT8)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I1_U4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0 || val > G_MAXINT8)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I1_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < G_MININT8 || val > G_MAXINT8)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint8) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I1_U8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < 0 || val > G_MAXINT8)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint8) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I1_R4) {
float val = LOCAL_VAR (ip [2], float);
if (val > (G_MININT8 - 1) && val < (G_MAXINT8 + 1))
LOCAL_VAR (ip [1], gint32) = (gint8) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I1_R8) {
double val = LOCAL_VAR (ip [2], double);
if (val > (G_MININT8 - 1) && val < (G_MAXINT8 + 1))
LOCAL_VAR (ip [1], gint32) = (gint8) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U1_I4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0 || val > G_MAXUINT8)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U1_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < 0 || val > G_MAXUINT8)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (guint8) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U1_R4) {
float val = LOCAL_VAR (ip [2], float);
if (val > -1.0f && val < (G_MAXUINT8 + 1))
LOCAL_VAR (ip [1], gint32) = (guint8)val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U1_R8) {
double val = LOCAL_VAR (ip [2], double);
if (val > -1.0 && val < (G_MAXUINT8 + 1))
LOCAL_VAR (ip [1], gint32) = (guint8)val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CKFINITE) {
double val = LOCAL_VAR (ip [2], double);
if (!mono_isfinite (val))
THROW_EX (interp_get_exception_arithmetic (frame, ip), ip);
LOCAL_VAR (ip [1], double) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MKREFANY) {
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
gpointer addr = LOCAL_VAR (ip [2], gpointer);
/* Write the typedref value */
MonoTypedRef *tref = (MonoTypedRef*)(locals + ip [1]);
tref->klass = c;
tref->type = m_class_get_byval_arg (c);
tref->value = addr;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_REFANYTYPE) {
MonoTypedRef *tref = (MonoTypedRef*)(locals + ip [2]);
LOCAL_VAR (ip [1], gpointer) = tref->type;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_REFANYVAL) {
MonoTypedRef *tref = (MonoTypedRef*)(locals + ip [2]);
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
if (c != tref->klass)
THROW_EX (interp_get_exception_invalid_cast (frame, ip), ip);
LOCAL_VAR (ip [1], gpointer) = tref->value;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDTOKEN)
// FIXME same as MINT_MONO_LDPTR
LOCAL_VAR (ip [1], gpointer) = frame->imethod->data_items [ip [2]];
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_OVF_I4) {
gint32 i1 = LOCAL_VAR (ip [2], gint32);
gint32 i2 = LOCAL_VAR (ip [3], gint32);
if (CHECK_ADD_OVERFLOW (i1, i2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = i1 + i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ADD_OVF_I8) {
gint64 l1 = LOCAL_VAR (ip [2], gint64);
gint64 l2 = LOCAL_VAR (ip [3], gint64);
if (CHECK_ADD_OVERFLOW64 (l1, l2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = l1 + l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ADD_OVF_UN_I4) {
guint32 i1 = LOCAL_VAR (ip [2], guint32);
guint32 i2 = LOCAL_VAR (ip [3], guint32);
if (CHECK_ADD_OVERFLOW_UN (i1, i2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint32) = i1 + i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ADD_OVF_UN_I8) {
guint64 l1 = LOCAL_VAR (ip [2], guint64);
guint64 l2 = LOCAL_VAR (ip [3], guint64);
if (CHECK_ADD_OVERFLOW64_UN (l1, l2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint64) = l1 + l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MUL_OVF_I4) {
gint32 i1 = LOCAL_VAR (ip [2], gint32);
gint32 i2 = LOCAL_VAR (ip [3], gint32);
if (CHECK_MUL_OVERFLOW (i1, i2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = i1 * i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MUL_OVF_I8) {
gint64 l1 = LOCAL_VAR (ip [2], gint64);
gint64 l2 = LOCAL_VAR (ip [3], gint64);
if (CHECK_MUL_OVERFLOW64 (l1, l2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = l1 * l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MUL_OVF_UN_I4) {
guint32 i1 = LOCAL_VAR (ip [2], guint32);
guint32 i2 = LOCAL_VAR (ip [3], guint32);
if (CHECK_MUL_OVERFLOW_UN (i1, i2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint32) = i1 * i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MUL_OVF_UN_I8) {
guint64 l1 = LOCAL_VAR (ip [2], guint64);
guint64 l2 = LOCAL_VAR (ip [3], guint64);
if (CHECK_MUL_OVERFLOW64_UN (l1, l2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint64) = l1 * l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_SUB_OVF_I4) {
gint32 i1 = LOCAL_VAR (ip [2], gint32);
gint32 i2 = LOCAL_VAR (ip [3], gint32);
if (CHECK_SUB_OVERFLOW (i1, i2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = i1 - i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_SUB_OVF_I8) {
gint64 l1 = LOCAL_VAR (ip [2], gint64);
gint64 l2 = LOCAL_VAR (ip [3], gint64);
if (CHECK_SUB_OVERFLOW64 (l1, l2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = l1 - l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_SUB_OVF_UN_I4) {
guint32 i1 = LOCAL_VAR (ip [2], guint32);
guint32 i2 = LOCAL_VAR (ip [3], guint32);
if (CHECK_SUB_OVERFLOW_UN (i1, i2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint32) = i1 - i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_SUB_OVF_UN_I8) {
guint64 l1 = LOCAL_VAR (ip [2], guint64);
guint64 l2 = LOCAL_VAR (ip [3], guint64);
if (CHECK_SUB_OVERFLOW64_UN (l1, l2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = l1 - l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ENDFINALLY) {
guint16 clause_index = *(ip + 1);
guint16 *ret_ip = *(guint16**)(locals + frame->imethod->clause_data_offsets [clause_index]);
if (!ret_ip) {
// this clause was called from EH, return to eh
g_assert (clause_args && clause_args->exec_frame == frame);
goto exit_clause;
}
ip = ret_ip;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CALL_HANDLER)
MINT_IN_CASE(MINT_CALL_HANDLER_S) {
gboolean short_offset = *ip == MINT_CALL_HANDLER_S;
const guint16 *ret_ip = short_offset ? (ip + 3) : (ip + 4);
guint16 clause_index = *(ret_ip - 1);
*(const guint16**)(locals + frame->imethod->clause_data_offsets [clause_index]) = ret_ip;
// jump to clause
ip += short_offset ? (gint16)*(ip + 1) : (gint32)READ32 (ip + 1);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LEAVE)
MINT_IN_CASE(MINT_LEAVE_S)
MINT_IN_CASE(MINT_LEAVE_CHECK)
MINT_IN_CASE(MINT_LEAVE_S_CHECK) {
int opcode = *ip;
gboolean const check = opcode == MINT_LEAVE_CHECK || opcode == MINT_LEAVE_S_CHECK;
if (check && frame->imethod->method->wrapper_type != MONO_WRAPPER_RUNTIME_INVOKE) {
MonoException *abort_exc = mono_interp_leave (frame);
if (abort_exc)
THROW_EX (abort_exc, ip);
}
gboolean const short_offset = opcode == MINT_LEAVE_S || opcode == MINT_LEAVE_S_CHECK;
ip += short_offset ? (gint16)*(ip + 1) : (gint32)READ32 (ip + 1);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ICALL_V_V)
MINT_IN_CASE(MINT_ICALL_P_V)
MINT_IN_CASE(MINT_ICALL_PP_V)
MINT_IN_CASE(MINT_ICALL_PPP_V)
MINT_IN_CASE(MINT_ICALL_PPPP_V)
MINT_IN_CASE(MINT_ICALL_PPPPP_V)
MINT_IN_CASE(MINT_ICALL_PPPPPP_V)
frame->state.ip = ip + 3;
do_icall_wrapper (frame, NULL, *ip, NULL, (stackval*)(locals + ip [1]), frame->imethod->data_items [ip [2]], FALSE, &gc_transitions);
EXCEPTION_CHECKPOINT;
CHECK_RESUME_STATE (context);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ICALL_V_P)
MINT_IN_CASE(MINT_ICALL_P_P)
MINT_IN_CASE(MINT_ICALL_PP_P)
MINT_IN_CASE(MINT_ICALL_PPP_P)
MINT_IN_CASE(MINT_ICALL_PPPP_P)
MINT_IN_CASE(MINT_ICALL_PPPPP_P)
MINT_IN_CASE(MINT_ICALL_PPPPPP_P)
frame->state.ip = ip + 4;
do_icall_wrapper (frame, NULL, *ip, (stackval*)(locals + ip [1]), (stackval*)(locals + ip [2]), frame->imethod->data_items [ip [3]], FALSE, &gc_transitions);
EXCEPTION_CHECKPOINT;
CHECK_RESUME_STATE (context);
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MONO_LDPTR)
LOCAL_VAR (ip [1], gpointer) = frame->imethod->data_items [ip [2]];
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MONO_NEWOBJ)
// FIXME push/pop LMF
LOCAL_VAR (ip [1], MonoObject*) = mono_interp_new ((MonoClass*)frame->imethod->data_items [ip [2]]); // FIXME: do not swallow the error
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MONO_RETOBJ)
// FIXME push/pop LMF
stackval_from_data (mono_method_signature_internal (frame->imethod->method)->ret, frame->stack, LOCAL_VAR (ip [1], gpointer),
mono_method_signature_internal (frame->imethod->method)->pinvoke && !mono_method_signature_internal (frame->imethod->method)->marshalling_disabled);
frame_data_allocator_pop (&context->data_stack, frame);
goto exit_frame;
MINT_IN_CASE(MINT_MONO_SGEN_THREAD_INFO)
LOCAL_VAR (ip [1], gpointer) = mono_tls_get_sgen_thread_info ();
ip += 2;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MONO_MEMORY_BARRIER) {
++ip;
mono_memory_barrier ();
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MONO_EXCHANGE_I8) {
gboolean flag = FALSE;
gint64 *dest = LOCAL_VAR (ip [2], gint64*);
gint64 exch = LOCAL_VAR (ip [3], gint64);
#if SIZEOF_VOID_P == 4
if (G_UNLIKELY (((size_t)dest) & 0x7)) {
gint64 result;
mono_interlocked_lock ();
result = *dest;
*dest = exch;
mono_interlocked_unlock ();
LOCAL_VAR (ip [1], gint64) = result;
flag = TRUE;
}
#endif
if (!flag)
LOCAL_VAR (ip [1], gint64) = mono_atomic_xchg_i64 (dest, exch);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MONO_LDDOMAIN)
LOCAL_VAR (ip [1], gpointer) = mono_domain_get ();
ip += 2;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MONO_ENABLE_GCTRANS)
gc_transitions = TRUE;
ip++;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SDB_INTR_LOC)
if (G_UNLIKELY (ss_enabled)) {
typedef void (*T) (void);
static T ss_tramp;
if (!ss_tramp) {
// FIXME push/pop LMF
void *tramp = mini_get_single_step_trampoline ();
mono_memory_barrier ();
ss_tramp = (T)tramp;
}
/*
* Make this point to the MINT_SDB_SEQ_POINT instruction which follows this since
* the address of that instruction is stored as the seq point address. Add also
* 1 to offset subtraction from interp_frame_get_ip.
*/
frame->state.ip = ip + 2;
/*
* Use the same trampoline as the JIT. This ensures that
* the debugger has the context for the last interpreter
* native frame.
*/
do_debugger_tramp (ss_tramp, frame);
CHECK_RESUME_STATE (context);
}
++ip;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SDB_SEQ_POINT)
/* Just a placeholder for a breakpoint */
++ip;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SDB_BREAKPOINT) {
typedef void (*T) (void);
static T bp_tramp;
if (!bp_tramp) {
// FIXME push/pop LMF
void *tramp = mini_get_breakpoint_trampoline ();
mono_memory_barrier ();
bp_tramp = (T)tramp;
}
/* Add 1 to offset subtraction from interp_frame_get_ip */
frame->state.ip = ip + 1;
/* Use the same trampoline as the JIT */
do_debugger_tramp (bp_tramp, frame);
CHECK_RESUME_STATE (context);
++ip;
MINT_IN_BREAK;
}
#define RELOP(datatype, op) \
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], datatype) op LOCAL_VAR (ip [3], datatype); \
ip += 4;
#define RELOP_FP(datatype, op, noorder) do { \
datatype a1 = LOCAL_VAR (ip [2], datatype); \
datatype a2 = LOCAL_VAR (ip [3], datatype); \
if (mono_isunordered (a1, a2)) \
LOCAL_VAR (ip [1], gint32) = noorder; \
else \
LOCAL_VAR (ip [1], gint32) = a1 op a2; \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_CEQ_I4)
RELOP(gint32, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CEQ0_I4)
LOCAL_VAR (ip [1], gint32) = (LOCAL_VAR (ip [2], gint32) == 0);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CEQ_I8)
RELOP(gint64, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CEQ_R4)
RELOP_FP(float, ==, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CEQ_R8)
RELOP_FP(double, ==, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CNE_I4)
RELOP(gint32, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CNE_I8)
RELOP(gint64, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CNE_R4)
RELOP_FP(float, !=, 1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CNE_R8)
RELOP_FP(double, !=, 1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_I4)
RELOP(gint32, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_I8)
RELOP(gint64, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_R4)
RELOP_FP(float, >, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_R8)
RELOP_FP(double, >, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGE_I4)
RELOP(gint32, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGE_I8)
RELOP(gint64, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGE_R4)
RELOP_FP(float, >=, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGE_R8)
RELOP_FP(double, >=, 0);
MINT_IN_BREAK;
#define RELOP_CAST(datatype, op) \
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], datatype) op LOCAL_VAR (ip [3], datatype); \
ip += 4;
MINT_IN_CASE(MINT_CGE_UN_I4)
RELOP_CAST(guint32, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGE_UN_I8)
RELOP_CAST(guint64, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_UN_I4)
RELOP_CAST(guint32, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_UN_I8)
RELOP_CAST(guint64, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_UN_R4)
RELOP_FP(float, >, 1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_UN_R8)
RELOP_FP(double, >, 1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_I4)
RELOP(gint32, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_I8)
RELOP(gint64, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_R4)
RELOP_FP(float, <, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_R8)
RELOP_FP(double, <, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_UN_I4)
RELOP_CAST(guint32, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_UN_I8)
RELOP_CAST(guint64, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_UN_R4)
RELOP_FP(float, <, 1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_UN_R8)
RELOP_FP(double, <, 1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLE_I4)
RELOP(gint32, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLE_I8)
RELOP(gint64, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLE_UN_I4)
RELOP_CAST(guint32, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLE_UN_I8)
RELOP_CAST(guint64, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLE_R4)
RELOP_FP(float, <=, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLE_R8)
RELOP_FP(double, <=, 0);
MINT_IN_BREAK;
#undef RELOP
#undef RELOP_FP
#undef RELOP_CAST
MINT_IN_CASE(MINT_LDFTN_ADDR) {
LOCAL_VAR (ip [1], gpointer) = frame->imethod->data_items [ip [2]];
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDFTN) {
InterpMethod *m = (InterpMethod*)frame->imethod->data_items [ip [2]];
// FIXME push/pop LMF
LOCAL_VAR (ip [1], gpointer) = imethod_to_ftnptr (m, FALSE);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDVIRTFTN) {
InterpMethod *virtual_method = (InterpMethod*)frame->imethod->data_items [ip [3]];
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
// FIXME push/pop LMF
InterpMethod *res_method = get_virtual_method (virtual_method, o->vtable);
gboolean need_unbox = m_class_is_valuetype (res_method->method->klass) && !m_class_is_valuetype (virtual_method->method->klass);
LOCAL_VAR (ip [1], gpointer) = imethod_to_ftnptr (res_method, need_unbox);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDFTN_DYNAMIC) {
error_init_reuse (error);
MonoMethod *cmethod = LOCAL_VAR (ip [2], MonoMethod*);
// FIXME push/pop LMF
if (G_UNLIKELY (mono_method_has_unmanaged_callers_only_attribute (cmethod))) {
cmethod = mono_marshal_get_managed_wrapper (cmethod, NULL, (MonoGCHandle)0, error);
mono_error_assert_ok (error);
gpointer addr = mini_get_interp_callbacks ()->create_method_pointer (cmethod, TRUE, error);
LOCAL_VAR (ip [1], gpointer) = addr;
} else {
InterpMethod *m = mono_interp_get_imethod (cmethod, error);
mono_error_assert_ok (error);
LOCAL_VAR (ip [1], gpointer) = imethod_to_ftnptr (m, FALSE);
}
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_PROF_ENTER) {
guint16 flag = ip [1];
ip += 2;
if ((flag & TRACING_FLAG) || ((flag & PROFILING_FLAG) && MONO_PROFILER_ENABLED (method_enter) &&
(frame->imethod->prof_flags & MONO_PROFILER_CALL_INSTRUMENTATION_ENTER_CONTEXT))) {
MonoProfilerCallContext *prof_ctx = g_new0 (MonoProfilerCallContext, 1);
prof_ctx->interp_frame = frame;
prof_ctx->method = frame->imethod->method;
// FIXME push/pop LMF
if (flag & TRACING_FLAG)
mono_trace_enter_method (frame->imethod->method, frame->imethod->jinfo, prof_ctx);
if (flag & PROFILING_FLAG)
MONO_PROFILER_RAISE (method_enter, (frame->imethod->method, prof_ctx));
g_free (prof_ctx);
} else if ((flag & PROFILING_FLAG) && MONO_PROFILER_ENABLED (method_enter)) {
MONO_PROFILER_RAISE (method_enter, (frame->imethod->method, NULL));
}
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_PROF_EXIT)
MINT_IN_CASE(MINT_PROF_EXIT_VOID) {
gboolean is_void = ip [0] == MINT_PROF_EXIT_VOID;
guint16 flag = is_void ? ip [1] : ip [2];
// Set retval
if (!is_void) {
int i32 = READ32 (ip + 3);
if (i32)
memmove (frame->retval, locals + ip [1], i32);
else
frame->retval [0] = LOCAL_VAR (ip [1], stackval);
}
if ((flag & TRACING_FLAG) || ((flag & PROFILING_FLAG) && MONO_PROFILER_ENABLED (method_leave) &&
(frame->imethod->prof_flags & MONO_PROFILER_CALL_INSTRUMENTATION_LEAVE_CONTEXT))) {
MonoProfilerCallContext *prof_ctx = g_new0 (MonoProfilerCallContext, 1);
prof_ctx->interp_frame = frame;
prof_ctx->method = frame->imethod->method;
if (!is_void)
prof_ctx->return_value = frame->retval;
// FIXME push/pop LMF
if (flag & TRACING_FLAG)
mono_trace_leave_method (frame->imethod->method, frame->imethod->jinfo, prof_ctx);
if (flag & PROFILING_FLAG)
MONO_PROFILER_RAISE (method_leave, (frame->imethod->method, prof_ctx));
g_free (prof_ctx);
} else if ((flag & PROFILING_FLAG) && MONO_PROFILER_ENABLED (method_enter)) {
MONO_PROFILER_RAISE (method_leave, (frame->imethod->method, NULL));
}
frame_data_allocator_pop (&context->data_stack, frame);
goto exit_frame;
}
MINT_IN_CASE(MINT_PROF_COVERAGE_STORE) {
++ip;
guint32 *p = (guint32*)GINT_TO_POINTER (READ64 (ip));
*p = 1;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDLOCA_S)
LOCAL_VAR (ip [1], gpointer) = locals + ip [2];
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_OFF)
// This opcode is resolved to a normal MINT_MOV when emitting compacted instructions
g_assert_not_reached ();
MINT_IN_BREAK;
#define MOV(argtype1,argtype2) \
LOCAL_VAR (ip [1], argtype1) = LOCAL_VAR (ip [2], argtype2); \
ip += 3;
// When loading from a local, we might need to sign / zero extend to 4 bytes
// which is our minimum "register" size in interp. They are only needed when
// the address of the local is taken and we should try to optimize them out
// because the local can't be propagated.
MINT_IN_CASE(MINT_MOV_I1) MOV(guint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_U1) MOV(guint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_I2) MOV(guint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_U2) MOV(guint32, guint16); MINT_IN_BREAK;
// Normal moves between locals
MINT_IN_CASE(MINT_MOV_4) MOV(guint32, guint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_8) MOV(guint64, guint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_VT) {
guint16 size = ip [3];
memmove (locals + ip [1], locals + ip [2], size);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MOV_8_2)
LOCAL_VAR (ip [1], guint64) = LOCAL_VAR (ip [2], guint64);
LOCAL_VAR (ip [3], guint64) = LOCAL_VAR (ip [4], guint64);
ip += 5;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_8_3)
LOCAL_VAR (ip [1], guint64) = LOCAL_VAR (ip [2], guint64);
LOCAL_VAR (ip [3], guint64) = LOCAL_VAR (ip [4], guint64);
LOCAL_VAR (ip [5], guint64) = LOCAL_VAR (ip [6], guint64);
ip += 7;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_8_4)
LOCAL_VAR (ip [1], guint64) = LOCAL_VAR (ip [2], guint64);
LOCAL_VAR (ip [3], guint64) = LOCAL_VAR (ip [4], guint64);
LOCAL_VAR (ip [5], guint64) = LOCAL_VAR (ip [6], guint64);
LOCAL_VAR (ip [7], guint64) = LOCAL_VAR (ip [8], guint64);
ip += 9;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOCALLOC) {
int len = LOCAL_VAR (ip [2], gint32);
gpointer mem = frame_data_allocator_alloc (&context->data_stack, frame, ALIGN_TO (len, MINT_VT_ALIGNMENT));
if (frame->imethod->init_locals)
memset (mem, 0, len);
LOCAL_VAR (ip [1], gpointer) = mem;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ENDFILTER)
/* top of stack is result of filter */
frame->retval->data.i = LOCAL_VAR (ip [1], gint32);
goto exit_clause;
MINT_IN_CASE(MINT_INITOBJ)
memset (LOCAL_VAR (ip [1], gpointer), 0, ip [2]);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CPBLK) {
gpointer dest = LOCAL_VAR (ip [1], gpointer);
gpointer src = LOCAL_VAR (ip [2], gpointer);
guint32 size = LOCAL_VAR (ip [3], guint32);
if (size && (!dest || !src))
THROW_EX (interp_get_exception_null_reference(frame, ip), ip);
else
memcpy (dest, src, size);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INITBLK) {
gpointer dest = LOCAL_VAR (ip [1], gpointer);
guint32 size = LOCAL_VAR (ip [3], guint32);
if (size)
NULL_CHECK (dest);
memset (dest, LOCAL_VAR (ip [2], gint32), size);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_RETHROW) {
int exvar_offset = ip [1];
THROW_EX_GENERAL (*(MonoException**)(frame_locals (frame) + exvar_offset), ip, TRUE);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MONO_RETHROW) {
/*
* need to clarify what this should actually do:
*
* Takes an exception from the stack and rethrows it.
* This is useful for wrappers that don't want to have to
* use CEE_THROW and lose the exception stacktrace.
*/
MonoException *exc = LOCAL_VAR (ip [1], MonoException*);
if (!exc)
exc = interp_get_exception_null_reference (frame, ip);
THROW_EX_GENERAL (exc, ip, TRUE);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LD_DELEGATE_METHOD_PTR) {
// FIXME push/pop LMF
MonoDelegate *del = LOCAL_VAR (ip [2], MonoDelegate*);
if (!del->interp_method) {
/* Not created from interpreted code */
error_init_reuse (error);
g_assert (del->method);
del->interp_method = mono_interp_get_imethod (del->method, error);
mono_error_assert_ok (error);
}
g_assert (del->interp_method);
LOCAL_VAR (ip [1], gpointer) = imethod_to_ftnptr (del->interp_method, FALSE);
ip += 3;
MINT_IN_BREAK;
}
#define MATH_UNOP(mathfunc) \
LOCAL_VAR (ip [1], double) = mathfunc (LOCAL_VAR (ip [2], double)); \
ip += 3;
#define MATH_BINOP(mathfunc) \
LOCAL_VAR (ip [1], double) = mathfunc (LOCAL_VAR (ip [2], double), LOCAL_VAR (ip [3], double)); \
ip += 4;
MINT_IN_CASE(MINT_ASIN) MATH_UNOP(asin); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ASINH) MATH_UNOP(asinh); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ACOS) MATH_UNOP(acos); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ACOSH) MATH_UNOP(acosh); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ATAN) MATH_UNOP(atan); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ATANH) MATH_UNOP(atanh); MINT_IN_BREAK;
MINT_IN_CASE(MINT_CEILING) MATH_UNOP(ceil); MINT_IN_BREAK;
MINT_IN_CASE(MINT_COS) MATH_UNOP(cos); MINT_IN_BREAK;
MINT_IN_CASE(MINT_CBRT) MATH_UNOP(cbrt); MINT_IN_BREAK;
MINT_IN_CASE(MINT_COSH) MATH_UNOP(cosh); MINT_IN_BREAK;
MINT_IN_CASE(MINT_EXP) MATH_UNOP(exp); MINT_IN_BREAK;
MINT_IN_CASE(MINT_FLOOR) MATH_UNOP(floor); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOG) MATH_UNOP(log); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOG2) MATH_UNOP(log2); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOG10) MATH_UNOP(log10); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SIN) MATH_UNOP(sin); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SQRT) MATH_UNOP(sqrt); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SINH) MATH_UNOP(sinh); MINT_IN_BREAK;
MINT_IN_CASE(MINT_TAN) MATH_UNOP(tan); MINT_IN_BREAK;
MINT_IN_CASE(MINT_TANH) MATH_UNOP(tanh); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ATAN2) MATH_BINOP(atan2); MINT_IN_BREAK;
MINT_IN_CASE(MINT_POW) MATH_BINOP(pow); MINT_IN_BREAK;
MINT_IN_CASE(MINT_FMA)
LOCAL_VAR (ip [1], double) = fma (LOCAL_VAR (ip [2], double), LOCAL_VAR (ip [3], double), LOCAL_VAR (ip [4], double));
ip += 5;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SCALEB)
LOCAL_VAR (ip [1], double) = scalbn (LOCAL_VAR (ip [2], double), LOCAL_VAR (ip [3], gint32));
ip += 4;
MINT_IN_BREAK;
#define MATH_UNOPF(mathfunc) \
LOCAL_VAR (ip [1], float) = mathfunc (LOCAL_VAR (ip [2], float)); \
ip += 3;
#define MATH_BINOPF(mathfunc) \
LOCAL_VAR (ip [1], float) = mathfunc (LOCAL_VAR (ip [2], float), LOCAL_VAR (ip [3], float)); \
ip += 4;
MINT_IN_CASE(MINT_ASINF) MATH_UNOPF(asinf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ASINHF) MATH_UNOPF(asinhf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ACOSF) MATH_UNOPF(acosf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ACOSHF) MATH_UNOPF(acoshf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ATANF) MATH_UNOPF(atanf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ATANHF) MATH_UNOPF(atanhf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_CEILINGF) MATH_UNOPF(ceilf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_COSF) MATH_UNOPF(cosf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_CBRTF) MATH_UNOPF(cbrtf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_COSHF) MATH_UNOPF(coshf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_EXPF) MATH_UNOPF(expf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_FLOORF) MATH_UNOPF(floorf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOGF) MATH_UNOPF(logf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOG2F) MATH_UNOPF(log2f); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOG10F) MATH_UNOPF(log10f); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SINF) MATH_UNOPF(sinf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SQRTF) MATH_UNOPF(sqrtf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SINHF) MATH_UNOPF(sinhf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_TANF) MATH_UNOPF(tanf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_TANHF) MATH_UNOPF(tanhf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ATAN2F) MATH_BINOPF(atan2f); MINT_IN_BREAK;
MINT_IN_CASE(MINT_POWF) MATH_BINOPF(powf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_FMAF)
LOCAL_VAR (ip [1], float) = fmaf (LOCAL_VAR (ip [2], float), LOCAL_VAR (ip [3], float), LOCAL_VAR (ip [4], float));
ip += 5;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SCALEBF)
LOCAL_VAR (ip [1], float) = scalbnf (LOCAL_VAR (ip [2], float), LOCAL_VAR (ip [3], gint32));
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_INTRINS_ENUM_HASFLAG) {
MonoClass *klass = (MonoClass*)frame->imethod->data_items [ip [4]];
LOCAL_VAR (ip [1], gint32) = mono_interp_enum_hasflag ((stackval*)(locals + ip [2]), (stackval*)(locals + ip [3]), klass);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_GET_HASHCODE) {
LOCAL_VAR (ip [1], gint32) = mono_object_hash_internal (LOCAL_VAR (ip [2], MonoObject*));
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_GET_TYPE) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], MonoObject*) = (MonoObject*) o->vtable->type;
ip += 3;
MINT_IN_BREAK;
}
#if !USE_COMPUTED_GOTO
default:
interp_error_xsx ("Unimplemented opcode: %04x %s at 0x%x\n", *ip, mono_interp_opname (*ip), ip - frame->imethod->code);
#endif
}
}
g_assert_not_reached ();
resume:
g_assert (context->has_resume_state);
g_assert (frame->imethod);
if (frame == context->handler_frame) {
/*
* When running finally blocks, we can have the same frame twice on the stack. If we have
* clause_args information, we need to check whether resuming should happen inside this
* finally block, or in some other part of the method, in which case we need to exit.
*/
if (clause_args && frame == clause_args->exec_frame && context->handler_ip >= clause_args->end_at_ip) {
goto exit_clause;
} else {
/* Set the current execution state to the resume state in context */
ip = context->handler_ip;
/* spec says stack should be empty at endfinally so it should be at the start too */
locals = (guchar*)frame->stack;
g_assert (context->exc_gchandle);
clear_resume_state (context);
// goto main_loop instead of MINT_IN_DISPATCH helps the compiler and therefore conserves stack.
// This is a slow/rare path and conserving stack is preferred over its performance otherwise.
goto main_loop;
}
} else if (clause_args && frame == clause_args->exec_frame) {
/*
* This frame doesn't handle the resume state and it is the first frame invoked from EH.
* We can't just return to parent. We must first exit the EH mechanism and start resuming
* again from the original frame.
*/
goto exit_clause;
}
// Because we are resuming in another frame, bypassing a normal ret opcode,
// we need to make sure to reset the localloc stack
frame_data_allocator_pop (&context->data_stack, frame);
// fall through
exit_frame:
g_assert_checked (frame->imethod);
if (frame->parent && frame->parent->state.ip) {
/* Return to the main loop after a non-recursive interpreter call */
//printf ("R: %s -> %s %p\n", mono_method_get_full_name (frame->imethod->method), mono_method_get_full_name (frame->parent->imethod->method), frame->parent->state.ip);
g_assert_checked (frame->stack);
frame = frame->parent;
/*
* FIXME We should be able to avoid dereferencing imethod here, if we will have
* a param_area and all calls would inherit the same sp, or if we are full coop.
*/
context->stack_pointer = (guchar*)frame->stack + frame->imethod->alloca_size;
LOAD_INTERP_STATE (frame);
CHECK_RESUME_STATE (context);
goto main_loop;
}
exit_clause:
if (!clause_args)
context->stack_pointer = (guchar*)frame->stack;
DEBUG_LEAVE ();
HANDLE_FUNCTION_RETURN ();
}
static void
interp_parse_options (const char *options)
{
char **args, **ptr;
if (!options)
return;
args = g_strsplit (options, ",", -1);
for (ptr = args; ptr && *ptr; ptr ++) {
char *arg = *ptr;
if (strncmp (arg, "jit=", 4) == 0)
mono_interp_jit_classes = g_slist_prepend (mono_interp_jit_classes, arg + 4);
else if (strncmp (arg, "interp-only=", strlen ("interp-only=")) == 0)
mono_interp_only_classes = g_slist_prepend (mono_interp_only_classes, arg + strlen ("interp-only="));
else if (strncmp (arg, "-inline", 7) == 0)
mono_interp_opt &= ~INTERP_OPT_INLINE;
else if (strncmp (arg, "-cprop", 6) == 0)
mono_interp_opt &= ~INTERP_OPT_CPROP;
else if (strncmp (arg, "-super", 6) == 0)
mono_interp_opt &= ~INTERP_OPT_SUPER_INSTRUCTIONS;
else if (strncmp (arg, "-bblocks", 8) == 0)
mono_interp_opt &= ~INTERP_OPT_BBLOCKS;
else if (strncmp (arg, "-all", 4) == 0)
mono_interp_opt = INTERP_OPT_NONE;
}
}
/*
* interp_set_resume_state:
*
* Set the state the interpeter will continue to execute from after execution returns to the interpreter.
* If INTERP_FRAME is NULL, that means the exception is caught in an AOTed frame and the interpreter needs to
* unwind back to AOT code.
*/
static void
interp_set_resume_state (MonoJitTlsData *jit_tls, MonoObject *ex, MonoJitExceptionInfo *ei, MonoInterpFrameHandle interp_frame, gpointer handler_ip)
{
ThreadContext *context;
g_assert (jit_tls);
context = (ThreadContext*)jit_tls->interp_context;
g_assert (context);
context->has_resume_state = TRUE;
context->handler_frame = (InterpFrame*)interp_frame;
context->handler_ei = ei;
if (context->exc_gchandle)
mono_gchandle_free_internal (context->exc_gchandle);
context->exc_gchandle = mono_gchandle_new_internal ((MonoObject*)ex, FALSE);
/* Ditto */
if (context->handler_frame) {
if (ei)
*(MonoObject**)(frame_locals (context->handler_frame) + ei->exvar_offset) = ex;
}
context->handler_ip = (const guint16*)handler_ip;
}
static void
interp_get_resume_state (const MonoJitTlsData *jit_tls, gboolean *has_resume_state, MonoInterpFrameHandle *interp_frame, gpointer *handler_ip)
{
g_assert (jit_tls);
ThreadContext *context = (ThreadContext*)jit_tls->interp_context;
*has_resume_state = context ? context->has_resume_state : FALSE;
if (!*has_resume_state)
return;
*interp_frame = context->handler_frame;
*handler_ip = (gpointer)context->handler_ip;
}
/*
* interp_run_finally:
*
* Run the finally clause identified by CLAUSE_INDEX in the intepreter frame given by
* frame->interp_frame.
* Return TRUE if the finally clause threw an exception.
*/
static gboolean
interp_run_finally (StackFrameInfo *frame, int clause_index, gpointer handler_ip, gpointer handler_ip_end)
{
InterpFrame *iframe = (InterpFrame*)frame->interp_frame;
ThreadContext *context = get_context ();
FrameClauseArgs clause_args;
const guint16 *state_ip;
memset (&clause_args, 0, sizeof (FrameClauseArgs));
clause_args.start_with_ip = (const guint16*)handler_ip;
clause_args.end_at_ip = (const guint16*)handler_ip_end;
clause_args.exec_frame = iframe;
state_ip = iframe->state.ip;
iframe->state.ip = NULL;
InterpFrame* const next_free = iframe->next_free;
iframe->next_free = NULL;
// this informs MINT_ENDFINALLY to return to EH
*(guint16**)(frame_locals (iframe) + iframe->imethod->clause_data_offsets [clause_index]) = NULL;
interp_exec_method (iframe, context, &clause_args);
iframe->next_free = next_free;
iframe->state.ip = state_ip;
check_pending_unwind (context);
if (context->has_resume_state) {
return TRUE;
} else {
return FALSE;
}
}
/*
* interp_run_filter:
*
* Run the filter clause identified by CLAUSE_INDEX in the intepreter frame given by
* frame->interp_frame.
*/
// Do not inline in case order of frame addresses matters.
static MONO_NEVER_INLINE gboolean
interp_run_filter (StackFrameInfo *frame, MonoException *ex, int clause_index, gpointer handler_ip, gpointer handler_ip_end)
{
InterpFrame *iframe = (InterpFrame*)frame->interp_frame;
ThreadContext *context = get_context ();
stackval retval;
FrameClauseArgs clause_args;
/*
* Have to run the clause in a new frame which is a copy of IFRAME, since
* during debugging, there are two copies of the frame on the stack.
*/
InterpFrame child_frame = {0};
child_frame.parent = iframe;
child_frame.imethod = iframe->imethod;
child_frame.stack = (stackval*)context->stack_pointer;
child_frame.retval = &retval;
/* Copy the stack frame of the original method */
memcpy (child_frame.stack, iframe->stack, iframe->imethod->locals_size);
// Write the exception object in its reserved stack slot
*((MonoException**)((char*)child_frame.stack + iframe->imethod->clause_data_offsets [clause_index])) = ex;
context->stack_pointer += iframe->imethod->alloca_size;
g_assert (context->stack_pointer < context->stack_end);
memset (&clause_args, 0, sizeof (FrameClauseArgs));
clause_args.start_with_ip = (const guint16*)handler_ip;
clause_args.end_at_ip = (const guint16*)handler_ip_end;
clause_args.exec_frame = &child_frame;
interp_exec_method (&child_frame, context, &clause_args);
/* Copy back the updated frame */
memcpy (iframe->stack, child_frame.stack, iframe->imethod->locals_size);
context->stack_pointer = (guchar*)child_frame.stack;
check_pending_unwind (context);
/* ENDFILTER stores the result into child_frame->retval */
return retval.data.i ? TRUE : FALSE;
}
/* Returns TRUE if there is a pending exception */
static gboolean
interp_run_clause_with_il_state (gpointer il_state_ptr, int clause_index, gpointer handler_ip, gpointer handler_ip_end,
MonoObject *ex, gboolean *filtered, MonoExceptionEnum clause_type)
{
MonoMethodILState *il_state = (MonoMethodILState*)il_state_ptr;
MonoMethodSignature *sig;
ThreadContext *context = get_context ();
stackval *orig_sp;
stackval *sp, *sp_args;
InterpMethod *imethod;
FrameClauseArgs clause_args;
ERROR_DECL (error);
sig = mono_method_signature_internal (il_state->method);
g_assert (sig);
imethod = mono_interp_get_imethod (il_state->method, error);
mono_error_assert_ok (error);
orig_sp = sp_args = sp = (stackval*)context->stack_pointer;
gpointer ret_addr = NULL;
int findex = 0;
if (sig->ret->type != MONO_TYPE_VOID) {
ret_addr = il_state->data [findex];
findex ++;
}
if (sig->hasthis) {
if (il_state->data [findex])
sp_args->data.p = *(gpointer*)il_state->data [findex];
sp_args++;
findex ++;
}
for (int i = 0; i < sig->param_count; ++i) {
if (il_state->data [findex]) {
int size = stackval_from_data (sig->params [i], sp_args, il_state->data [findex], FALSE);
sp_args = STACK_ADD_BYTES (sp_args, size);
} else {
int size = stackval_size (sig->params [i], FALSE);
sp_args = STACK_ADD_BYTES (sp_args, size);
}
findex ++;
}
/* Allocate frame */
InterpFrame frame = {0};
frame.imethod = imethod;
frame.stack = sp;
frame.retval = sp;
context->stack_pointer = (guchar*)sp_args;
context->stack_pointer += imethod->alloca_size;
g_assert (context->stack_pointer < context->stack_end);
MonoMethodHeader *header = mono_method_get_header_internal (il_state->method, error);
mono_error_assert_ok (error);
/* Init locals */
if (header->num_locals)
memset (frame_locals (&frame) + imethod->local_offsets [0], 0, imethod->locals_size);
/* Copy locals from il_state */
int locals_start = findex;
for (int i = 0; i < header->num_locals; ++i) {
if (il_state->data [locals_start + i])
stackval_from_data (header->locals [i], (stackval*)(frame_locals (&frame) + imethod->local_offsets [i]), il_state->data [locals_start + i], FALSE);
}
memset (&clause_args, 0, sizeof (FrameClauseArgs));
clause_args.start_with_ip = (const guint16*)handler_ip;
if (clause_type == MONO_EXCEPTION_CLAUSE_NONE || clause_type == MONO_EXCEPTION_CLAUSE_FILTER)
clause_args.end_at_ip = (const guint16*)clause_args.start_with_ip + 0xffffff;
else
clause_args.end_at_ip = (const guint16*)handler_ip_end;
clause_args.exec_frame = &frame;
if (clause_type == MONO_EXCEPTION_CLAUSE_NONE || clause_type == MONO_EXCEPTION_CLAUSE_FILTER)
*(MonoObject**)(frame_locals (&frame) + imethod->jinfo->clauses [clause_index].exvar_offset) = ex;
else
// this informs MINT_ENDFINALLY to return to EH
*(guint16**)(frame_locals (&frame) + imethod->clause_data_offsets [clause_index]) = NULL;
/* Set in mono_handle_exception () */
context->has_resume_state = FALSE;
interp_exec_method (&frame, context, &clause_args);
/* Write back args */
sp_args = sp;
findex = 0;
if (sig->ret->type != MONO_TYPE_VOID)
findex ++;
if (sig->hasthis) {
// FIXME: This
sp_args++;
findex ++;
}
for (int i = 0; i < sig->param_count; ++i) {
if (il_state->data [findex]) {
int size = stackval_to_data (sig->params [i], sp_args, il_state->data [findex], FALSE);
sp_args = STACK_ADD_BYTES (sp_args, size);
} else {
int size = stackval_size (sig->params [i], FALSE);
sp_args = STACK_ADD_BYTES (sp_args, size);
}
findex ++;
}
/* Write back locals */
for (int i = 0; i < header->num_locals; ++i) {
if (il_state->data [locals_start + i])
stackval_to_data (header->locals [i], (stackval*)(frame_locals (&frame) + imethod->local_offsets [i]), il_state->data [locals_start + i], FALSE);
}
mono_metadata_free_mh (header);
if (clause_type == MONO_EXCEPTION_CLAUSE_NONE && ret_addr) {
stackval_to_data (sig->ret, frame.retval, ret_addr, FALSE);
} else if (clause_type == MONO_EXCEPTION_CLAUSE_FILTER) {
g_assert (filtered);
*filtered = frame.retval->data.i;
}
memset (orig_sp, 0, (guint8*)context->stack_pointer - (guint8*)orig_sp);
context->stack_pointer = (guchar*)orig_sp;
check_pending_unwind (context);
return context->has_resume_state;
}
typedef struct {
InterpFrame *current;
} StackIter;
static gpointer
interp_frame_get_ip (MonoInterpFrameHandle frame)
{
InterpFrame *iframe = (InterpFrame*)frame;
g_assert (iframe->imethod);
/*
* For calls, state.ip points to the instruction following the call, so we need to subtract
* in order to get inside the call instruction range. Other instructions that set the IP for
* the rest of the runtime to see, like throws and sdb breakpoints, will need to account for
* this subtraction that we are doing here.
*/
return (gpointer)(iframe->state.ip - 1);
}
/*
* interp_frame_iter_init:
*
* Initialize an iterator for iterating through interpreted frames.
*/
static void
interp_frame_iter_init (MonoInterpStackIter *iter, gpointer interp_exit_data)
{
StackIter *stack_iter = (StackIter*)iter;
stack_iter->current = (InterpFrame*)interp_exit_data;
}
/*
* interp_frame_iter_next:
*
* Fill out FRAME with date for the next interpreter frame.
*/
static gboolean
interp_frame_iter_next (MonoInterpStackIter *iter, StackFrameInfo *frame)
{
StackIter *stack_iter = (StackIter*)iter;
InterpFrame *iframe = stack_iter->current;
memset (frame, 0, sizeof (StackFrameInfo));
/* pinvoke frames doesn't have imethod set */
while (iframe && !(iframe->imethod && iframe->imethod->code && iframe->imethod->jinfo))
iframe = iframe->parent;
if (!iframe)
return FALSE;
MonoMethod *method = iframe->imethod->method;
frame->interp_frame = iframe;
frame->method = method;
frame->actual_method = method;
if (method && ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) || (method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME)))) {
frame->native_offset = -1;
frame->type = FRAME_TYPE_MANAGED_TO_NATIVE;
} else {
frame->type = FRAME_TYPE_INTERP;
/* This is the offset in the interpreter IR. */
frame->native_offset = (guint8*)interp_frame_get_ip (iframe) - (guint8*)iframe->imethod->code;
if (!method->wrapper_type || method->wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD)
frame->managed = TRUE;
}
frame->ji = iframe->imethod->jinfo;
frame->frame_addr = iframe;
stack_iter->current = iframe->parent;
return TRUE;
}
static MonoJitInfo*
interp_find_jit_info (MonoMethod *method)
{
InterpMethod* imethod;
imethod = lookup_imethod (method);
if (imethod)
return imethod->jinfo;
else
return NULL;
}
static void
interp_set_breakpoint (MonoJitInfo *jinfo, gpointer ip)
{
guint16 *code = (guint16*)ip;
g_assert (*code == MINT_SDB_SEQ_POINT);
*code = MINT_SDB_BREAKPOINT;
}
static void
interp_clear_breakpoint (MonoJitInfo *jinfo, gpointer ip)
{
guint16 *code = (guint16*)ip;
g_assert (*code == MINT_SDB_BREAKPOINT);
*code = MINT_SDB_SEQ_POINT;
}
static MonoJitInfo*
interp_frame_get_jit_info (MonoInterpFrameHandle frame)
{
InterpFrame *iframe = (InterpFrame*)frame;
g_assert (iframe->imethod);
return iframe->imethod->jinfo;
}
static gpointer
interp_frame_get_arg (MonoInterpFrameHandle frame, int pos)
{
InterpFrame *iframe = (InterpFrame*)frame;
g_assert (iframe->imethod);
return (char*)iframe->stack + get_arg_offset_fast (iframe->imethod, NULL, pos + iframe->imethod->hasthis);
}
static gpointer
interp_frame_get_local (MonoInterpFrameHandle frame, int pos)
{
InterpFrame *iframe = (InterpFrame*)frame;
g_assert (iframe->imethod);
return frame_locals (iframe) + iframe->imethod->local_offsets [pos];
}
static gpointer
interp_frame_get_this (MonoInterpFrameHandle frame)
{
InterpFrame *iframe = (InterpFrame*)frame;
g_assert (iframe->imethod);
g_assert (iframe->imethod->hasthis);
return iframe->stack;
}
static MonoInterpFrameHandle
interp_frame_get_parent (MonoInterpFrameHandle frame)
{
InterpFrame *iframe = (InterpFrame*)frame;
return iframe->parent;
}
static void
interp_start_single_stepping (void)
{
ss_enabled = TRUE;
}
static void
interp_stop_single_stepping (void)
{
ss_enabled = FALSE;
}
/*
* interp_mark_stack:
*
* Mark the interpreter stack frames for a thread.
*
*/
static void
interp_mark_stack (gpointer thread_data, GcScanFunc func, gpointer gc_data, gboolean precise)
{
MonoThreadInfo *info = (MonoThreadInfo*)thread_data;
if (!mono_use_interpreter)
return;
if (precise)
return;
/*
* We explicitly mark the frames instead of registering the stack fragments as GC roots, so
* we have to process less data and avoid false pinning from data which is above 'pos'.
*
* The stack frame handling code uses compiler write barriers only, but the calling code
* in sgen-mono.c already did a mono_memory_barrier_process_wide () so we can
* process these data structures normally.
*/
MonoJitTlsData *jit_tls = (MonoJitTlsData *)info->tls [TLS_KEY_JIT_TLS];
if (!jit_tls)
return;
ThreadContext *context = (ThreadContext*)jit_tls->interp_context;
if (!context || !context->stack_start)
return;
// FIXME: Scan the whole area with 1 call
for (gpointer *p = (gpointer*)context->stack_start; p < (gpointer*)context->stack_pointer; p++)
func (p, gc_data);
FrameDataFragment *frag;
for (frag = context->data_stack.first; frag; frag = frag->next) {
// FIXME: Scan the whole area with 1 call
for (gpointer *p = (gpointer*)&frag->data; p < (gpointer*)frag->pos; ++p)
func (p, gc_data);
if (frag == context->data_stack.current)
break;
}
}
#if COUNT_OPS
static int
opcode_count_comparer (const void * pa, const void * pb)
{
long counta = opcode_counts [*(int*)pa];
long countb = opcode_counts [*(int*)pb];
if (counta < countb)
return 1;
else if (counta > countb)
return -1;
else
return 0;
}
static void
interp_print_op_count (void)
{
int ordered_ops [MINT_LASTOP];
int i;
long total_ops = 0;
for (i = 0; i < MINT_LASTOP; i++) {
ordered_ops [i] = i;
total_ops += opcode_counts [i];
}
qsort (ordered_ops, MINT_LASTOP, sizeof (int), opcode_count_comparer);
g_print ("total ops %ld\n", total_ops);
for (i = 0; i < MINT_LASTOP; i++) {
long count = opcode_counts [ordered_ops [i]];
g_print ("%s : %ld (%.2lf%%)\n", mono_interp_opname (ordered_ops [i]), count, (double)count / total_ops * 100);
}
}
#endif
#if PROFILE_INTERP
static InterpMethod **imethods;
static int num_methods;
const int opcount_threshold = 100000;
static void
interp_add_imethod (gpointer method, gpointer user_data)
{
InterpMethod *imethod = (InterpMethod*) method;
if (imethod->opcounts > opcount_threshold)
imethods [num_methods++] = imethod;
}
static int
imethod_opcount_comparer (gconstpointer m1, gconstpointer m2)
{
long diff = (*(InterpMethod**)m2)->opcounts > (*(InterpMethod**)m1)->opcounts;
if (diff > 0)
return 1;
else if (diff < 0)
return -1;
else
return 0;
}
static void
interp_print_method_counts (void)
{
MonoJitMemoryManager *jit_mm = get_default_jit_mm ();
jit_mm_lock (jit_mm);
imethods = (InterpMethod**) malloc (jit_mm->interp_code_hash.num_entries * sizeof (InterpMethod*));
mono_internal_hash_table_apply (&jit_mm->interp_code_hash, interp_add_imethod, NULL);
jit_mm_unlock (jit_mm);
qsort (imethods, num_methods, sizeof (InterpMethod*), imethod_opcount_comparer);
printf ("Total executed opcodes %ld\n", total_executed_opcodes);
long cumulative_executed_opcodes = 0;
for (int i = 0; i < num_methods; i++) {
cumulative_executed_opcodes += imethods [i]->opcounts;
printf ("%d%% Opcounts %ld, calls %ld, Method %s, imethod ptr %p\n", (int)(cumulative_executed_opcodes * 100 / total_executed_opcodes), imethods [i]->opcounts, imethods [i]->calls, mono_method_full_name (imethods [i]->method, TRUE), imethods [i]);
}
}
#endif
static void
interp_set_optimizations (guint32 opts)
{
mono_interp_opt = opts;
}
static void
invalidate_transform (gpointer imethod_, gpointer user_data)
{
InterpMethod *imethod = (InterpMethod *) imethod_;
imethod->transformed = FALSE;
}
static void
copy_imethod_for_frame (InterpFrame *frame)
{
InterpMethod *copy = (InterpMethod *) m_method_alloc0 (frame->imethod->method, sizeof (InterpMethod));
memcpy (copy, frame->imethod, sizeof (InterpMethod));
copy->next_jit_code_hash = NULL; /* we don't want that in our copy */
frame->imethod = copy;
/* Note: The copy will be around until the method is unloaded. Ideally we
* would reclaim its memory when the corresponding InterpFrame is popped.
*/
}
static void
metadata_update_backup_frames (MonoThreadInfo *info, InterpFrame *frame)
{
while (frame) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "threadinfo=%p, copy imethod for method=%s", info, mono_method_full_name (frame->imethod->method, 1));
copy_imethod_for_frame (frame);
frame = frame->parent;
}
}
static void
metadata_update_prepare_to_invalidate (void)
{
/* (1) make a copy of imethod for every interpframe that is on the stack,
* so we do not invalidate currently running methods */
FOREACH_THREAD_EXCLUDE (info, MONO_THREAD_INFO_FLAGS_NO_GC) {
if (!info || !info->jit_data)
continue;
MonoLMF *lmf = info->jit_data->lmf;
while (lmf) {
if (((gsize) lmf->previous_lmf) & 2) {
MonoLMFExt *ext = (MonoLMFExt *) lmf;
if (ext->kind == MONO_LMFEXT_INTERP_EXIT || ext->kind == MONO_LMFEXT_INTERP_EXIT_WITH_CTX) {
InterpFrame *frame = ext->interp_exit_data;
metadata_update_backup_frames (info, frame);
}
}
lmf = (MonoLMF *)(((gsize) lmf->previous_lmf) & ~3);
}
} FOREACH_THREAD_END
/* (2) invalidate all the registered imethods */
}
static void
interp_invalidate_transformed (void)
{
gboolean need_stw_restart = FALSE;
if (mono_metadata_has_updates ()) {
mono_stop_world (MONO_THREAD_INFO_FLAGS_NO_GC);
metadata_update_prepare_to_invalidate ();
need_stw_restart = TRUE;
}
// FIXME: Enumerate all memory managers
MonoJitMemoryManager *jit_mm = get_default_jit_mm ();
jit_mm_lock (jit_mm);
mono_internal_hash_table_apply (&jit_mm->interp_code_hash, invalidate_transform, NULL);
jit_mm_unlock (jit_mm);
if (need_stw_restart)
mono_restart_world (MONO_THREAD_INFO_FLAGS_NO_GC);
}
typedef struct {
MonoJitInfo **jit_info_array;
gint size;
gint next;
} InterpCopyJitInfoFuncUserData;
static void
interp_copy_jit_info_func (gpointer imethod, gpointer user_data)
{
InterpCopyJitInfoFuncUserData *data = (InterpCopyJitInfoFuncUserData*)user_data;
if (data->next < data->size)
data->jit_info_array [data->next++] = ((InterpMethod *)imethod)->jinfo;
}
static void
interp_jit_info_foreach (InterpJitInfoFunc func, gpointer user_data)
{
InterpCopyJitInfoFuncUserData copy_jit_info_data;
// FIXME: Enumerate all memory managers
MonoJitMemoryManager *jit_mm = get_default_jit_mm ();
// Can't keep memory manager lock while iterating and calling callback since it might take other locks
// causing poential deadlock situations. Instead, create copy of interpreter imethod jinfo pointers into
// plain array and use pointers from array when when running callbacks.
copy_jit_info_data.size = mono_atomic_load_i32 (&(jit_mm->interp_code_hash.num_entries));
copy_jit_info_data.next = 0;
copy_jit_info_data.jit_info_array = (MonoJitInfo**) g_new (MonoJitInfo*, copy_jit_info_data.size);
if (copy_jit_info_data.jit_info_array) {
jit_mm_lock (jit_mm);
mono_internal_hash_table_apply (&jit_mm->interp_code_hash, interp_copy_jit_info_func, ©_jit_info_data);
jit_mm_unlock (jit_mm);
}
if (copy_jit_info_data.jit_info_array) {
for (size_t i = 0; i < copy_jit_info_data.next; ++i)
func (copy_jit_info_data.jit_info_array [i], user_data);
g_free (copy_jit_info_data.jit_info_array);
}
}
static gboolean
interp_sufficient_stack (gsize size)
{
ThreadContext *context = get_context ();
return (context->stack_pointer + size) < (context->stack_start + INTERP_STACK_SIZE);
}
static void
interp_cleanup (void)
{
#if COUNT_OPS
interp_print_op_count ();
#endif
#if PROFILE_INTERP
interp_print_method_counts ();
#endif
}
static void
register_interp_stats (void)
{
mono_counters_init ();
mono_counters_register ("Total transform time", MONO_COUNTER_INTERP | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &mono_interp_stats.transform_time);
mono_counters_register ("Methods transformed", MONO_COUNTER_INTERP | MONO_COUNTER_LONG, &mono_interp_stats.methods_transformed);
mono_counters_register ("Total cprop time", MONO_COUNTER_INTERP | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &mono_interp_stats.cprop_time);
mono_counters_register ("Total super instructions time", MONO_COUNTER_INTERP | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &mono_interp_stats.super_instructions_time);
mono_counters_register ("STLOC_NP count", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.stloc_nps);
mono_counters_register ("MOVLOC count", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.movlocs);
mono_counters_register ("Copy propagations", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.copy_propagations);
mono_counters_register ("Added pop count", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.added_pop_count);
mono_counters_register ("Constant folds", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.constant_folds);
mono_counters_register ("Ldlocas removed", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.ldlocas_removed);
mono_counters_register ("Super instructions", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.super_instructions);
mono_counters_register ("Killed instructions", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.killed_instructions);
mono_counters_register ("Emitted instructions", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.emitted_instructions);
mono_counters_register ("Methods inlined", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.inlined_methods);
mono_counters_register ("Inline failures", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.inline_failures);
}
#undef MONO_EE_CALLBACK
#define MONO_EE_CALLBACK(ret, name, sig) interp_ ## name,
static const MonoEECallbacks mono_interp_callbacks = {
MONO_EE_CALLBACKS
};
void
mono_ee_interp_init (const char *opts)
{
g_assert (mono_ee_api_version () == MONO_EE_API_VERSION);
g_assert (!interp_init_done);
interp_init_done = TRUE;
mono_native_tls_alloc (&thread_context_id, NULL);
set_context (NULL);
interp_parse_options (opts);
/* Don't do any optimizations if running under debugger */
if (mini_get_debug_options ()->mdb_optimizations)
mono_interp_opt = 0;
mono_interp_transform_init ();
mini_install_interp_callbacks (&mono_interp_callbacks);
register_interp_stats ();
}
| /**
* \file
*
* interp.c: Interpreter for CIL byte codes
*
* Authors:
* Paolo Molaro ([email protected])
* Miguel de Icaza ([email protected])
* Dietmar Maurer ([email protected])
*
* (C) 2001, 2002 Ximian, Inc.
*/
#ifndef __USE_ISOC99
#define __USE_ISOC99
#endif
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <glib.h>
#include <math.h>
#include <locale.h>
#include <mono/utils/gc_wrapper.h>
#include <mono/utils/mono-math.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-tls-inline.h>
#include <mono/utils/mono-threads.h>
#include <mono/utils/mono-membar.h>
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#else
# ifdef __CYGWIN__
# define alloca __builtin_alloca
# endif
#endif
/* trim excessive headers */
#include <mono/metadata/image.h>
#include <mono/metadata/assembly-internals.h>
#include <mono/metadata/cil-coff.h>
#include <mono/metadata/mono-endian.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/tokentype.h>
#include <mono/metadata/loader.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/reflection.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/verify.h>
#include <mono/metadata/opcodes.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/marshal.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/gc-internals.h>
#include <mono/utils/atomic.h>
#include "interp.h"
#include "interp-internals.h"
#include "mintops.h"
#include "interp-intrins.h"
#include <mono/mini/mini.h>
#include <mono/mini/mini-runtime.h>
#include <mono/mini/aot-runtime.h>
#include <mono/mini/llvm-runtime.h>
#include <mono/mini/llvmonly-runtime.h>
#include <mono/mini/jit-icalls.h>
#include <mono/mini/ee.h>
#include <mono/mini/trace.h>
#include <mono/metadata/components.h>
#ifdef TARGET_ARM
#include <mono/mini/mini-arm.h>
#endif
#include <mono/metadata/icall-decl.h>
/* Arguments that are passed when invoking only a finally/filter clause from the frame */
struct FrameClauseArgs {
/* Where we start the frame execution from */
const guint16 *start_with_ip;
/*
* End ip of the exit_clause. We need it so we know whether the resume
* state is for this frame (which is called from EH) or for the original
* frame further down the stack.
*/
const guint16 *end_at_ip;
/* Frame that is executing this clause */
InterpFrame *exec_frame;
};
/*
* This code synchronizes with interp_mark_stack () using compiler memory barriers.
*/
static FrameDataFragment*
frame_data_frag_new (int size)
{
FrameDataFragment *frag = (FrameDataFragment*)g_malloc (size);
frag->pos = (guint8*)&frag->data;
frag->end = (guint8*)frag + size;
frag->next = NULL;
return frag;
}
static void
frame_data_frag_free (FrameDataFragment *frag)
{
while (frag) {
FrameDataFragment *next = frag->next;
g_free (frag);
frag = next;
}
}
static void
frame_data_allocator_init (FrameDataAllocator *stack, int size)
{
FrameDataFragment *frag;
frag = frame_data_frag_new (size);
stack->first = stack->current = frag;
stack->infos_capacity = 4;
stack->infos = (FrameDataInfo*)g_malloc (stack->infos_capacity * sizeof (FrameDataInfo));
}
static void
frame_data_allocator_free (FrameDataAllocator *stack)
{
/* Assert to catch leaks */
g_assert_checked (stack->current == stack->first && stack->current->pos == (guint8*)&stack->current->data);
frame_data_frag_free (stack->first);
}
static FrameDataFragment*
frame_data_allocator_add_frag (FrameDataAllocator *stack, int size)
{
FrameDataFragment *new_frag;
// FIXME:
int frag_size = 4096;
if (size + sizeof (FrameDataFragment) > frag_size)
frag_size = size + sizeof (FrameDataFragment);
new_frag = frame_data_frag_new (frag_size);
mono_compiler_barrier ();
stack->current->next = new_frag;
stack->current = new_frag;
return new_frag;
}
static gpointer
frame_data_allocator_alloc (FrameDataAllocator *stack, InterpFrame *frame, int size)
{
FrameDataFragment *current = stack->current;
gpointer res;
int infos_len = stack->infos_len;
if (!infos_len || (infos_len > 0 && stack->infos [infos_len - 1].frame != frame)) {
/* First allocation by this frame. Save the markers for restore */
if (infos_len == stack->infos_capacity) {
stack->infos_capacity = infos_len * 2;
stack->infos = (FrameDataInfo*)g_realloc (stack->infos, stack->infos_capacity * sizeof (FrameDataInfo));
}
stack->infos [infos_len].frame = frame;
stack->infos [infos_len].frag = current;
stack->infos [infos_len].pos = current->pos;
stack->infos_len++;
}
if (G_LIKELY (current->pos + size <= current->end)) {
res = current->pos;
current->pos += size;
} else {
if (current->next && current->next->pos + size <= current->next->end) {
current = stack->current = current->next;
current->pos = (guint8*)¤t->data;
} else {
FrameDataFragment *tmp = current->next;
/* avoid linking to be freed fragments, so the GC can't trip over it */
current->next = NULL;
mono_compiler_barrier ();
frame_data_frag_free (tmp);
current = frame_data_allocator_add_frag (stack, size);
}
g_assert (current->pos + size <= current->end);
res = (gpointer)current->pos;
current->pos += size;
}
mono_compiler_barrier ();
return res;
}
static void
frame_data_allocator_pop (FrameDataAllocator *stack, InterpFrame *frame)
{
int infos_len = stack->infos_len;
if (infos_len > 0 && stack->infos [infos_len - 1].frame == frame) {
infos_len--;
stack->current = stack->infos [infos_len].frag;
stack->current->pos = stack->infos [infos_len].pos;
stack->infos_len = infos_len;
}
}
/*
* reinit_frame:
*
* Reinitialize a frame.
*/
static void
reinit_frame (InterpFrame *frame, InterpFrame *parent, InterpMethod *imethod, gpointer retval, gpointer stack)
{
frame->parent = parent;
frame->imethod = imethod;
frame->stack = (stackval*)stack;
frame->retval = (stackval*)retval;
frame->state.ip = NULL;
}
#define STACK_ADD_BYTES(sp,bytes) ((stackval*)((char*)(sp) + ALIGN_TO(bytes, MINT_STACK_SLOT_SIZE)))
#define STACK_SUB_BYTES(sp,bytes) ((stackval*)((char*)(sp) - ALIGN_TO(bytes, MINT_STACK_SLOT_SIZE)))
/*
* List of classes whose methods will be executed by transitioning to JITted code.
* Used for testing.
*/
GSList *mono_interp_jit_classes;
/* Optimizations enabled with interpreter */
int mono_interp_opt = INTERP_OPT_DEFAULT;
/* If TRUE, interpreted code will be interrupted at function entry/backward branches */
static gboolean ss_enabled;
static gboolean interp_init_done = FALSE;
static void
interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs *clause_args);
static MonoException* do_transform_method (InterpMethod *imethod, InterpFrame *method, ThreadContext *context);
static InterpMethod* lookup_method_pointer (gpointer addr);
typedef void (*ICallMethod) (InterpFrame *frame);
static MonoNativeTlsKey thread_context_id;
#define DEBUG_INTERP 0
#define COUNT_OPS 0
#if DEBUG_INTERP
int mono_interp_traceopt = 2;
/* If true, then we output the opcodes as we interpret them */
static int global_tracing = 2;
static int debug_indent_level = 0;
static int break_on_method = 0;
static int nested_trace = 0;
static GList *db_methods = NULL;
static char* dump_args (InterpFrame *inv);
static void
output_indent (void)
{
int h;
for (h = 0; h < debug_indent_level; h++)
g_print (" ");
}
static void
db_match_method (gpointer data, gpointer user_data)
{
MonoMethod *m = (MonoMethod*)user_data;
MonoMethodDesc *desc = (MonoMethodDesc*)data;
if (mono_method_desc_full_match (desc, m))
break_on_method = 1;
}
static void
debug_enter (InterpFrame *frame, int *tracing)
{
if (db_methods) {
g_list_foreach (db_methods, db_match_method, (gpointer)frame->imethod->method);
if (break_on_method)
*tracing = nested_trace ? (global_tracing = 2, 3) : 2;
break_on_method = 0;
}
if (*tracing) {
MonoMethod *method = frame->imethod->method;
char *mn, *args = dump_args (frame);
debug_indent_level++;
output_indent ();
mn = mono_method_full_name (method, FALSE);
g_print ("(%p) Entering %s (", mono_thread_internal_current (), mn);
g_free (mn);
g_print ("%s)\n", args);
g_free (args);
}
}
#define DEBUG_LEAVE() \
if (tracing) { \
char *mn, *args; \
args = dump_retval (frame); \
output_indent (); \
mn = mono_method_full_name (frame->imethod->method, FALSE); \
g_print ("(%p) Leaving %s", mono_thread_internal_current (), mn); \
g_free (mn); \
g_print (" => %s\n", args); \
g_free (args); \
debug_indent_level--; \
if (tracing == 3) global_tracing = 0; \
}
#else
int mono_interp_traceopt = 0;
#define DEBUG_LEAVE()
#endif
#if defined(__GNUC__) && !defined(TARGET_WASM) && !COUNT_OPS && !DEBUG_INTERP && !ENABLE_CHECKED_BUILD && !PROFILE_INTERP
#define USE_COMPUTED_GOTO 1
#endif
#if USE_COMPUTED_GOTO
#define MINT_IN_DISPATCH(op) goto *in_labels [opcode = (MintOpcode)(op)]
#define MINT_IN_SWITCH(op) MINT_IN_DISPATCH (op);
#define MINT_IN_BREAK MINT_IN_DISPATCH (*ip)
#define MINT_IN_CASE(x) LAB_ ## x:
#else
#define MINT_IN_SWITCH(op) COUNT_OP(op); switch (opcode = (MintOpcode)(op))
#define MINT_IN_CASE(x) case x:
#define MINT_IN_BREAK break
#endif
static void
clear_resume_state (ThreadContext *context)
{
context->has_resume_state = 0;
context->handler_frame = NULL;
context->handler_ei = NULL;
g_assert (context->exc_gchandle);
mono_gchandle_free_internal (context->exc_gchandle);
context->exc_gchandle = 0;
}
/*
* If this bit is set, it means the call has thrown the exception, and we
* reached this point because the EH code in mono_handle_exception ()
* unwound all the JITted frames below us. mono_interp_set_resume_state ()
* has set the fields in context to indicate where we have to resume execution.
*/
#define CHECK_RESUME_STATE(context) do { \
if ((context)->has_resume_state) \
goto resume; \
} while (0)
static void
set_context (ThreadContext *context)
{
mono_native_tls_set_value (thread_context_id, context);
if (!context)
return;
MonoJitTlsData *jit_tls = mono_tls_get_jit_tls ();
g_assertf (jit_tls, "ThreadContext needs initialized JIT TLS");
/* jit_tls assumes ownership of 'context' */
jit_tls->interp_context = context;
}
static ThreadContext *
get_context (void)
{
ThreadContext *context = (ThreadContext *) mono_native_tls_get_value (thread_context_id);
if (context == NULL) {
context = g_new0 (ThreadContext, 1);
context->stack_start = (guchar*)mono_valloc (0, INTERP_STACK_SIZE, MONO_MMAP_READ | MONO_MMAP_WRITE, MONO_MEM_ACCOUNT_INTERP_STACK);
context->stack_end = context->stack_start + INTERP_STACK_SIZE - INTERP_REDZONE_SIZE;
context->stack_real_end = context->stack_start + INTERP_STACK_SIZE;
context->stack_pointer = context->stack_start;
frame_data_allocator_init (&context->data_stack, 8192);
/* Make sure all data is initialized before publishing the context */
mono_compiler_barrier ();
set_context (context);
}
return context;
}
static void
interp_free_context (gpointer ctx)
{
ThreadContext *context = (ThreadContext*)ctx;
ThreadContext *current_context = (ThreadContext *) mono_native_tls_get_value (thread_context_id);
/* at thread exit, we can be called from the JIT TLS key destructor with current_context == NULL */
if (current_context != NULL) {
/* check that the context we're freeing is the current one before overwriting TLS */
g_assert (context == current_context);
set_context (NULL);
}
mono_vfree (context->stack_start, INTERP_STACK_SIZE, MONO_MEM_ACCOUNT_INTERP_STACK);
/* Prevent interp_mark_stack from trying to scan the data_stack, before freeing it */
context->stack_start = NULL;
mono_compiler_barrier ();
frame_data_allocator_free (&context->data_stack);
g_free (context);
}
/* Continue unwinding if there is an exception that needs to be handled in an AOTed frame above us */
static void
check_pending_unwind (ThreadContext *context)
{
if (context->has_resume_state && !context->handler_frame)
mono_llvm_cpp_throw_exception ();
}
void
mono_interp_error_cleanup (MonoError* error)
{
mono_error_cleanup (error); /* FIXME: don't swallow the error */
error_init_reuse (error); // one instruction, so this function is good inline candidate
}
static InterpMethod*
lookup_imethod (MonoMethod *method)
{
InterpMethod *imethod;
MonoJitMemoryManager *jit_mm = jit_mm_for_method (method);
jit_mm_lock (jit_mm);
imethod = (InterpMethod*)mono_internal_hash_table_lookup (&jit_mm->interp_code_hash, method);
jit_mm_unlock (jit_mm);
return imethod;
}
InterpMethod*
mono_interp_get_imethod (MonoMethod *method, MonoError *error)
{
InterpMethod *imethod;
MonoMethodSignature *sig;
MonoJitMemoryManager *jit_mm = jit_mm_for_method (method);
int i;
error_init (error);
jit_mm_lock (jit_mm);
imethod = (InterpMethod*)mono_internal_hash_table_lookup (&jit_mm->interp_code_hash, method);
jit_mm_unlock (jit_mm);
if (imethod)
return imethod;
sig = mono_method_signature_internal (method);
imethod = (InterpMethod*)m_method_alloc0 (method, sizeof (InterpMethod));
imethod->method = method;
imethod->param_count = sig->param_count;
imethod->hasthis = sig->hasthis;
imethod->vararg = sig->call_convention == MONO_CALL_VARARG;
imethod->code_type = IMETHOD_CODE_UNKNOWN;
if (imethod->method->string_ctor)
imethod->rtype = m_class_get_byval_arg (mono_defaults.string_class);
else
imethod->rtype = mini_get_underlying_type (sig->ret);
imethod->param_types = (MonoType**)m_method_alloc0 (method, sizeof (MonoType*) * sig->param_count);
for (i = 0; i < sig->param_count; ++i)
imethod->param_types [i] = mini_get_underlying_type (sig->params [i]);
jit_mm_lock (jit_mm);
InterpMethod *old_imethod;
if (!((old_imethod = mono_internal_hash_table_lookup (&jit_mm->interp_code_hash, method))))
mono_internal_hash_table_insert (&jit_mm->interp_code_hash, method, imethod);
else {
imethod = old_imethod; /* leak the newly allocated InterpMethod to the mempool */
}
jit_mm_unlock (jit_mm);
imethod->prof_flags = mono_profiler_get_call_instrumentation_flags (imethod->method);
return imethod;
}
#if defined (MONO_CROSS_COMPILE) || defined (HOST_WASM)
#define INTERP_PUSH_LMF_WITH_CTX_BODY(ext, exit_label) \
(ext).kind = MONO_LMFEXT_INTERP_EXIT;
#elif defined(MONO_ARCH_HAS_NO_PROPER_MONOCTX)
/* some platforms, e.g. appleTV, don't provide us a precise MonoContext
* (registers are not accurate), thus resuming to the label does not work. */
#define INTERP_PUSH_LMF_WITH_CTX_BODY(ext, exit_label) \
(ext).kind = MONO_LMFEXT_INTERP_EXIT;
#elif defined (_MSC_VER)
#define INTERP_PUSH_LMF_WITH_CTX_BODY(ext, exit_label) \
(ext).kind = MONO_LMFEXT_INTERP_EXIT_WITH_CTX; \
(ext).interp_exit_label_set = FALSE; \
MONO_CONTEXT_GET_CURRENT ((ext).ctx); \
if ((ext).interp_exit_label_set == FALSE) \
mono_arch_do_ip_adjustment (&(ext).ctx); \
if ((ext).interp_exit_label_set == TRUE) \
goto exit_label; \
(ext).interp_exit_label_set = TRUE;
#elif defined(MONO_ARCH_HAS_MONO_CONTEXT)
#define INTERP_PUSH_LMF_WITH_CTX_BODY(ext, exit_label) \
(ext).kind = MONO_LMFEXT_INTERP_EXIT_WITH_CTX; \
MONO_CONTEXT_GET_CURRENT ((ext).ctx); \
MONO_CONTEXT_SET_IP (&(ext).ctx, (&&exit_label)); \
mono_arch_do_ip_adjustment (&(ext).ctx);
#else
#define INTERP_PUSH_LMF_WITH_CTX_BODY(ext, exit_label) g_error ("requires working mono-context");
#endif
/* INTERP_PUSH_LMF_WITH_CTX:
*
* same as interp_push_lmf, but retrieving and attaching MonoContext to it.
* This is needed to resume into the interp when the exception is thrown from
* native code (see ./mono/tests/install_eh_callback.exe).
*
* This must be a macro in order to retrieve the right register values for
* MonoContext.
*/
#define INTERP_PUSH_LMF_WITH_CTX(frame, ext, exit_label) \
memset (&(ext), 0, sizeof (MonoLMFExt)); \
(ext).interp_exit_data = (frame); \
INTERP_PUSH_LMF_WITH_CTX_BODY ((ext), exit_label); \
mono_push_lmf (&(ext));
/*
* interp_push_lmf:
*
* Push an LMF frame on the LMF stack
* to mark the transition to native code.
* This is needed for the native code to
* be able to do stack walks.
*/
static void
interp_push_lmf (MonoLMFExt *ext, InterpFrame *frame)
{
memset (ext, 0, sizeof (MonoLMFExt));
ext->kind = MONO_LMFEXT_INTERP_EXIT;
ext->interp_exit_data = frame;
mono_push_lmf (ext);
}
static void
interp_pop_lmf (MonoLMFExt *ext)
{
mono_pop_lmf (&ext->lmf);
}
static InterpMethod*
get_virtual_method (InterpMethod *imethod, MonoVTable *vtable)
{
MonoMethod *m = imethod->method;
InterpMethod *ret = NULL;
if ((m->flags & METHOD_ATTRIBUTE_FINAL) || !(m->flags & METHOD_ATTRIBUTE_VIRTUAL)) {
if (m->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) {
ERROR_DECL (error);
ret = mono_interp_get_imethod (mono_marshal_get_synchronized_wrapper (m), error);
mono_interp_error_cleanup (error); /* FIXME: don't swallow the error */
} else {
ret = imethod;
}
return ret;
}
mono_class_setup_vtable (vtable->klass);
int slot = mono_method_get_vtable_slot (m);
if (mono_class_is_interface (m->klass)) {
g_assert (vtable->klass != m->klass);
/* TODO: interface offset lookup is slow, go through IMT instead */
gboolean non_exact_match;
slot += mono_class_interface_offset_with_variance (vtable->klass, m->klass, &non_exact_match);
}
MonoMethod *virtual_method = m_class_get_vtable (vtable->klass) [slot];
if (m->is_inflated && mono_method_get_context (m)->method_inst) {
MonoGenericContext context = { NULL, NULL };
if (mono_class_is_ginst (virtual_method->klass))
context.class_inst = mono_class_get_generic_class (virtual_method->klass)->context.class_inst;
else if (mono_class_is_gtd (virtual_method->klass))
context.class_inst = mono_class_get_generic_container (virtual_method->klass)->context.class_inst;
context.method_inst = mono_method_get_context (m)->method_inst;
ERROR_DECL (error);
virtual_method = mono_class_inflate_generic_method_checked (virtual_method, &context, error);
mono_error_cleanup (error); /* FIXME: don't swallow the error */
}
if (virtual_method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) {
virtual_method = mono_marshal_get_native_wrapper (virtual_method, FALSE, FALSE);
}
if (virtual_method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) {
virtual_method = mono_marshal_get_synchronized_wrapper (virtual_method);
}
ERROR_DECL (error);
InterpMethod *virtual_imethod = mono_interp_get_imethod (virtual_method, error);
mono_error_cleanup (error); /* FIXME: don't swallow the error */
return virtual_imethod;
}
typedef struct {
InterpMethod *imethod;
InterpMethod *target_imethod;
} InterpVTableEntry;
/* memory manager lock must be held */
static GSList*
append_imethod (MonoMemoryManager *memory_manager, GSList *list, InterpMethod *imethod, InterpMethod *target_imethod)
{
GSList *ret;
InterpVTableEntry *entry;
entry = (InterpVTableEntry*) mono_mem_manager_alloc0 (memory_manager, sizeof (InterpVTableEntry));
entry->imethod = imethod;
entry->target_imethod = target_imethod;
ret = mono_mem_manager_alloc0 (memory_manager, sizeof (GSList));
ret->data = entry;
ret = g_slist_concat (list, ret);
return ret;
}
static InterpMethod*
get_target_imethod (GSList *list, InterpMethod *imethod)
{
while (list != NULL) {
InterpVTableEntry *entry = (InterpVTableEntry*) list->data;
if (entry->imethod == imethod)
return entry->target_imethod;
list = list->next;
}
return NULL;
}
static inline MonoVTableEEData*
get_vtable_ee_data (MonoVTable *vtable)
{
MonoVTableEEData *ee_data = (MonoVTableEEData*)vtable->ee_data;
if (G_UNLIKELY (!ee_data)) {
ee_data = m_class_alloc0 (vtable->klass, sizeof (MonoVTableEEData));
mono_memory_barrier ();
vtable->ee_data = ee_data;
}
return ee_data;
}
static gpointer*
get_method_table (MonoVTable *vtable, int offset)
{
if (offset >= 0)
return get_vtable_ee_data (vtable)->interp_vtable;
else
return (gpointer*)vtable;
}
static gpointer*
alloc_method_table (MonoVTable *vtable, int offset)
{
gpointer *table;
if (offset >= 0) {
table = (gpointer*)m_class_alloc0 (vtable->klass, m_class_get_vtable_size (vtable->klass) * sizeof (gpointer));
get_vtable_ee_data (vtable)->interp_vtable = table;
} else {
table = (gpointer*)vtable;
}
return table;
}
static InterpMethod* // Inlining causes additional stack use in caller.
get_virtual_method_fast (InterpMethod *imethod, MonoVTable *vtable, int offset)
{
gpointer *table;
MonoMemoryManager *memory_manager = NULL;
table = get_method_table (vtable, offset);
if (G_UNLIKELY (!table)) {
memory_manager = m_class_get_mem_manager (vtable->klass);
/* Lazily allocate method table */
mono_mem_manager_lock (memory_manager);
table = get_method_table (vtable, offset);
if (!table)
table = alloc_method_table (vtable, offset);
mono_mem_manager_unlock (memory_manager);
}
if (G_UNLIKELY (!table [offset])) {
InterpMethod *target_imethod = get_virtual_method (imethod, vtable);
if (!memory_manager)
memory_manager = m_class_get_mem_manager (vtable->klass);
/* Lazily initialize the method table slot */
mono_mem_manager_lock (memory_manager);
if (!table [offset]) {
if (imethod->method->is_inflated || offset < 0)
table [offset] = append_imethod (memory_manager, NULL, imethod, target_imethod);
else
table [offset] = (gpointer) ((gsize)target_imethod | 0x1);
}
mono_mem_manager_unlock (memory_manager);
}
if ((gsize)table [offset] & 0x1) {
/* Non generic virtual call. Only one method in slot */
return (InterpMethod*) ((gsize)table [offset] & ~0x1);
} else {
/* Virtual generic or interface call. Multiple methods in slot */
InterpMethod *target_imethod = get_target_imethod ((GSList*)table [offset], imethod);
if (G_UNLIKELY (!target_imethod)) {
target_imethod = get_virtual_method (imethod, vtable);
if (!memory_manager)
memory_manager = m_class_get_mem_manager (vtable->klass);
mono_mem_manager_lock (memory_manager);
if (!get_target_imethod ((GSList*)table [offset], imethod))
table [offset] = append_imethod (memory_manager, (GSList*)table [offset], imethod, target_imethod);
mono_mem_manager_unlock (memory_manager);
}
return target_imethod;
}
}
// Returns the size it uses on the interpreter stack
static int
stackval_size (MonoType *type, gboolean pinvoke)
{
if (m_type_is_byref (type))
return MINT_STACK_SLOT_SIZE;
switch (type->type) {
case MONO_TYPE_VOID:
return 0;
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_CHAR:
case MONO_TYPE_I4:
case MONO_TYPE_U:
case MONO_TYPE_I:
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
case MONO_TYPE_U4:
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_R4:
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_I8:
case MONO_TYPE_U8:
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_R8:
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_STRING:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_ARRAY:
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_VALUETYPE:
if (m_class_is_enumtype (type->data.klass)) {
return stackval_size (mono_class_enum_basetype_internal (type->data.klass), pinvoke);
} else {
int size;
if (pinvoke)
size = mono_class_native_size (type->data.klass, NULL);
else
size = mono_class_value_size (type->data.klass, NULL);
return ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
case MONO_TYPE_GENERICINST: {
if (mono_type_generic_inst_is_valuetype (type)) {
MonoClass *klass = mono_class_from_mono_type_internal (type);
int size;
if (pinvoke)
size = mono_class_native_size (klass, NULL);
else
size = mono_class_value_size (klass, NULL);
return ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
return stackval_size (m_class_get_byval_arg (type->data.generic_class->container_class), pinvoke);
}
default:
g_error ("got type 0x%02x", type->type);
}
}
// Returns the size it uses on the interpreter stack
static int
stackval_from_data (MonoType *type, stackval *result, const void *data, gboolean pinvoke)
{
if (m_type_is_byref (type)) {
result->data.p = *(gpointer*)data;
return MINT_STACK_SLOT_SIZE;
}
switch (type->type) {
case MONO_TYPE_VOID:
return 0;
case MONO_TYPE_I1:
result->data.i = *(gint8*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_U1:
case MONO_TYPE_BOOLEAN:
result->data.i = *(guint8*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_I2:
result->data.i = *(gint16*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_U2:
case MONO_TYPE_CHAR:
result->data.i = *(guint16*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_I4:
result->data.i = *(gint32*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_U:
case MONO_TYPE_I:
result->data.nati = *(mono_i*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
result->data.p = *(gpointer*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_U4:
result->data.i = *(guint32*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_R4:
/* memmove handles unaligned case */
memmove (&result->data.f_r4, data, sizeof (float));
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_I8:
case MONO_TYPE_U8:
memmove (&result->data.l, data, sizeof (gint64));
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_R8:
memmove (&result->data.f, data, sizeof (double));
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_STRING:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_ARRAY:
result->data.p = *(gpointer*)data;
return MINT_STACK_SLOT_SIZE;
case MONO_TYPE_VALUETYPE:
if (m_class_is_enumtype (type->data.klass)) {
return stackval_from_data (mono_class_enum_basetype_internal (type->data.klass), result, data, pinvoke);
} else {
int size;
if (pinvoke)
size = mono_class_native_size (type->data.klass, NULL);
else
size = mono_class_value_size (type->data.klass, NULL);
memcpy (result, data, size);
return ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
case MONO_TYPE_GENERICINST: {
if (mono_type_generic_inst_is_valuetype (type)) {
MonoClass *klass = mono_class_from_mono_type_internal (type);
int size;
if (pinvoke)
size = mono_class_native_size (klass, NULL);
else
size = mono_class_value_size (klass, NULL);
memcpy (result, data, size);
return ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
return stackval_from_data (m_class_get_byval_arg (type->data.generic_class->container_class), result, data, pinvoke);
}
default:
g_error ("got type 0x%02x", type->type);
}
}
static int
stackval_to_data (MonoType *type, stackval *val, void *data, gboolean pinvoke)
{
if (m_type_is_byref (type)) {
gpointer *p = (gpointer*)data;
*p = val->data.p;
return MINT_STACK_SLOT_SIZE;
}
/* printf ("TODAT0 %p\n", data); */
switch (type->type) {
case MONO_TYPE_I1:
case MONO_TYPE_U1: {
guint8 *p = (guint8*)data;
*p = val->data.i;
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_BOOLEAN: {
guint8 *p = (guint8*)data;
*p = (val->data.i != 0);
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_CHAR: {
guint16 *p = (guint16*)data;
*p = val->data.i;
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_I: {
mono_i *p = (mono_i*)data;
/* In theory the value used by stloc should match the local var type
but in practice it sometimes doesn't (a int32 gets dup'd and stloc'd into
a native int - both by csc and mcs). Not sure what to do about sign extension
as it is outside the spec... doing the obvious */
*p = (mono_i)val->data.nati;
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_U: {
mono_u *p = (mono_u*)data;
/* see above. */
*p = (mono_u)val->data.nati;
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_I4:
case MONO_TYPE_U4: {
gint32 *p = (gint32*)data;
*p = val->data.i;
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_I8:
case MONO_TYPE_U8: {
memmove (data, &val->data.l, sizeof (gint64));
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_R4: {
/* memmove handles unaligned case */
memmove (data, &val->data.f_r4, sizeof (float));
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_R8: {
memmove (data, &val->data.f, sizeof (double));
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_STRING:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_ARRAY: {
gpointer *p = (gpointer *) data;
mono_gc_wbarrier_generic_store_internal (p, val->data.o);
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR: {
gpointer *p = (gpointer *) data;
*p = val->data.p;
return MINT_STACK_SLOT_SIZE;
}
case MONO_TYPE_VALUETYPE:
if (m_class_is_enumtype (type->data.klass)) {
return stackval_to_data (mono_class_enum_basetype_internal (type->data.klass), val, data, pinvoke);
} else {
int size;
if (pinvoke) {
size = mono_class_native_size (type->data.klass, NULL);
memcpy (data, val, size);
} else {
size = mono_class_value_size (type->data.klass, NULL);
mono_value_copy_internal (data, val, type->data.klass);
}
return ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
case MONO_TYPE_GENERICINST: {
MonoClass *container_class = type->data.generic_class->container_class;
if (m_class_is_valuetype (container_class) && !m_class_is_enumtype (container_class)) {
MonoClass *klass = mono_class_from_mono_type_internal (type);
int size;
if (pinvoke) {
size = mono_class_native_size (klass, NULL);
memcpy (data, val, size);
} else {
size = mono_class_value_size (klass, NULL);
mono_value_copy_internal (data, val, klass);
}
return ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
return stackval_to_data (m_class_get_byval_arg (type->data.generic_class->container_class), val, data, pinvoke);
}
default:
g_error ("got type %x", type->type);
}
}
typedef struct {
MonoException *ex;
MonoContext *ctx;
} HandleExceptionCbData;
static void
handle_exception_cb (gpointer arg)
{
HandleExceptionCbData *cb_data = (HandleExceptionCbData*)arg;
mono_handle_exception (cb_data->ctx, (MonoObject*)cb_data->ex);
}
/*
* interp_throw:
* Throw an exception from the interpreter.
*/
static MONO_NEVER_INLINE void
interp_throw (ThreadContext *context, MonoException *ex, InterpFrame *frame, const guint16* ip, gboolean rethrow)
{
ERROR_DECL (error);
MonoLMFExt ext;
/*
* When explicitly throwing exception we pass the ip of the instruction that throws the exception.
* Offset the subtraction from interp_frame_get_ip, so we don't end up in prev instruction.
*/
frame->state.ip = ip + 1;
interp_push_lmf (&ext, frame);
if (mono_object_isinst_checked ((MonoObject *) ex, mono_defaults.exception_class, error)) {
MonoException *mono_ex = ex;
if (!rethrow) {
mono_ex->stack_trace = NULL;
mono_ex->trace_ips = NULL;
}
}
mono_error_assert_ok (error);
MonoContext ctx;
memset (&ctx, 0, sizeof (MonoContext));
MONO_CONTEXT_SET_SP (&ctx, frame);
/*
* Call the JIT EH code. The EH code will call back to us using:
* - mono_interp_set_resume_state ()/run_finally ()/run_filter ().
* Since ctx.ip is 0, this will start unwinding from the LMF frame
* pushed above, which points to our frames.
*/
mono_handle_exception (&ctx, (MonoObject*)ex);
interp_pop_lmf (&ext);
if (MONO_CONTEXT_GET_IP (&ctx) != 0) {
/* We need to unwind into non-interpreter code */
mono_restore_context (&ctx);
g_assert_not_reached ();
}
g_assert (context->has_resume_state);
}
static MONO_NEVER_INLINE MonoException *
interp_error_convert_to_exception (InterpFrame *frame, MonoError *error, const guint16 *ip)
{
MonoLMFExt ext;
MonoException *ex;
/*
* When calling runtime functions we pass the ip of the instruction triggering the runtime call.
* Offset the subtraction from interp_frame_get_ip, so we don't end up in prev instruction.
*/
frame->state.ip = ip + 1;
interp_push_lmf (&ext, frame);
ex = mono_error_convert_to_exception (error);
interp_pop_lmf (&ext);
return ex;
}
#define INTERP_BUILD_EXCEPTION_TYPE_FUNC_NAME(prefix_name, type_name) \
prefix_name ## _ ## type_name
#define INTERP_GET_EXCEPTION(exception_type) \
static MONO_NEVER_INLINE MonoException * \
INTERP_BUILD_EXCEPTION_TYPE_FUNC_NAME(interp_get_exception, exception_type) (InterpFrame *frame, const guint16 *ip)\
{ \
MonoLMFExt ext; \
MonoException *ex; \
frame->state.ip = ip + 1; \
interp_push_lmf (&ext, frame); \
ex = INTERP_BUILD_EXCEPTION_TYPE_FUNC_NAME(mono_get_exception,exception_type) (); \
interp_pop_lmf (&ext); \
return ex; \
}
#define INTERP_GET_EXCEPTION_CHAR_ARG(exception_type) \
static MONO_NEVER_INLINE MonoException * \
INTERP_BUILD_EXCEPTION_TYPE_FUNC_NAME(interp_get_exception, exception_type) (const char *arg, InterpFrame *frame, const guint16 *ip)\
{ \
MonoLMFExt ext; \
MonoException *ex; \
frame->state.ip = ip + 1; \
interp_push_lmf (&ext, frame); \
ex = INTERP_BUILD_EXCEPTION_TYPE_FUNC_NAME(mono_get_exception,exception_type) (arg); \
interp_pop_lmf (&ext); \
return ex; \
}
INTERP_GET_EXCEPTION(null_reference)
INTERP_GET_EXCEPTION(divide_by_zero)
INTERP_GET_EXCEPTION(overflow)
INTERP_GET_EXCEPTION(invalid_cast)
INTERP_GET_EXCEPTION(index_out_of_range)
INTERP_GET_EXCEPTION(array_type_mismatch)
INTERP_GET_EXCEPTION(arithmetic)
INTERP_GET_EXCEPTION_CHAR_ARG(argument_out_of_range)
// We conservatively pin exception object here to avoid tweaking the
// numerous call sites of this macro, even though, in a few cases,
// this is not needed.
#define THROW_EX_GENERAL(exception,ex_ip, rethrow) \
do { \
MonoException *__ex = (exception); \
MONO_HANDLE_ASSIGN_RAW (tmp_handle, (MonoObject*)__ex); \
interp_throw (context, __ex, (frame), (ex_ip), (rethrow)); \
MONO_HANDLE_ASSIGN_RAW (tmp_handle, (MonoObject*)NULL); \
goto resume; \
} while (0)
#define THROW_EX(exception,ex_ip) THROW_EX_GENERAL ((exception), (ex_ip), FALSE)
#define NULL_CHECK(o) do { \
if (G_UNLIKELY (!(o))) \
THROW_EX (interp_get_exception_null_reference (frame, ip), ip); \
} while (0)
#define EXCEPTION_CHECKPOINT \
do { \
if (mono_thread_interruption_request_flag && !mono_threads_is_critical_method (frame->imethod->method)) { \
MonoException *exc = mono_thread_interruption_checkpoint (); \
if (exc) \
THROW_EX_GENERAL (exc, ip, TRUE); \
} \
} while (0)
// Reduce duplicate code in interp_exec_method
static MONO_NEVER_INLINE void
do_safepoint (InterpFrame *frame, ThreadContext *context, const guint16 *ip)
{
MonoLMFExt ext;
/*
* When calling runtime functions we pass the ip of the instruction triggering the runtime call.
* Offset the subtraction from interp_frame_get_ip, so we don't end up in prev instruction.
*/
frame->state.ip = ip + 1;
interp_push_lmf (&ext, frame);
/* Poll safepoint */
mono_threads_safepoint ();
interp_pop_lmf (&ext);
}
#define SAFEPOINT \
do { \
if (G_UNLIKELY (mono_polling_required)) \
do_safepoint (frame, context, ip); \
} while (0)
static MonoObject*
ves_array_create (MonoClass *klass, int param_count, stackval *values, MonoError *error)
{
int rank = m_class_get_rank (klass);
uintptr_t *lengths = g_newa (uintptr_t, rank * 2);
intptr_t *lower_bounds = NULL;
if (param_count > rank && m_class_get_byval_arg (klass)->type == MONO_TYPE_SZARRAY) {
// Special constructor for jagged arrays
for (int i = 0; i < param_count; ++i)
lengths [i] = values [i].data.i;
return (MonoObject*) mono_array_new_jagged_checked (klass, param_count, lengths, error);
} else if (2 * rank == param_count) {
for (int l = 0; l < 2; ++l) {
int src = l;
int dst = l * rank;
for (int r = 0; r < rank; ++r, src += 2, ++dst) {
lengths [dst] = values [src].data.i;
}
}
/* lower bounds are first. */
lower_bounds = (intptr_t *) lengths;
lengths += rank;
} else {
/* Only lengths provided. */
for (int i = 0; i < param_count; ++i) {
lengths [i] = values [i].data.i;
}
}
return (MonoObject*) mono_array_new_full_checked (klass, lengths, lower_bounds, error);
}
static gint32
ves_array_calculate_index (MonoArray *ao, stackval *sp, gboolean safe)
{
MonoClass *ac = ((MonoObject *) ao)->vtable->klass;
guint32 pos = 0;
if (ao->bounds) {
for (gint32 i = 0; i < m_class_get_rank (ac); i++) {
gint32 idx = sp [i].data.i;
gint32 lower = ao->bounds [i].lower_bound;
guint32 len = ao->bounds [i].length;
if (safe && (idx < lower || (guint32)(idx - lower) >= len))
return -1;
pos = (pos * len) + (guint32)(idx - lower);
}
} else {
pos = sp [0].data.i;
if (safe && pos >= ao->max_length)
return -1;
}
return pos;
}
static MonoException*
ves_array_get (InterpFrame *frame, stackval *sp, stackval *retval, MonoMethodSignature *sig, gboolean safe)
{
MonoObject *o = sp->data.o;
MonoArray *ao = (MonoArray *) o;
MonoClass *ac = o->vtable->klass;
g_assert (m_class_get_rank (ac) >= 1);
gint32 pos = ves_array_calculate_index (ao, sp + 1, safe);
if (pos == -1)
return mono_get_exception_index_out_of_range ();
gint32 esize = mono_array_element_size (ac);
gconstpointer ea = mono_array_addr_with_size_fast (ao, esize, pos);
MonoType *mt = sig->ret;
stackval_from_data (mt, retval, ea, FALSE);
return NULL;
}
static MonoException*
ves_array_element_address (InterpFrame *frame, MonoClass *required_type, MonoArray *ao, gpointer *ret, stackval *sp, gboolean needs_typecheck)
{
MonoClass *ac = ((MonoObject *) ao)->vtable->klass;
g_assert (m_class_get_rank (ac) >= 1);
gint32 pos = ves_array_calculate_index (ao, sp, TRUE);
if (pos == -1)
return mono_get_exception_index_out_of_range ();
if (needs_typecheck && !mono_class_is_assignable_from_internal (m_class_get_element_class (mono_object_class ((MonoObject *) ao)), required_type))
return mono_get_exception_array_type_mismatch ();
gint32 esize = mono_array_element_size (ac);
*ret = mono_array_addr_with_size_fast (ao, esize, pos);
return NULL;
}
/* Does not handle `this` argument */
static guint32
compute_arg_offset (MonoMethodSignature *sig, int index, int prev_offset)
{
if (index == 0)
return 0;
if (prev_offset == -1) {
guint32 offset = 0;
for (int i = 0; i < index; i++) {
int size, align;
MonoType *type = sig->params [i];
size = mono_type_size (type, &align);
offset += ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
return offset;
} else {
int size, align;
MonoType *type = sig->params [index - 1];
size = mono_type_size (type, &align);
return prev_offset + ALIGN_TO (size, MINT_STACK_SLOT_SIZE);
}
}
static guint32*
initialize_arg_offsets (InterpMethod *imethod, MonoMethodSignature *csig)
{
if (imethod->arg_offsets)
return imethod->arg_offsets;
// For pinvokes, csig represents the real signature with marshalled args. If an explicit
// marshalled signature was not provided, we use the managed signature of the method.
MonoMethodSignature *sig = csig;
if (!sig)
sig = mono_method_signature_internal (imethod->method);
int arg_count = sig->hasthis + sig->param_count;
g_assert (arg_count);
guint32 *arg_offsets = (guint32*) g_malloc ((sig->hasthis + sig->param_count) * sizeof (int));
int index = 0, offset_addend = 0, prev_offset = 0;
if (sig->hasthis) {
arg_offsets [index++] = 0;
offset_addend = MINT_STACK_SLOT_SIZE;
}
for (int i = 0; i < sig->param_count; i++) {
prev_offset = compute_arg_offset (sig, i, prev_offset);
arg_offsets [index++] = prev_offset + offset_addend;
}
mono_memory_write_barrier ();
if (mono_atomic_cas_ptr ((gpointer*)&imethod->arg_offsets, arg_offsets, NULL) != NULL)
g_free (arg_offsets);
return imethod->arg_offsets;
}
static guint32
get_arg_offset_fast (InterpMethod *imethod, MonoMethodSignature *sig, int index)
{
guint32 *arg_offsets = imethod->arg_offsets;
if (arg_offsets)
return arg_offsets [index];
arg_offsets = initialize_arg_offsets (imethod, sig);
g_assert (arg_offsets);
return arg_offsets [index];
}
static guint32
get_arg_offset (InterpMethod *imethod, MonoMethodSignature *sig, int index)
{
if (imethod) {
return get_arg_offset_fast (imethod, sig, index);
} else {
g_assert (!sig->hasthis);
return compute_arg_offset (sig, index, -1);
}
}
#ifdef MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE
static MonoFuncV mono_native_to_interp_trampoline = NULL;
#endif
#ifndef MONO_ARCH_HAVE_INTERP_PINVOKE_TRAMP
static InterpMethodArguments*
build_args_from_sig (MonoMethodSignature *sig, InterpFrame *frame)
{
InterpMethodArguments *margs = g_malloc0 (sizeof (InterpMethodArguments));
#ifdef TARGET_ARM
g_assert (mono_arm_eabi_supported ());
int i8_align = mono_arm_i8_align ();
#endif
#ifdef TARGET_WASM
margs->sig = sig;
#endif
if (sig->hasthis)
margs->ilen++;
for (int i = 0; i < sig->param_count; i++) {
guint32 ptype = m_type_is_byref (sig->params [i]) ? MONO_TYPE_PTR : sig->params [i]->type;
switch (ptype) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_CHAR:
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_I:
case MONO_TYPE_U:
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_STRING:
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_GENERICINST:
#if SIZEOF_VOID_P == 8
case MONO_TYPE_I8:
case MONO_TYPE_U8:
#endif
margs->ilen++;
break;
#if SIZEOF_VOID_P == 4
case MONO_TYPE_I8:
case MONO_TYPE_U8:
#ifdef TARGET_ARM
/* pairs begin at even registers */
if (i8_align == 8 && margs->ilen & 1)
margs->ilen++;
#endif
margs->ilen += 2;
break;
#endif
case MONO_TYPE_R4:
case MONO_TYPE_R8:
margs->flen++;
break;
default:
g_error ("build_args_from_sig: not implemented yet (1): 0x%x\n", ptype);
}
}
if (margs->ilen > 0)
margs->iargs = g_malloc0 (sizeof (gpointer) * margs->ilen);
if (margs->flen > 0)
margs->fargs = g_malloc0 (sizeof (double) * margs->flen);
if (margs->ilen > INTERP_ICALL_TRAMP_IARGS)
g_error ("build_args_from_sig: TODO, allocate gregs: %d\n", margs->ilen);
if (margs->flen > INTERP_ICALL_TRAMP_FARGS)
g_error ("build_args_from_sig: TODO, allocate fregs: %d\n", margs->flen);
size_t int_i = 0;
size_t int_f = 0;
if (sig->hasthis) {
margs->iargs [0] = frame->stack [0].data.p;
int_i++;
g_error ("FIXME if hasthis, we incorrectly access the args below");
}
for (int i = 0; i < sig->param_count; i++) {
guint32 offset = get_arg_offset (frame->imethod, sig, i);
stackval *sp_arg = STACK_ADD_BYTES (frame->stack, offset);
MonoType *type = sig->params [i];
guint32 ptype;
retry:
ptype = m_type_is_byref (type) ? MONO_TYPE_PTR : type->type;
switch (ptype) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_CHAR:
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_I:
case MONO_TYPE_U:
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_STRING:
#if SIZEOF_VOID_P == 8
case MONO_TYPE_I8:
case MONO_TYPE_U8:
#endif
margs->iargs [int_i] = sp_arg->data.p;
#if DEBUG_INTERP
g_print ("build_args_from_sig: margs->iargs [%d]: %p (frame @ %d)\n", int_i, margs->iargs [int_i], i);
#endif
int_i++;
break;
case MONO_TYPE_VALUETYPE:
if (m_class_is_enumtype (type->data.klass)) {
type = mono_class_enum_basetype_internal (type->data.klass);
goto retry;
}
margs->iargs [int_i] = sp_arg;
#if DEBUG_INTERP
g_print ("build_args_from_sig: margs->iargs [%d]: %p (vt) (frame @ %d)\n", int_i, margs->iargs [int_i], i);
#endif
#ifdef HOST_WASM
{
/* Scalar vtypes are passed by value */
if (mini_wasm_is_scalar_vtype (sig->params [i]))
margs->iargs [int_i] = *(gpointer*)margs->iargs [int_i];
}
#endif
int_i++;
break;
case MONO_TYPE_GENERICINST: {
MonoClass *container_class = type->data.generic_class->container_class;
type = m_class_get_byval_arg (container_class);
goto retry;
}
#if SIZEOF_VOID_P == 4
case MONO_TYPE_I8:
case MONO_TYPE_U8: {
#ifdef TARGET_ARM
/* pairs begin at even registers */
if (i8_align == 8 && int_i & 1)
int_i++;
#endif
margs->iargs [int_i] = (gpointer) sp_arg->data.pair.lo;
int_i++;
margs->iargs [int_i] = (gpointer) sp_arg->data.pair.hi;
#if DEBUG_INTERP
g_print ("build_args_from_sig: margs->iargs [%d/%d]: 0x%016" PRIx64 ", hi=0x%08x lo=0x%08x (frame @ %d)\n", int_i - 1, int_i, *((guint64 *) &margs->iargs [int_i - 1]), sp_arg->data.pair.hi, sp_arg->data.pair.lo, i);
#endif
int_i++;
break;
}
#endif
case MONO_TYPE_R4:
case MONO_TYPE_R8:
if (ptype == MONO_TYPE_R4)
* (float *) &(margs->fargs [int_f]) = sp_arg->data.f_r4;
else
margs->fargs [int_f] = sp_arg->data.f;
#if DEBUG_INTERP
g_print ("build_args_from_sig: margs->fargs [%d]: %p (%f) (frame @ %d)\n", int_f, margs->fargs [int_f], margs->fargs [int_f], i);
#endif
int_f ++;
break;
default:
g_error ("build_args_from_sig: not implemented yet (2): 0x%x\n", ptype);
}
}
switch (sig->ret->type) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_CHAR:
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_I:
case MONO_TYPE_U:
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_STRING:
case MONO_TYPE_I8:
case MONO_TYPE_U8:
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_GENERICINST:
margs->retval = (gpointer*)frame->retval;
margs->is_float_ret = 0;
break;
case MONO_TYPE_R4:
case MONO_TYPE_R8:
margs->retval = (gpointer*)frame->retval;
margs->is_float_ret = 1;
break;
case MONO_TYPE_VOID:
margs->retval = NULL;
break;
default:
g_error ("build_args_from_sig: ret type not implemented yet: 0x%x\n", sig->ret->type);
}
return margs;
}
#endif
static void
interp_frame_arg_to_data (MonoInterpFrameHandle frame, MonoMethodSignature *sig, int index, gpointer data)
{
InterpFrame *iframe = (InterpFrame*)frame;
InterpMethod *imethod = iframe->imethod;
// If index == -1, we finished executing an InterpFrame and the result is at retval.
if (index == -1)
stackval_to_data (sig->ret, iframe->retval, data, sig->pinvoke && !sig->marshalling_disabled);
else if (sig->hasthis && index == 0)
*(gpointer*)data = iframe->stack->data.p;
else
stackval_to_data (sig->params [index - sig->hasthis], STACK_ADD_BYTES (iframe->stack, get_arg_offset (imethod, sig, index)), data, sig->pinvoke && !sig->marshalling_disabled);
}
static void
interp_data_to_frame_arg (MonoInterpFrameHandle frame, MonoMethodSignature *sig, int index, gconstpointer data)
{
InterpFrame *iframe = (InterpFrame*)frame;
InterpMethod *imethod = iframe->imethod;
// Get result from pinvoke call, put it directly on top of execution stack in the caller frame
if (index == -1)
stackval_from_data (sig->ret, iframe->retval, data, sig->pinvoke && !sig->marshalling_disabled);
else if (sig->hasthis && index == 0)
iframe->stack->data.p = *(gpointer*)data;
else
stackval_from_data (sig->params [index - sig->hasthis], STACK_ADD_BYTES (iframe->stack, get_arg_offset (imethod, sig, index)), data, sig->pinvoke && !sig->marshalling_disabled);
}
static gpointer
interp_frame_arg_to_storage (MonoInterpFrameHandle frame, MonoMethodSignature *sig, int index)
{
InterpFrame *iframe = (InterpFrame*)frame;
InterpMethod *imethod = iframe->imethod;
if (index == -1)
return iframe->retval;
else
return STACK_ADD_BYTES (iframe->stack, get_arg_offset (imethod, sig, index));
}
static MonoPIFunc
get_interp_to_native_trampoline (void)
{
static MonoPIFunc trampoline = NULL;
if (!trampoline) {
if (mono_ee_features.use_aot_trampolines) {
trampoline = (MonoPIFunc) mono_aot_get_trampoline ("interp_to_native_trampoline");
} else {
MonoTrampInfo *info;
trampoline = (MonoPIFunc) mono_arch_get_interp_to_native_trampoline (&info);
mono_tramp_info_register (info, NULL);
}
mono_memory_barrier ();
}
return trampoline;
}
static void
interp_to_native_trampoline (gpointer addr, gpointer ccontext)
{
get_interp_to_native_trampoline () (addr, ccontext);
}
/* MONO_NO_OPTIMIZATION is needed due to usage of INTERP_PUSH_LMF_WITH_CTX. */
#ifdef _MSC_VER
#pragma optimize ("", off)
#endif
static MONO_NO_OPTIMIZATION MONO_NEVER_INLINE gpointer
ves_pinvoke_method (
InterpMethod *imethod,
MonoMethodSignature *sig,
MonoFuncV addr,
ThreadContext *context,
InterpFrame *parent_frame,
stackval *ret_sp,
stackval *sp,
gboolean save_last_error,
gpointer *cache,
gboolean *gc_transitions)
{
InterpFrame frame = {0};
frame.parent = parent_frame;
frame.imethod = imethod;
frame.stack = sp;
frame.retval = ret_sp;
MonoLMFExt ext;
gpointer args;
MONO_REQ_GC_UNSAFE_MODE;
#ifdef HOST_WASM
/*
* Use a per-signature entry function.
* Cache it in imethod->data_items.
* This is GC safe.
*/
MonoPIFunc entry_func = *cache;
if (!entry_func) {
entry_func = (MonoPIFunc)mono_wasm_get_interp_to_native_trampoline (sig);
mono_memory_barrier ();
*cache = entry_func;
}
#else
static MonoPIFunc entry_func = NULL;
if (!entry_func) {
MONO_ENTER_GC_UNSAFE;
#ifdef MONO_ARCH_HAS_NO_PROPER_MONOCTX
ERROR_DECL (error);
entry_func = (MonoPIFunc) mono_jit_compile_method_jit_only (mini_get_interp_lmf_wrapper ("mono_interp_to_native_trampoline", (gpointer) mono_interp_to_native_trampoline), error);
mono_error_assert_ok (error);
#else
entry_func = get_interp_to_native_trampoline ();
#endif
mono_memory_barrier ();
MONO_EXIT_GC_UNSAFE;
}
#endif
if (save_last_error) {
mono_marshal_clear_last_error ();
}
#ifdef MONO_ARCH_HAVE_INTERP_PINVOKE_TRAMP
CallContext ccontext;
mono_arch_set_native_call_context_args (&ccontext, &frame, sig);
args = &ccontext;
#else
InterpMethodArguments *margs = build_args_from_sig (sig, &frame);
args = margs;
#endif
INTERP_PUSH_LMF_WITH_CTX (&frame, ext, exit_pinvoke);
if (*gc_transitions) {
MONO_ENTER_GC_SAFE;
entry_func ((gpointer) addr, args);
MONO_EXIT_GC_SAFE;
*gc_transitions = FALSE;
} else {
entry_func ((gpointer) addr, args);
}
if (save_last_error)
mono_marshal_set_last_error ();
interp_pop_lmf (&ext);
#ifdef MONO_ARCH_HAVE_INTERP_PINVOKE_TRAMP
if (!context->has_resume_state) {
mono_arch_get_native_call_context_ret (&ccontext, &frame, sig);
}
g_free (ccontext.stack);
#else
// Only the vt address has been returned, we need to copy the entire content on interp stack
if (!context->has_resume_state && MONO_TYPE_ISSTRUCT (sig->ret))
stackval_from_data (sig->ret, frame.retval, (char*)frame.retval->data.p, sig->pinvoke && !sig->marshalling_disabled);
g_free (margs->iargs);
g_free (margs->fargs);
g_free (margs);
#endif
goto exit_pinvoke; // prevent unused label warning in some configurations
exit_pinvoke:
return NULL;
}
#ifdef _MSC_VER
#pragma optimize ("", on)
#endif
/*
* interp_init_delegate:
*
* Initialize del->interp_method.
*/
static void
interp_init_delegate (MonoDelegate *del, MonoDelegateTrampInfo **out_info, MonoError *error)
{
MonoMethod *method;
if (del->interp_method) {
/* Delegate created by a call to ves_icall_mono_delegate_ctor_interp () */
del->method = ((InterpMethod *)del->interp_method)->method;
} else if (del->method_ptr && !del->method) {
/* Delegate created from methodInfo.MethodHandle.GetFunctionPointer() */
del->interp_method = (InterpMethod *)del->method_ptr;
if (mono_llvm_only)
// FIXME:
g_assert_not_reached ();
} else if (del->method) {
/* Delegate created dynamically */
del->interp_method = mono_interp_get_imethod (del->method, error);
} else {
/* Created from JITted code */
g_assert_not_reached ();
}
method = ((InterpMethod*)del->interp_method)->method;
if (del->target &&
method &&
method->flags & METHOD_ATTRIBUTE_VIRTUAL &&
method->flags & METHOD_ATTRIBUTE_ABSTRACT &&
mono_class_is_abstract (method->klass))
del->interp_method = get_virtual_method ((InterpMethod*)del->interp_method, del->target->vtable);
method = ((InterpMethod*)del->interp_method)->method;
if (method && m_class_get_parent (method->klass) == mono_defaults.multicastdelegate_class) {
const char *name = method->name;
if (*name == 'I' && (strcmp (name, "Invoke") == 0)) {
/*
* When invoking the delegate interp_method is executed directly. If it's an
* invoke make sure we replace it with the appropriate delegate invoke wrapper.
*
* FIXME We should do this later, when we also know the delegate on which the
* target method is called.
*/
del->interp_method = mono_interp_get_imethod (mono_marshal_get_delegate_invoke (method, NULL), error);
mono_error_assert_ok (error);
}
}
if (!((InterpMethod *) del->interp_method)->transformed && method_is_dynamic (method)) {
/* Return any errors from method compilation */
mono_interp_transform_method ((InterpMethod *) del->interp_method, get_context (), error);
return_if_nok (error);
}
/*
* Compute a MonoDelegateTrampInfo for this delegate if possible and pass it back to
* the caller.
* Keep a 1 element cache in imethod->del_info. This should be good enough since most methods
* are only associated with one delegate type.
*/
if (out_info)
*out_info = NULL;
if (mono_llvm_only) {
InterpMethod *imethod = del->interp_method;
method = imethod->method;
if (imethod->del_info && imethod->del_info->klass == del->object.vtable->klass) {
*out_info = imethod->del_info;
} else if (!imethod->del_info) {
imethod->del_info = mono_create_delegate_trampoline_info (del->object.vtable->klass, method);
*out_info = imethod->del_info;
}
}
}
/* Convert a function pointer for a managed method to an InterpMethod* */
static InterpMethod*
ftnptr_to_imethod (gpointer addr, gboolean *need_unbox)
{
InterpMethod *imethod;
if (mono_llvm_only) {
ERROR_DECL (error);
/* Function pointers are represented by a MonoFtnDesc structure */
MonoFtnDesc *ftndesc = (MonoFtnDesc*)addr;
g_assert (ftndesc);
g_assert (ftndesc->method);
if (!ftndesc->interp_method) {
imethod = mono_interp_get_imethod (ftndesc->method, error);
mono_error_assert_ok (error);
mono_memory_barrier ();
// FIXME Handle unboxing here ?
ftndesc->interp_method = imethod;
}
*need_unbox = INTERP_IMETHOD_IS_TAGGED_UNBOX (ftndesc->interp_method);
imethod = INTERP_IMETHOD_UNTAG_UNBOX (ftndesc->interp_method);
} else {
/* Function pointers are represented by their InterpMethod */
*need_unbox = INTERP_IMETHOD_IS_TAGGED_UNBOX (addr);
imethod = INTERP_IMETHOD_UNTAG_UNBOX (addr);
}
return imethod;
}
static gpointer
imethod_to_ftnptr (InterpMethod *imethod, gboolean need_unbox)
{
if (mono_llvm_only) {
ERROR_DECL (error);
/* Function pointers are represented by a MonoFtnDesc structure */
MonoFtnDesc **ftndesc_p;
if (need_unbox)
ftndesc_p = &imethod->ftndesc_unbox;
else
ftndesc_p = &imethod->ftndesc;
if (!*ftndesc_p) {
MonoFtnDesc *ftndesc = mini_llvmonly_load_method_ftndesc (imethod->method, FALSE, need_unbox, error);
mono_error_assert_ok (error);
if (need_unbox)
ftndesc->interp_method = INTERP_IMETHOD_TAG_UNBOX (imethod);
else
ftndesc->interp_method = imethod;
mono_memory_barrier ();
*ftndesc_p = ftndesc;
}
return *ftndesc_p;
} else {
if (need_unbox)
return INTERP_IMETHOD_TAG_UNBOX (imethod);
else
return imethod;
}
}
static void
interp_delegate_ctor (MonoObjectHandle this_obj, MonoObjectHandle target, gpointer addr, MonoError *error)
{
gboolean need_unbox;
/* addr is the result of an LDFTN opcode */
InterpMethod *imethod = ftnptr_to_imethod (addr, &need_unbox);
if (!(imethod->method->flags & METHOD_ATTRIBUTE_STATIC)) {
MonoMethod *invoke = mono_get_delegate_invoke_internal (mono_handle_class (this_obj));
/* virtual invoke delegates must not have null check */
if (mono_method_signature_internal (imethod->method)->param_count == mono_method_signature_internal (invoke)->param_count
&& MONO_HANDLE_IS_NULL (target)) {
mono_error_set_argument (error, "this", "Delegate to an instance method cannot have null 'this'");
return;
}
}
g_assert (imethod->method);
gpointer entry = mini_get_interp_callbacks ()->create_method_pointer (imethod->method, FALSE, error);
return_if_nok (error);
MONO_HANDLE_SETVAL (MONO_HANDLE_CAST (MonoDelegate, this_obj), interp_method, gpointer, imethod);
mono_delegate_ctor (this_obj, target, entry, imethod->method, error);
}
#if DEBUG_INTERP
static void
dump_stackval (GString *str, stackval *s, MonoType *type)
{
switch (type->type) {
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_CHAR:
case MONO_TYPE_BOOLEAN:
g_string_append_printf (str, "[%d] ", s->data.i);
break;
case MONO_TYPE_STRING:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_ARRAY:
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
case MONO_TYPE_I:
case MONO_TYPE_U:
g_string_append_printf (str, "[%p] ", s->data.p);
break;
case MONO_TYPE_VALUETYPE:
if (m_class_is_enumtype (type->data.klass))
g_string_append_printf (str, "[%d] ", s->data.i);
else
g_string_append_printf (str, "[vt:%p] ", s->data.p);
break;
case MONO_TYPE_R4:
g_string_append_printf (str, "[%g] ", s->data.f_r4);
break;
case MONO_TYPE_R8:
g_string_append_printf (str, "[%g] ", s->data.f);
break;
case MONO_TYPE_I8:
case MONO_TYPE_U8:
default: {
GString *res = g_string_new ("");
mono_type_get_desc (res, type, TRUE);
g_string_append_printf (str, "[{%s} %" PRId64 "/0x%0" PRIx64 "] ", res->str, (gint64)s->data.l, (guint64)s->data.l);
g_string_free (res, TRUE);
break;
}
}
}
static char*
dump_retval (InterpFrame *inv)
{
GString *str = g_string_new ("");
MonoType *ret = mono_method_signature_internal (inv->imethod->method)->ret;
if (ret->type != MONO_TYPE_VOID)
dump_stackval (str, inv->stack, ret);
return g_string_free (str, FALSE);
}
static char*
dump_args (InterpFrame *inv)
{
GString *str = g_string_new ("");
int i;
MonoMethodSignature *signature = mono_method_signature_internal (inv->imethod->method);
if (signature->param_count == 0 && !signature->hasthis)
return g_string_free (str, FALSE);
if (signature->hasthis) {
MonoMethod *method = inv->imethod->method;
dump_stackval (str, inv->stack, m_class_get_byval_arg (method->klass));
}
for (i = 0; i < signature->param_count; ++i)
dump_stackval (str, inv->stack + (!!signature->hasthis) + i, signature->params [i]);
return g_string_free (str, FALSE);
}
#endif
#define CHECK_ADD_OVERFLOW(a,b) \
(gint32)(b) >= 0 ? (gint32)(G_MAXINT32) - (gint32)(b) < (gint32)(a) ? -1 : 0 \
: (gint32)(G_MININT32) - (gint32)(b) > (gint32)(a) ? +1 : 0
#define CHECK_SUB_OVERFLOW(a,b) \
(gint32)(b) < 0 ? (gint32)(G_MAXINT32) + (gint32)(b) < (gint32)(a) ? -1 : 0 \
: (gint32)(G_MININT32) + (gint32)(b) > (gint32)(a) ? +1 : 0
#define CHECK_ADD_OVERFLOW_UN(a,b) \
(guint32)(G_MAXUINT32) - (guint32)(b) < (guint32)(a) ? -1 : 0
#define CHECK_SUB_OVERFLOW_UN(a,b) \
(guint32)(a) < (guint32)(b) ? -1 : 0
#define CHECK_ADD_OVERFLOW64(a,b) \
(gint64)(b) >= 0 ? (gint64)(G_MAXINT64) - (gint64)(b) < (gint64)(a) ? -1 : 0 \
: (gint64)(G_MININT64) - (gint64)(b) > (gint64)(a) ? +1 : 0
#define CHECK_SUB_OVERFLOW64(a,b) \
(gint64)(b) < 0 ? (gint64)(G_MAXINT64) + (gint64)(b) < (gint64)(a) ? -1 : 0 \
: (gint64)(G_MININT64) + (gint64)(b) > (gint64)(a) ? +1 : 0
#define CHECK_ADD_OVERFLOW64_UN(a,b) \
(guint64)(G_MAXUINT64) - (guint64)(b) < (guint64)(a) ? -1 : 0
#define CHECK_SUB_OVERFLOW64_UN(a,b) \
(guint64)(a) < (guint64)(b) ? -1 : 0
#if SIZEOF_VOID_P == 4
#define CHECK_ADD_OVERFLOW_NAT(a,b) CHECK_ADD_OVERFLOW(a,b)
#define CHECK_ADD_OVERFLOW_NAT_UN(a,b) CHECK_ADD_OVERFLOW_UN(a,b)
#else
#define CHECK_ADD_OVERFLOW_NAT(a,b) CHECK_ADD_OVERFLOW64(a,b)
#define CHECK_ADD_OVERFLOW_NAT_UN(a,b) CHECK_ADD_OVERFLOW64_UN(a,b)
#endif
/* Resolves to TRUE if the operands would overflow */
#define CHECK_MUL_OVERFLOW(a,b) \
((gint32)(a) == 0) || ((gint32)(b) == 0) ? 0 : \
(((gint32)(a) > 0) && ((gint32)(b) == -1)) ? FALSE : \
(((gint32)(a) < 0) && ((gint32)(b) == -1)) ? (a == G_MININT32) : \
(((gint32)(a) > 0) && ((gint32)(b) > 0)) ? (gint32)(a) > ((G_MAXINT32) / (gint32)(b)) : \
(((gint32)(a) > 0) && ((gint32)(b) < 0)) ? (gint32)(a) > ((G_MININT32) / (gint32)(b)) : \
(((gint32)(a) < 0) && ((gint32)(b) > 0)) ? (gint32)(a) < ((G_MININT32) / (gint32)(b)) : \
(gint32)(a) < ((G_MAXINT32) / (gint32)(b))
#define CHECK_MUL_OVERFLOW_UN(a,b) \
((guint32)(a) == 0) || ((guint32)(b) == 0) ? 0 : \
(guint32)(b) > ((G_MAXUINT32) / (guint32)(a))
#define CHECK_MUL_OVERFLOW64(a,b) \
((gint64)(a) == 0) || ((gint64)(b) == 0) ? 0 : \
(((gint64)(a) > 0) && ((gint64)(b) == -1)) ? FALSE : \
(((gint64)(a) < 0) && ((gint64)(b) == -1)) ? (a == G_MININT64) : \
(((gint64)(a) > 0) && ((gint64)(b) > 0)) ? (gint64)(a) > ((G_MAXINT64) / (gint64)(b)) : \
(((gint64)(a) > 0) && ((gint64)(b) < 0)) ? (gint64)(a) > ((G_MININT64) / (gint64)(b)) : \
(((gint64)(a) < 0) && ((gint64)(b) > 0)) ? (gint64)(a) < ((G_MININT64) / (gint64)(b)) : \
(gint64)(a) < ((G_MAXINT64) / (gint64)(b))
#define CHECK_MUL_OVERFLOW64_UN(a,b) \
((guint64)(a) == 0) || ((guint64)(b) == 0) ? 0 : \
(guint64)(b) > ((G_MAXUINT64) / (guint64)(a))
#if SIZEOF_VOID_P == 4
#define CHECK_MUL_OVERFLOW_NAT(a,b) CHECK_MUL_OVERFLOW(a,b)
#define CHECK_MUL_OVERFLOW_NAT_UN(a,b) CHECK_MUL_OVERFLOW_UN(a,b)
#else
#define CHECK_MUL_OVERFLOW_NAT(a,b) CHECK_MUL_OVERFLOW64(a,b)
#define CHECK_MUL_OVERFLOW_NAT_UN(a,b) CHECK_MUL_OVERFLOW64_UN(a,b)
#endif
// Do not inline in case order of frame addresses matters.
static MONO_NEVER_INLINE MonoObject*
interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc, MonoError *error)
{
ThreadContext *context = get_context ();
MonoMethodSignature *sig = mono_method_signature_internal (method);
stackval *sp = (stackval*)context->stack_pointer;
MonoMethod *target_method = method;
error_init (error);
if (exc)
*exc = NULL;
if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
target_method = mono_marshal_get_native_wrapper (target_method, FALSE, FALSE);
MonoMethod *invoke_wrapper = mono_marshal_get_runtime_invoke_full (target_method, FALSE, TRUE);
//* <code>MonoObject *runtime_invoke (MonoObject *this_obj, void **params, MonoObject **exc, void* method)</code>
if (sig->hasthis)
sp [0].data.p = obj;
else
sp [0].data.p = NULL;
sp [1].data.p = params;
sp [2].data.p = exc;
sp [3].data.p = target_method;
InterpMethod *imethod = mono_interp_get_imethod (invoke_wrapper, error);
mono_error_assert_ok (error);
InterpFrame frame = {0};
frame.imethod = imethod;
frame.stack = sp;
frame.retval = sp;
// The method to execute might not be transformed yet, so we don't know how much stack
// it uses. We bump the stack_pointer here so any code triggered by method compilation
// will not attempt to use the space that we used to push the args for this method.
// The real top of stack for this method will be set in interp_exec_method once the
// method is transformed.
context->stack_pointer = (guchar*)(sp + 4);
g_assert (context->stack_pointer < context->stack_end);
MONO_ENTER_GC_UNSAFE;
interp_exec_method (&frame, context, NULL);
MONO_EXIT_GC_UNSAFE;
context->stack_pointer = (guchar*)sp;
check_pending_unwind (context);
if (context->has_resume_state) {
/*
* This can happen on wasm where native frames cannot be skipped during EH.
* EH processing will continue when control returns to the interpreter.
*/
return NULL;
}
// The return value is at the bottom of the stack
return frame.stack->data.o;
}
typedef struct {
InterpMethod *rmethod;
gpointer this_arg;
gpointer res;
gpointer args [16];
gpointer *many_args;
} InterpEntryData;
/* Main function for entering the interpreter from compiled code */
// Do not inline in case order of frame addresses matters.
static MONO_NEVER_INLINE void
interp_entry (InterpEntryData *data)
{
InterpMethod *rmethod;
ThreadContext *context;
stackval *sp, *sp_args;
MonoMethod *method;
MonoMethodSignature *sig;
MonoType *type;
gpointer orig_domain = NULL, attach_cookie;
int i;
if ((gsize)data->rmethod & 1) {
/* Unbox */
data->this_arg = mono_object_unbox_internal ((MonoObject*)data->this_arg);
data->rmethod = (InterpMethod*)(gpointer)((gsize)data->rmethod & ~1);
}
rmethod = data->rmethod;
if (rmethod->needs_thread_attach)
orig_domain = mono_threads_attach_coop (mono_domain_get (), &attach_cookie);
context = get_context ();
sp_args = sp = (stackval*)context->stack_pointer;
method = rmethod->method;
if (m_class_get_parent (method->klass) == mono_defaults.multicastdelegate_class && !strcmp (method->name, "Invoke")) {
/*
* This happens when AOT code for the invoke wrapper is not found.
* Have to replace the method with the wrapper here, since the wrapper depends on the delegate.
*/
ERROR_DECL (error);
MonoDelegate *del = (MonoDelegate*)data->this_arg;
// FIXME: This is slow
method = mono_marshal_get_delegate_invoke (method, del);
data->rmethod = mono_interp_get_imethod (method, error);
mono_error_assert_ok (error);
}
sig = mono_method_signature_internal (method);
// FIXME: Optimize this
if (sig->hasthis) {
sp_args->data.p = data->this_arg;
sp_args++;
}
gpointer *params;
if (data->many_args)
params = data->many_args;
else
params = data->args;
for (i = 0; i < sig->param_count; ++i) {
if (m_type_is_byref (sig->params [i])) {
sp_args->data.p = params [i];
sp_args++;
} else {
int size = stackval_from_data (sig->params [i], sp_args, params [i], FALSE);
sp_args = STACK_ADD_BYTES (sp_args, size);
}
}
InterpFrame frame = {0};
frame.imethod = data->rmethod;
frame.stack = sp;
frame.retval = sp;
context->stack_pointer = (guchar*)sp_args;
g_assert (context->stack_pointer < context->stack_end);
MONO_ENTER_GC_UNSAFE;
interp_exec_method (&frame, context, NULL);
MONO_EXIT_GC_UNSAFE;
context->stack_pointer = (guchar*)sp;
if (rmethod->needs_thread_attach)
mono_threads_detach_coop (orig_domain, &attach_cookie);
check_pending_unwind (context);
if (mono_llvm_only) {
if (context->has_resume_state)
/* The exception will be handled in a frame above us */
mono_llvm_cpp_throw_exception ();
} else {
g_assert (!context->has_resume_state);
}
// The return value is at the bottom of the stack, after the locals space
type = rmethod->rtype;
if (type->type != MONO_TYPE_VOID)
stackval_to_data (type, frame.stack, data->res, FALSE);
}
static void
do_icall (MonoMethodSignature *sig, int op, stackval *ret_sp, stackval *sp, gpointer ptr, gboolean save_last_error)
{
if (save_last_error)
mono_marshal_clear_last_error ();
switch (op) {
case MINT_ICALL_V_V: {
typedef void (*T)(void);
T func = (T)ptr;
func ();
break;
}
case MINT_ICALL_V_P: {
typedef gpointer (*T)(void);
T func = (T)ptr;
ret_sp->data.p = func ();
break;
}
case MINT_ICALL_P_V: {
typedef void (*T)(gpointer);
T func = (T)ptr;
func (sp [0].data.p);
break;
}
case MINT_ICALL_P_P: {
typedef gpointer (*T)(gpointer);
T func = (T)ptr;
ret_sp->data.p = func (sp [0].data.p);
break;
}
case MINT_ICALL_PP_V: {
typedef void (*T)(gpointer,gpointer);
T func = (T)ptr;
func (sp [0].data.p, sp [1].data.p);
break;
}
case MINT_ICALL_PP_P: {
typedef gpointer (*T)(gpointer,gpointer);
T func = (T)ptr;
ret_sp->data.p = func (sp [0].data.p, sp [1].data.p);
break;
}
case MINT_ICALL_PPP_V: {
typedef void (*T)(gpointer,gpointer,gpointer);
T func = (T)ptr;
func (sp [0].data.p, sp [1].data.p, sp [2].data.p);
break;
}
case MINT_ICALL_PPP_P: {
typedef gpointer (*T)(gpointer,gpointer,gpointer);
T func = (T)ptr;
ret_sp->data.p = func (sp [0].data.p, sp [1].data.p, sp [2].data.p);
break;
}
case MINT_ICALL_PPPP_V: {
typedef void (*T)(gpointer,gpointer,gpointer,gpointer);
T func = (T)ptr;
func (sp [0].data.p, sp [1].data.p, sp [2].data.p, sp [3].data.p);
break;
}
case MINT_ICALL_PPPP_P: {
typedef gpointer (*T)(gpointer,gpointer,gpointer,gpointer);
T func = (T)ptr;
ret_sp->data.p = func (sp [0].data.p, sp [1].data.p, sp [2].data.p, sp [3].data.p);
break;
}
case MINT_ICALL_PPPPP_V: {
typedef void (*T)(gpointer,gpointer,gpointer,gpointer,gpointer);
T func = (T)ptr;
func (sp [0].data.p, sp [1].data.p, sp [2].data.p, sp [3].data.p, sp [4].data.p);
break;
}
case MINT_ICALL_PPPPP_P: {
typedef gpointer (*T)(gpointer,gpointer,gpointer,gpointer,gpointer);
T func = (T)ptr;
ret_sp->data.p = func (sp [0].data.p, sp [1].data.p, sp [2].data.p, sp [3].data.p, sp [4].data.p);
break;
}
case MINT_ICALL_PPPPPP_V: {
typedef void (*T)(gpointer,gpointer,gpointer,gpointer,gpointer,gpointer);
T func = (T)ptr;
func (sp [0].data.p, sp [1].data.p, sp [2].data.p, sp [3].data.p, sp [4].data.p, sp [5].data.p);
break;
}
case MINT_ICALL_PPPPPP_P: {
typedef gpointer (*T)(gpointer,gpointer,gpointer,gpointer,gpointer,gpointer);
T func = (T)ptr;
ret_sp->data.p = func (sp [0].data.p, sp [1].data.p, sp [2].data.p, sp [3].data.p, sp [4].data.p, sp [5].data.p);
break;
}
default:
g_assert_not_reached ();
}
if (save_last_error)
mono_marshal_set_last_error ();
/* convert the native representation to the stackval representation */
if (sig)
stackval_from_data (sig->ret, ret_sp, (char*) &ret_sp->data.p, sig->pinvoke && !sig->marshalling_disabled);
}
/* MONO_NO_OPTIMIZATION is needed due to usage of INTERP_PUSH_LMF_WITH_CTX. */
#ifdef _MSC_VER
#pragma optimize ("", off)
#endif
// Do not inline in case order of frame addresses matters, and maybe other reasons.
static MONO_NO_OPTIMIZATION MONO_NEVER_INLINE gpointer
do_icall_wrapper (InterpFrame *frame, MonoMethodSignature *sig, int op, stackval *ret_sp, stackval *sp, gpointer ptr, gboolean save_last_error, gboolean *gc_transitions)
{
MonoLMFExt ext;
INTERP_PUSH_LMF_WITH_CTX (frame, ext, exit_icall);
if (*gc_transitions) {
MONO_ENTER_GC_SAFE;
do_icall (sig, op, ret_sp, sp, ptr, save_last_error);
MONO_EXIT_GC_SAFE;
*gc_transitions = FALSE;
} else {
do_icall (sig, op, ret_sp, sp, ptr, save_last_error);
}
interp_pop_lmf (&ext);
goto exit_icall; // prevent unused label warning in some configurations
/* If an exception is thrown from native code, execution will continue here */
exit_icall:
return NULL;
}
#ifdef _MSC_VER
#pragma optimize ("", on)
#endif
typedef struct {
int pindex;
gpointer jit_wrapper;
gpointer *args;
gpointer extra_arg;
MonoFtnDesc ftndesc;
} JitCallCbData;
/* Callback called by mono_llvm_cpp_catch_exception () */
static void
jit_call_cb (gpointer arg)
{
JitCallCbData *cb_data = (JitCallCbData*)arg;
gpointer jit_wrapper = cb_data->jit_wrapper;
int pindex = cb_data->pindex;
gpointer *args = cb_data->args;
gpointer ftndesc = cb_data->extra_arg;
switch (pindex) {
case 0: {
typedef void (*T)(gpointer);
T func = (T)jit_wrapper;
func (ftndesc);
break;
}
case 1: {
typedef void (*T)(gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], ftndesc);
break;
}
case 2: {
typedef void (*T)(gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], ftndesc);
break;
}
case 3: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], args [2], ftndesc);
break;
}
case 4: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], args [2], args [3], ftndesc);
break;
}
case 5: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], args [2], args [3], args [4], ftndesc);
break;
}
case 6: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], args [2], args [3], args [4], args [5], ftndesc);
break;
}
case 7: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], args [2], args [3], args [4], args [5], args [6], ftndesc);
break;
}
case 8: {
typedef void (*T)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer);
T func = (T)jit_wrapper;
func (args [0], args [1], args [2], args [3], args [4], args [5], args [6], args [7], ftndesc);
break;
}
default:
g_assert_not_reached ();
break;
}
}
enum {
/* Pass stackval->data.p */
JIT_ARG_BYVAL,
/* Pass &stackval->data.p */
JIT_ARG_BYREF
};
enum {
JIT_RET_VOID,
JIT_RET_SCALAR,
JIT_RET_VTYPE
};
typedef struct _JitCallInfo JitCallInfo;
struct _JitCallInfo {
gpointer addr;
gpointer extra_arg;
gpointer wrapper;
MonoMethodSignature *sig;
guint8 *arginfo;
gint32 res_size;
int ret_mt;
gboolean no_wrapper;
};
static MONO_NEVER_INLINE void
init_jit_call_info (InterpMethod *rmethod, MonoError *error)
{
MonoMethodSignature *sig;
JitCallInfo *cinfo;
//printf ("jit_call: %s\n", mono_method_full_name (rmethod->method, 1));
MonoMethod *method = rmethod->method;
// FIXME: Memory management
cinfo = g_new0 (JitCallInfo, 1);
sig = mono_method_signature_internal (method);
g_assert (sig);
gpointer addr = mono_jit_compile_method_jit_only (method, error);
return_if_nok (error);
g_assert (addr);
gboolean need_wrapper = TRUE;
if (mono_llvm_only) {
MonoAotMethodFlags flags = mono_aot_get_method_flags (addr);
if (flags & MONO_AOT_METHOD_FLAG_GSHAREDVT_VARIABLE) {
/*
* The callee already has a gsharedvt signature, we can call it directly
* instead of through a gsharedvt out wrapper.
*/
need_wrapper = FALSE;
cinfo->no_wrapper = TRUE;
}
}
gpointer jit_wrapper = NULL;
if (need_wrapper) {
MonoMethod *wrapper = mini_get_gsharedvt_out_sig_wrapper (sig);
jit_wrapper = mono_jit_compile_method_jit_only (wrapper, error);
mono_error_assert_ok (error);
}
if (mono_llvm_only) {
gboolean caller_gsharedvt = !need_wrapper;
cinfo->addr = mini_llvmonly_add_method_wrappers (method, addr, caller_gsharedvt, FALSE, &cinfo->extra_arg);
} else {
cinfo->addr = addr;
}
cinfo->sig = sig;
cinfo->wrapper = jit_wrapper;
if (sig->ret->type != MONO_TYPE_VOID) {
int mt = mint_type (sig->ret);
if (mt == MINT_TYPE_VT) {
MonoClass *klass = mono_class_from_mono_type_internal (sig->ret);
/*
* We cache this size here, instead of the instruction stream of the
* calling instruction, to save space for common callvirt instructions
* that could end up doing a jit call.
*/
gint32 size = mono_class_value_size (klass, NULL);
cinfo->res_size = ALIGN_TO (size, MINT_VT_ALIGNMENT);
} else {
cinfo->res_size = MINT_STACK_SLOT_SIZE;
}
cinfo->ret_mt = mt;
} else {
cinfo->ret_mt = -1;
}
if (sig->param_count) {
cinfo->arginfo = g_new0 (guint8, sig->param_count);
for (int i = 0; i < rmethod->param_count; ++i) {
MonoType *t = rmethod->param_types [i];
int mt = mint_type (t);
if (m_type_is_byref (sig->params [i])) {
cinfo->arginfo [i] = JIT_ARG_BYVAL;
} else if (mt == MINT_TYPE_O) {
cinfo->arginfo [i] = JIT_ARG_BYREF;
} else {
/* stackval->data is an union */
cinfo->arginfo [i] = JIT_ARG_BYREF;
}
}
}
mono_memory_barrier ();
rmethod->jit_call_info = cinfo;
}
static MONO_NEVER_INLINE void
do_jit_call (ThreadContext *context, stackval *ret_sp, stackval *sp, InterpFrame *frame, InterpMethod *rmethod, MonoError *error)
{
MonoLMFExt ext;
JitCallInfo *cinfo;
//printf ("jit_call: %s\n", mono_method_full_name (rmethod->method, 1));
/*
* Call JITted code through a gsharedvt_out wrapper. These wrappers receive every argument
* by ref and return a return value using an explicit return value argument.
*/
if (G_UNLIKELY (!rmethod->jit_call_info)) {
init_jit_call_info (rmethod, error);
mono_error_assert_ok (error);
}
cinfo = (JitCallInfo*)rmethod->jit_call_info;
/*
* Convert the arguments on the interpeter stack to the format expected by the gsharedvt_out wrapper.
*/
gpointer args [32];
int pindex = 0;
int stack_index = 0;
if (rmethod->hasthis) {
args [pindex ++] = sp [0].data.p;
stack_index ++;
}
/* return address */
if (cinfo->ret_mt != -1)
args [pindex ++] = ret_sp;
for (int i = 0; i < rmethod->param_count; ++i) {
stackval *sval = STACK_ADD_BYTES (sp, get_arg_offset_fast (rmethod, NULL, stack_index + i));
if (cinfo->arginfo [i] == JIT_ARG_BYVAL)
args [pindex ++] = sval->data.p;
else
/* data is an union, so can use 'p' for all types */
args [pindex ++] = sval;
}
JitCallCbData cb_data;
memset (&cb_data, 0, sizeof (cb_data));
cb_data.pindex = pindex;
cb_data.args = args;
if (cinfo->no_wrapper) {
cb_data.jit_wrapper = cinfo->addr;
cb_data.extra_arg = cinfo->extra_arg;
} else {
cb_data.ftndesc.addr = cinfo->addr;
cb_data.ftndesc.arg = cinfo->extra_arg;
cb_data.jit_wrapper = cinfo->wrapper;
cb_data.extra_arg = &cb_data.ftndesc;
}
interp_push_lmf (&ext, frame);
gboolean thrown = FALSE;
if (mono_aot_mode == MONO_AOT_MODE_LLVMONLY_INTERP) {
/* Catch the exception thrown by the native code using a try-catch */
mono_llvm_cpp_catch_exception (jit_call_cb, &cb_data, &thrown);
} else {
jit_call_cb (&cb_data);
}
interp_pop_lmf (&ext);
if (thrown) {
if (context->has_resume_state)
/*
* This happens when interp_entry calls mono_llvm_reraise_exception ().
*/
return;
MonoJitTlsData *jit_tls = mono_get_jit_tls ();
if (jit_tls->resume_state.il_state) {
/*
* This c++ exception is going to be caught by an AOTed frame above us.
* We can't rethrow here, since that will skip the cleanup of the
* interpreter stack space etc. So instruct the interpreter to unwind.
*/
context->has_resume_state = TRUE;
context->handler_frame = NULL;
return;
}
MonoObject *obj = mini_llvmonly_load_exception ();
g_assert (obj);
mini_llvmonly_clear_exception ();
mono_error_set_exception_instance (error, (MonoException*)obj);
return;
}
if (cinfo->ret_mt != -1) {
// Sign/zero extend if necessary
switch (cinfo->ret_mt) {
case MINT_TYPE_I1:
ret_sp->data.i = *(gint8*)ret_sp;
break;
case MINT_TYPE_U1:
ret_sp->data.i = *(guint8*)ret_sp;
break;
case MINT_TYPE_I2:
ret_sp->data.i = *(gint16*)ret_sp;
break;
case MINT_TYPE_U2:
ret_sp->data.i = *(guint16*)ret_sp;
break;
case MINT_TYPE_I4:
case MINT_TYPE_I8:
case MINT_TYPE_R4:
case MINT_TYPE_R8:
case MINT_TYPE_VT:
case MINT_TYPE_O:
/* The result was written to ret_sp */
break;
default:
g_assert_not_reached ();
}
}
}
static MONO_NEVER_INLINE void
do_debugger_tramp (void (*tramp) (void), InterpFrame *frame)
{
MonoLMFExt ext;
interp_push_lmf (&ext, frame);
tramp ();
interp_pop_lmf (&ext);
}
static MONO_NEVER_INLINE MonoException*
do_transform_method (InterpMethod *imethod, InterpFrame *frame, ThreadContext *context)
{
MonoLMFExt ext;
/* Don't push lmf if we have no interp data */
gboolean push_lmf = frame->parent != NULL;
MonoException *ex = NULL;
ERROR_DECL (error);
/* Use the parent frame as the current frame is not complete yet */
if (push_lmf)
interp_push_lmf (&ext, frame->parent);
#if DEBUG_INTERP
if (imethod->method) {
char* mn = mono_method_full_name (imethod->method, TRUE);
g_print ("(%p) Transforming %s\n", mono_thread_internal_current (), mn);
g_free (mn);
}
#endif
mono_interp_transform_method (imethod, context, error);
if (!is_ok (error))
ex = mono_error_convert_to_exception (error);
if (push_lmf)
interp_pop_lmf (&ext);
return ex;
}
static void
init_arglist (InterpFrame *frame, MonoMethodSignature *sig, stackval *sp, char *arglist)
{
*(gpointer*)arglist = sig;
arglist += sizeof (gpointer);
for (int i = sig->sentinelpos; i < sig->param_count; i++) {
int align, arg_size, sv_size;
arg_size = mono_type_stack_size (sig->params [i], &align);
arglist = (char*)ALIGN_PTR_TO (arglist, align);
sv_size = stackval_to_data (sig->params [i], sp, arglist, FALSE);
arglist += arg_size;
sp = STACK_ADD_BYTES (sp, sv_size);
}
}
/*
* These functions are the entry points into the interpreter from compiled code.
* They are called by the interp_in wrappers. They have the following signature:
* void (<optional this_arg>, <optional retval pointer>, <arg1>, ..., <argn>, <method ptr>)
* They pack up their arguments into an InterpEntryData structure and call interp_entry ().
* It would be possible for the wrappers to pack up the arguments etc, but that would make them bigger, and there are
* more wrappers then these functions.
* this/static * ret/void * 16 arguments -> 64 functions.
*/
#define INTERP_ENTRY_BASE(_method, _this_arg, _res) \
InterpEntryData data; \
(data).rmethod = (_method); \
(data).res = (_res); \
(data).this_arg = (_this_arg); \
(data).many_args = NULL;
#define INTERP_ENTRY0(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
interp_entry (&data); \
}
#define INTERP_ENTRY1(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
interp_entry (&data); \
}
#define INTERP_ENTRY2(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
interp_entry (&data); \
}
#define INTERP_ENTRY3(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
(data).args [2] = arg3; \
interp_entry (&data); \
}
#define INTERP_ENTRY4(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
(data).args [2] = arg3; \
(data).args [3] = arg4; \
interp_entry (&data); \
}
#define INTERP_ENTRY5(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
(data).args [2] = arg3; \
(data).args [3] = arg4; \
(data).args [4] = arg5; \
interp_entry (&data); \
}
#define INTERP_ENTRY6(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
(data).args [2] = arg3; \
(data).args [3] = arg4; \
(data).args [4] = arg5; \
(data).args [5] = arg6; \
interp_entry (&data); \
}
#define INTERP_ENTRY7(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
(data).args [2] = arg3; \
(data).args [3] = arg4; \
(data).args [4] = arg5; \
(data).args [5] = arg6; \
(data).args [6] = arg7; \
interp_entry (&data); \
}
#define INTERP_ENTRY8(_this_arg, _res, _method) { \
INTERP_ENTRY_BASE (_method, _this_arg, _res); \
(data).args [0] = arg1; \
(data).args [1] = arg2; \
(data).args [2] = arg3; \
(data).args [3] = arg4; \
(data).args [4] = arg5; \
(data).args [5] = arg6; \
(data).args [6] = arg7; \
(data).args [7] = arg8; \
interp_entry (&data); \
}
#define ARGLIST0 InterpMethod *rmethod
#define ARGLIST1 gpointer arg1, InterpMethod *rmethod
#define ARGLIST2 gpointer arg1, gpointer arg2, InterpMethod *rmethod
#define ARGLIST3 gpointer arg1, gpointer arg2, gpointer arg3, InterpMethod *rmethod
#define ARGLIST4 gpointer arg1, gpointer arg2, gpointer arg3, gpointer arg4, InterpMethod *rmethod
#define ARGLIST5 gpointer arg1, gpointer arg2, gpointer arg3, gpointer arg4, gpointer arg5, InterpMethod *rmethod
#define ARGLIST6 gpointer arg1, gpointer arg2, gpointer arg3, gpointer arg4, gpointer arg5, gpointer arg6, InterpMethod *rmethod
#define ARGLIST7 gpointer arg1, gpointer arg2, gpointer arg3, gpointer arg4, gpointer arg5, gpointer arg6, gpointer arg7, InterpMethod *rmethod
#define ARGLIST8 gpointer arg1, gpointer arg2, gpointer arg3, gpointer arg4, gpointer arg5, gpointer arg6, gpointer arg7, gpointer arg8, InterpMethod *rmethod
static void interp_entry_static_0 (ARGLIST0) INTERP_ENTRY0 (NULL, NULL, rmethod)
static void interp_entry_static_1 (ARGLIST1) INTERP_ENTRY1 (NULL, NULL, rmethod)
static void interp_entry_static_2 (ARGLIST2) INTERP_ENTRY2 (NULL, NULL, rmethod)
static void interp_entry_static_3 (ARGLIST3) INTERP_ENTRY3 (NULL, NULL, rmethod)
static void interp_entry_static_4 (ARGLIST4) INTERP_ENTRY4 (NULL, NULL, rmethod)
static void interp_entry_static_5 (ARGLIST5) INTERP_ENTRY5 (NULL, NULL, rmethod)
static void interp_entry_static_6 (ARGLIST6) INTERP_ENTRY6 (NULL, NULL, rmethod)
static void interp_entry_static_7 (ARGLIST7) INTERP_ENTRY7 (NULL, NULL, rmethod)
static void interp_entry_static_8 (ARGLIST8) INTERP_ENTRY8 (NULL, NULL, rmethod)
static void interp_entry_static_ret_0 (gpointer res, ARGLIST0) INTERP_ENTRY0 (NULL, res, rmethod)
static void interp_entry_static_ret_1 (gpointer res, ARGLIST1) INTERP_ENTRY1 (NULL, res, rmethod)
static void interp_entry_static_ret_2 (gpointer res, ARGLIST2) INTERP_ENTRY2 (NULL, res, rmethod)
static void interp_entry_static_ret_3 (gpointer res, ARGLIST3) INTERP_ENTRY3 (NULL, res, rmethod)
static void interp_entry_static_ret_4 (gpointer res, ARGLIST4) INTERP_ENTRY4 (NULL, res, rmethod)
static void interp_entry_static_ret_5 (gpointer res, ARGLIST5) INTERP_ENTRY5 (NULL, res, rmethod)
static void interp_entry_static_ret_6 (gpointer res, ARGLIST6) INTERP_ENTRY6 (NULL, res, rmethod)
static void interp_entry_static_ret_7 (gpointer res, ARGLIST7) INTERP_ENTRY7 (NULL, res, rmethod)
static void interp_entry_static_ret_8 (gpointer res, ARGLIST8) INTERP_ENTRY8 (NULL, res, rmethod)
static void interp_entry_instance_0 (gpointer this_arg, ARGLIST0) INTERP_ENTRY0 (this_arg, NULL, rmethod)
static void interp_entry_instance_1 (gpointer this_arg, ARGLIST1) INTERP_ENTRY1 (this_arg, NULL, rmethod)
static void interp_entry_instance_2 (gpointer this_arg, ARGLIST2) INTERP_ENTRY2 (this_arg, NULL, rmethod)
static void interp_entry_instance_3 (gpointer this_arg, ARGLIST3) INTERP_ENTRY3 (this_arg, NULL, rmethod)
static void interp_entry_instance_4 (gpointer this_arg, ARGLIST4) INTERP_ENTRY4 (this_arg, NULL, rmethod)
static void interp_entry_instance_5 (gpointer this_arg, ARGLIST5) INTERP_ENTRY5 (this_arg, NULL, rmethod)
static void interp_entry_instance_6 (gpointer this_arg, ARGLIST6) INTERP_ENTRY6 (this_arg, NULL, rmethod)
static void interp_entry_instance_7 (gpointer this_arg, ARGLIST7) INTERP_ENTRY7 (this_arg, NULL, rmethod)
static void interp_entry_instance_8 (gpointer this_arg, ARGLIST8) INTERP_ENTRY8 (this_arg, NULL, rmethod)
static void interp_entry_instance_ret_0 (gpointer this_arg, gpointer res, ARGLIST0) INTERP_ENTRY0 (this_arg, res, rmethod)
static void interp_entry_instance_ret_1 (gpointer this_arg, gpointer res, ARGLIST1) INTERP_ENTRY1 (this_arg, res, rmethod)
static void interp_entry_instance_ret_2 (gpointer this_arg, gpointer res, ARGLIST2) INTERP_ENTRY2 (this_arg, res, rmethod)
static void interp_entry_instance_ret_3 (gpointer this_arg, gpointer res, ARGLIST3) INTERP_ENTRY3 (this_arg, res, rmethod)
static void interp_entry_instance_ret_4 (gpointer this_arg, gpointer res, ARGLIST4) INTERP_ENTRY4 (this_arg, res, rmethod)
static void interp_entry_instance_ret_5 (gpointer this_arg, gpointer res, ARGLIST5) INTERP_ENTRY5 (this_arg, res, rmethod)
static void interp_entry_instance_ret_6 (gpointer this_arg, gpointer res, ARGLIST6) INTERP_ENTRY6 (this_arg, res, rmethod)
static void interp_entry_instance_ret_7 (gpointer this_arg, gpointer res, ARGLIST7) INTERP_ENTRY7 (this_arg, res, rmethod)
static void interp_entry_instance_ret_8 (gpointer this_arg, gpointer res, ARGLIST8) INTERP_ENTRY8 (this_arg, res, rmethod)
#define INTERP_ENTRY_FUNCLIST(type) (gpointer)interp_entry_ ## type ## _0, (gpointer)interp_entry_ ## type ## _1, (gpointer)interp_entry_ ## type ## _2, (gpointer)interp_entry_ ## type ## _3, (gpointer)interp_entry_ ## type ## _4, (gpointer)interp_entry_ ## type ## _5, (gpointer)interp_entry_ ## type ## _6, (gpointer)interp_entry_ ## type ## _7, (gpointer)interp_entry_ ## type ## _8
static gpointer entry_funcs_static [MAX_INTERP_ENTRY_ARGS + 1] = { INTERP_ENTRY_FUNCLIST (static) };
static gpointer entry_funcs_static_ret [MAX_INTERP_ENTRY_ARGS + 1] = { INTERP_ENTRY_FUNCLIST (static_ret) };
static gpointer entry_funcs_instance [MAX_INTERP_ENTRY_ARGS + 1] = { INTERP_ENTRY_FUNCLIST (instance) };
static gpointer entry_funcs_instance_ret [MAX_INTERP_ENTRY_ARGS + 1] = { INTERP_ENTRY_FUNCLIST (instance_ret) };
/* General version for methods with more than MAX_INTERP_ENTRY_ARGS arguments */
static void
interp_entry_general (gpointer this_arg, gpointer res, gpointer *args, gpointer rmethod)
{
INTERP_ENTRY_BASE ((InterpMethod*)rmethod, this_arg, res);
data.many_args = args;
interp_entry (&data);
}
#ifdef MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE
// Do not inline in case order of frame addresses matters.
static MONO_NEVER_INLINE void
interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untyped)
{
ThreadContext *context;
stackval *sp;
MonoMethod *method;
MonoMethodSignature *sig;
CallContext *ccontext = (CallContext*) ccontext_untyped;
InterpMethod *rmethod = (InterpMethod*) rmethod_untyped;
gpointer orig_domain = NULL, attach_cookie;
int i;
if (rmethod->needs_thread_attach)
orig_domain = mono_threads_attach_coop (mono_domain_get (), &attach_cookie);
context = get_context ();
sp = (stackval*)context->stack_pointer;
method = rmethod->method;
sig = mono_method_signature_internal (method);
if (method->string_ctor) {
MonoMethodSignature *newsig = (MonoMethodSignature*)g_alloca (MONO_SIZEOF_METHOD_SIGNATURE + ((sig->param_count + 2) * sizeof (MonoType*)));
memcpy (newsig, sig, mono_metadata_signature_size (sig));
newsig->ret = m_class_get_byval_arg (mono_defaults.string_class);
sig = newsig;
}
InterpFrame frame = {0};
frame.imethod = rmethod;
frame.stack = sp;
frame.retval = sp;
/* Copy the args saved in the trampoline to the frame stack */
gpointer retp = mono_arch_get_native_call_context_args (ccontext, &frame, sig);
/* Allocate storage for value types */
stackval *newsp = sp;
/* FIXME we should reuse computation on imethod for this */
if (sig->hasthis)
newsp++;
for (i = 0; i < sig->param_count; i++) {
MonoType *type = sig->params [i];
int size;
if (type->type == MONO_TYPE_GENERICINST && !MONO_TYPE_IS_REFERENCE (type)) {
size = mono_class_value_size (mono_class_from_mono_type_internal (type), NULL);
} else if (type->type == MONO_TYPE_VALUETYPE) {
if (sig->pinvoke && !sig->marshalling_disabled)
size = mono_class_native_size (type->data.klass, NULL);
else
size = mono_class_value_size (type->data.klass, NULL);
} else {
size = MINT_STACK_SLOT_SIZE;
}
newsp = STACK_ADD_BYTES (newsp, size);
}
context->stack_pointer = (guchar*)newsp;
g_assert (context->stack_pointer < context->stack_end);
MONO_ENTER_GC_UNSAFE;
interp_exec_method (&frame, context, NULL);
MONO_EXIT_GC_UNSAFE;
context->stack_pointer = (guchar*)sp;
g_assert (!context->has_resume_state);
if (rmethod->needs_thread_attach)
mono_threads_detach_coop (orig_domain, &attach_cookie);
check_pending_unwind (context);
/* Write back the return value */
/* 'frame' is still valid */
mono_arch_set_native_call_context_ret (ccontext, &frame, sig, retp);
}
#else
static void
interp_entry_from_trampoline (gpointer ccontext_untyped, gpointer rmethod_untyped)
{
g_assert_not_reached ();
}
#endif /* MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE */
static void
interp_entry_llvmonly (gpointer res, gpointer *args, gpointer imethod_untyped)
{
InterpMethod *imethod = (InterpMethod*)imethod_untyped;
if (imethod->hasthis)
interp_entry_general (*(gpointer*)(args [0]), res, args + 1, imethod);
else
interp_entry_general (NULL, res, args, imethod);
}
static gpointer
interp_get_interp_method (MonoMethod *method, MonoError *error)
{
return mono_interp_get_imethod (method, error);
}
static MonoJitInfo*
interp_compile_interp_method (MonoMethod *method, MonoError *error)
{
InterpMethod *imethod = mono_interp_get_imethod (method, error);
return_val_if_nok (error, NULL);
if (!imethod->transformed) {
mono_interp_transform_method (imethod, get_context (), error);
return_val_if_nok (error, NULL);
}
return imethod->jinfo;
}
static InterpMethod*
lookup_method_pointer (gpointer addr)
{
InterpMethod *res = NULL;
MonoJitMemoryManager *jit_mm = get_default_jit_mm ();
jit_mm_lock (jit_mm);
if (jit_mm->interp_method_pointer_hash)
res = (InterpMethod*)g_hash_table_lookup (jit_mm->interp_method_pointer_hash, addr);
jit_mm_unlock (jit_mm);
return res;
}
#ifndef MONO_ARCH_HAVE_INTERP_NATIVE_TO_MANAGED
static void
interp_no_native_to_managed (void)
{
g_error ("interpreter: native-to-managed transition not available on this platform");
}
#endif
static void
no_llvmonly_interp_method_pointer (void)
{
g_assert_not_reached ();
}
/*
* interp_create_method_pointer_llvmonly:
*
* Return an ftndesc for entering the interpreter and executing METHOD.
*/
static MonoFtnDesc*
interp_create_method_pointer_llvmonly (MonoMethod *method, gboolean unbox, MonoError *error)
{
gpointer addr, entry_func, entry_wrapper;
MonoMethodSignature *sig;
MonoMethod *wrapper;
InterpMethod *imethod;
imethod = mono_interp_get_imethod (method, error);
return_val_if_nok (error, NULL);
if (unbox) {
if (imethod->llvmonly_unbox_entry)
return (MonoFtnDesc*)imethod->llvmonly_unbox_entry;
} else {
if (imethod->jit_entry)
return (MonoFtnDesc*)imethod->jit_entry;
}
sig = mono_method_signature_internal (method);
/*
* The entry functions need access to the method to call, so we have
* to use a ftndesc. The caller uses a normal signature, while the
* entry functions use a gsharedvt_in signature, so wrap the entry function in
* a gsharedvt_in_sig wrapper.
* We use a gsharedvt_in_sig wrapper instead of an interp_in wrapper, because they
* are mostly the same, and they are already generated. The exception is the
* wrappers for methods with more than 8 arguments, those are different.
*/
if (sig->param_count > MAX_INTERP_ENTRY_ARGS)
wrapper = mini_get_interp_in_wrapper (sig);
else
wrapper = mini_get_gsharedvt_in_sig_wrapper (sig);
entry_wrapper = mono_jit_compile_method_jit_only (wrapper, error);
mono_error_assertf_ok (error, "couldn't compile wrapper \"%s\" for \"%s\"",
mono_method_get_name_full (wrapper, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL),
mono_method_get_name_full (method, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL));
if (sig->param_count > MAX_INTERP_ENTRY_ARGS) {
entry_func = (gpointer)interp_entry_general;
} else if (sig->hasthis) {
if (sig->ret->type == MONO_TYPE_VOID)
entry_func = entry_funcs_instance [sig->param_count];
else
entry_func = entry_funcs_instance_ret [sig->param_count];
} else {
if (sig->ret->type == MONO_TYPE_VOID)
entry_func = entry_funcs_static [sig->param_count];
else
entry_func = entry_funcs_static_ret [sig->param_count];
}
g_assert (entry_func);
/* Encode unbox in the lower bit of imethod */
gpointer entry_arg = imethod;
if (unbox)
entry_arg = (gpointer)(((gsize)entry_arg) | 1);
MonoFtnDesc *entry_ftndesc = mini_llvmonly_create_ftndesc (method, entry_func, entry_arg);
addr = mini_llvmonly_create_ftndesc (method, entry_wrapper, entry_ftndesc);
// FIXME:
MonoJitMemoryManager *jit_mm = get_default_jit_mm ();
jit_mm_lock (jit_mm);
if (!jit_mm->interp_method_pointer_hash)
jit_mm->interp_method_pointer_hash = g_hash_table_new (NULL, NULL);
g_hash_table_insert (jit_mm->interp_method_pointer_hash, addr, imethod);
jit_mm_unlock (jit_mm);
mono_memory_barrier ();
if (unbox)
imethod->llvmonly_unbox_entry = addr;
else
imethod->jit_entry = addr;
return (MonoFtnDesc*)addr;
}
/*
* interp_create_method_pointer:
*
* Return a function pointer which can be used to call METHOD using the
* interpreter. Return NULL for methods which are not supported.
*/
static gpointer
interp_create_method_pointer (MonoMethod *method, gboolean compile, MonoError *error)
{
gpointer addr, entry_func, entry_wrapper = NULL;
InterpMethod *imethod = mono_interp_get_imethod (method, error);
if (imethod->jit_entry)
return imethod->jit_entry;
if (compile && !imethod->transformed) {
/* Return any errors from method compilation */
mono_interp_transform_method (imethod, get_context (), error);
return_val_if_nok (error, NULL);
}
MonoMethodSignature *sig = mono_method_signature_internal (method);
if (method->string_ctor) {
MonoMethodSignature *newsig = (MonoMethodSignature*)g_alloca (MONO_SIZEOF_METHOD_SIGNATURE + ((sig->param_count + 2) * sizeof (MonoType*)));
memcpy (newsig, sig, mono_metadata_signature_size (sig));
newsig->ret = m_class_get_byval_arg (mono_defaults.string_class);
sig = newsig;
}
if (sig->param_count > MAX_INTERP_ENTRY_ARGS) {
entry_func = (gpointer)interp_entry_general;
} else if (sig->hasthis) {
if (sig->ret->type == MONO_TYPE_VOID)
entry_func = entry_funcs_instance [sig->param_count];
else
entry_func = entry_funcs_instance_ret [sig->param_count];
} else {
if (sig->ret->type == MONO_TYPE_VOID)
entry_func = entry_funcs_static [sig->param_count];
else
entry_func = entry_funcs_static_ret [sig->param_count];
}
#ifndef MONO_ARCH_HAVE_INTERP_NATIVE_TO_MANAGED
#ifdef HOST_WASM
if (method->wrapper_type == MONO_WRAPPER_NATIVE_TO_MANAGED) {
WrapperInfo *info = mono_marshal_get_wrapper_info (method);
MonoMethod *orig_method = info->d.native_to_managed.method;
/*
* These are called from native code. Ask the host app for a trampoline.
*/
MonoFtnDesc *ftndesc = g_new0 (MonoFtnDesc, 1);
ftndesc->addr = entry_func;
ftndesc->arg = imethod;
addr = mono_wasm_get_native_to_interp_trampoline (orig_method, ftndesc);
if (addr) {
mono_memory_barrier ();
imethod->jit_entry = addr;
return addr;
}
/*
* The runtime expects a function pointer unique to method and
* the native caller expects a function pointer with the
* right signature, so fail right away.
*/
char *s = mono_method_get_full_name (orig_method);
char *msg = g_strdup_printf ("No native to managed transition for method '%s', missing [UnmanagedCallersOnly] attribute.", s);
mono_error_set_platform_not_supported (error, msg);
g_free (s);
g_free (msg);
return NULL;
}
#endif
return (gpointer)interp_no_native_to_managed;
#endif
if (mono_llvm_only) {
/* The caller should call interp_create_method_pointer_llvmonly */
//g_assert_not_reached ();
return (gpointer)no_llvmonly_interp_method_pointer;
}
if (method->wrapper_type && method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE)
return imethod;
#ifndef MONO_ARCH_HAVE_FTNPTR_ARG_TRAMPOLINE
/*
* Interp in wrappers get the argument in the rgctx register. If
* MONO_ARCH_HAVE_FTNPTR_ARG_TRAMPOLINE is defined it means that
* on that arch the rgctx register is not scratch, so we use a
* separate temp register. We should update the wrappers for this
* if we really care about those architectures (arm).
*/
MonoMethod *wrapper = mini_get_interp_in_wrapper (sig);
entry_wrapper = mono_jit_compile_method_jit_only (wrapper, error);
#endif
if (!entry_wrapper) {
#ifndef MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE
g_assertion_message ("couldn't compile wrapper \"%s\" for \"%s\"",
mono_method_get_name_full (wrapper, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL),
mono_method_get_name_full (method, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL));
#else
mono_interp_error_cleanup (error);
if (!mono_native_to_interp_trampoline) {
if (mono_aot_only) {
mono_native_to_interp_trampoline = (MonoFuncV)mono_aot_get_trampoline ("native_to_interp_trampoline");
} else {
MonoTrampInfo *info;
mono_native_to_interp_trampoline = (MonoFuncV)mono_arch_get_native_to_interp_trampoline (&info);
mono_tramp_info_register (info, NULL);
}
}
entry_wrapper = (gpointer)mono_native_to_interp_trampoline;
/* We need the lmf wrapper only when being called from mixed mode */
if (sig->pinvoke)
entry_func = (gpointer)interp_entry_from_trampoline;
else {
static gpointer cached_func = NULL;
if (!cached_func) {
cached_func = mono_jit_compile_method_jit_only (mini_get_interp_lmf_wrapper ("mono_interp_entry_from_trampoline", (gpointer) mono_interp_entry_from_trampoline), error);
mono_memory_barrier ();
}
entry_func = cached_func;
}
#endif
}
g_assert (entry_func);
/* This is the argument passed to the interp_in wrapper by the static rgctx trampoline */
MonoFtnDesc *ftndesc = g_new0 (MonoFtnDesc, 1);
ftndesc->addr = entry_func;
ftndesc->arg = imethod;
mono_error_assert_ok (error);
/*
* The wrapper is called by compiled code, which doesn't pass the extra argument, so we pass it in the
* rgctx register using a trampoline.
*/
addr = mono_create_ftnptr_arg_trampoline (ftndesc, entry_wrapper);
MonoJitMemoryManager *jit_mm = get_default_jit_mm ();
jit_mm_lock (jit_mm);
if (!jit_mm->interp_method_pointer_hash)
jit_mm->interp_method_pointer_hash = g_hash_table_new (NULL, NULL);
g_hash_table_insert (jit_mm->interp_method_pointer_hash, addr, imethod);
jit_mm_unlock (jit_mm);
mono_memory_barrier ();
imethod->jit_entry = addr;
return addr;
}
static void
interp_free_method (MonoMethod *method)
{
MonoJitMemoryManager *jit_mm = jit_mm_for_method (method);
jit_mm_lock (jit_mm);
/* InterpMethod is allocated in the domain mempool. We might haven't
* allocated an InterpMethod for this instance yet */
mono_internal_hash_table_remove (&jit_mm->interp_code_hash, method);
jit_mm_unlock (jit_mm);
}
#if COUNT_OPS
static long opcode_counts[MINT_LASTOP];
#define COUNT_OP(op) opcode_counts[op]++
#else
#define COUNT_OP(op)
#endif
#if DEBUG_INTERP
#define DUMP_INSTR() \
if (tracing > 1) { \
output_indent (); \
char *mn = mono_method_full_name (frame->imethod->method, FALSE); \
char *disasm = mono_interp_dis_mintop ((gint32)(ip - frame->imethod->code), TRUE, ip + 1, *ip); \
g_print ("(%p) %s -> %s\n", mono_thread_internal_current (), mn, disasm); \
g_free (mn); \
g_free (disasm); \
}
#else
#define DUMP_INSTR()
#endif
static MONO_NEVER_INLINE MonoException*
do_init_vtable (MonoVTable *vtable, MonoError *error, InterpFrame *frame, const guint16 *ip)
{
MonoLMFExt ext;
MonoException *ex = NULL;
/*
* When calling runtime functions we pass the ip of the instruction triggering the runtime call.
* Offset the subtraction from interp_frame_get_ip, so we don't end up in prev instruction.
*/
frame->state.ip = ip + 1;
interp_push_lmf (&ext, frame);
mono_runtime_class_init_full (vtable, error);
if (!is_ok (error))
ex = mono_error_convert_to_exception (error);
interp_pop_lmf (&ext);
return ex;
}
#define INIT_VTABLE(vtable) do { \
if (G_UNLIKELY (!(vtable)->initialized)) { \
MonoException *__init_vtable_ex = do_init_vtable ((vtable), error, frame, ip); \
if (G_UNLIKELY (__init_vtable_ex)) \
THROW_EX (__init_vtable_ex, ip); \
} \
} while (0);
static MonoObject*
mono_interp_new (MonoClass* klass)
{
ERROR_DECL (error);
MonoObject* const object = mono_object_new_checked (klass, error);
mono_error_cleanup (error); // FIXME: do not swallow the error
return object;
}
static gboolean
mono_interp_isinst (MonoObject* object, MonoClass* klass)
{
ERROR_DECL (error);
gboolean isinst;
MonoClass *obj_class = mono_object_class (object);
mono_class_is_assignable_from_checked (klass, obj_class, &isinst, error);
mono_error_cleanup (error); // FIXME: do not swallow the error
return isinst;
}
static MONO_NEVER_INLINE InterpMethod*
mono_interp_get_native_func_wrapper (InterpMethod* imethod, MonoMethodSignature* csignature, guchar* code)
{
ERROR_DECL(error);
/* Pinvoke call is missing the wrapper. See mono_get_native_calli_wrapper */
MonoMarshalSpec** mspecs = g_newa0 (MonoMarshalSpec*, csignature->param_count + 1);
MonoMethodPInvoke iinfo;
memset (&iinfo, 0, sizeof (iinfo));
MonoMethod *method = imethod->method;
MonoImage *image = NULL;
if (imethod->method->dynamic)
image = ((MonoDynamicMethod*)method)->assembly->image;
else
image = m_class_get_image (method->klass);
MonoMethod* m = mono_marshal_get_native_func_wrapper (image, csignature, &iinfo, mspecs, code);
for (int i = csignature->param_count; i >= 0; i--)
if (mspecs [i])
mono_metadata_free_marshal_spec (mspecs [i]);
InterpMethod *cmethod = mono_interp_get_imethod (m, error);
mono_error_cleanup (error); /* FIXME: don't swallow the error */
return cmethod;
}
// Do not inline in case order of frame addresses matters.
static MONO_NEVER_INLINE MonoException*
mono_interp_leave (InterpFrame* parent_frame)
{
InterpFrame frame = {parent_frame};
gboolean gc_transitions = FALSE;
stackval tmp_sp;
/*
* We need for mono_thread_get_undeniable_exception to be able to unwind
* to check the abort threshold. For this to work we use frame as a
* dummy frame that is stored in the lmf and serves as the transition frame
*/
do_icall_wrapper (&frame, NULL, MINT_ICALL_V_P, &tmp_sp, &tmp_sp, (gpointer)mono_thread_get_undeniable_exception, FALSE, &gc_transitions);
return (MonoException*)tmp_sp.data.p;
}
static gint32
mono_interp_enum_hasflag (stackval *sp1, stackval *sp2, MonoClass* klass)
{
guint64 a_val = 0, b_val = 0;
stackval_to_data (m_class_get_byval_arg (klass), sp1, &a_val, FALSE);
stackval_to_data (m_class_get_byval_arg (klass), sp2, &b_val, FALSE);
return (a_val & b_val) == b_val;
}
// varargs in wasm consumes extra linear stack per call-site.
// These g_warning/g_error wrappers fix that. It is not the
// small wasm stack, but conserving it is still desirable.
static void
g_warning_d (const char *format, int d)
{
g_warning (format, d);
}
#if !USE_COMPUTED_GOTO
static void
interp_error_xsx (const char *format, int x1, const char *s, int x2)
{
g_error (format, x1, s, x2);
}
#endif
static MONO_ALWAYS_INLINE gboolean
method_entry (ThreadContext *context, InterpFrame *frame,
#if DEBUG_INTERP
int *out_tracing,
#endif
MonoException **out_ex)
{
gboolean slow = FALSE;
#if DEBUG_INTERP
debug_enter (frame, out_tracing);
#endif
#if PROFILE_INTERP
frame->imethod->calls++;
#endif
*out_ex = NULL;
if (!G_UNLIKELY (frame->imethod->transformed)) {
slow = TRUE;
MonoException *ex = do_transform_method (frame->imethod, frame, context);
if (ex) {
*out_ex = ex;
/*
* Initialize the stack base pointer here, in the uncommon branch, so we don't
* need to check for it everytime when exitting a frame.
*/
frame->stack = (stackval*)context->stack_pointer;
return slow;
}
}
return slow;
}
/* Save the state of the interpeter main loop into FRAME */
#define SAVE_INTERP_STATE(frame) do { \
frame->state.ip = ip; \
} while (0)
/* Load and clear state from FRAME */
#define LOAD_INTERP_STATE(frame) do { \
ip = frame->state.ip; \
locals = (unsigned char *)frame->stack; \
frame->state.ip = NULL; \
} while (0)
/* Initialize interpreter state for executing FRAME */
#define INIT_INTERP_STATE(frame, _clause_args) do { \
ip = _clause_args ? ((FrameClauseArgs *)_clause_args)->start_with_ip : (frame)->imethod->code; \
locals = (unsigned char *)(frame)->stack; \
} while (0)
#if PROFILE_INTERP
static long total_executed_opcodes;
#endif
#define LOCAL_VAR(offset,type) (*(type*)(locals + (offset)))
/*
* If CLAUSE_ARGS is non-null, start executing from it.
* The ERROR argument is used to avoid declaring an error object for every interp frame, its not used
* to return error information.
* FRAME is only valid until the next call to alloc_frame ().
*/
static MONO_NEVER_INLINE void
interp_exec_method (InterpFrame *frame, ThreadContext *context, FrameClauseArgs *clause_args)
{
InterpMethod *cmethod;
MonoException *ex;
ERROR_DECL(error);
/* Interpreter main loop state (InterpState) */
const guint16 *ip = NULL;
unsigned char *locals = NULL;
int call_args_offset;
int return_offset;
gboolean gc_transitions = FALSE;
#if DEBUG_INTERP
int tracing = global_tracing;
#endif
#if USE_COMPUTED_GOTO
static void * const in_labels[] = {
#define OPDEF(a,b,c,d,e,f) &&LAB_ ## a,
#include "mintops.def"
};
#endif
HANDLE_FUNCTION_ENTER ();
/*
* GC SAFETY:
*
* The interpreter executes in gc unsafe (non-preempt) mode. On wasm, we cannot rely on
* scanning the stack or any registers. In order to make the code GC safe, every objref
* handled by the code needs to be kept alive and pinned in any of the following ways:
* - the object needs to be stored on the interpreter stack. In order to make sure the
* object actually gets stored on the interp stack and the store is not optimized out,
* the store/variable should be volatile.
* - if the execution of an opcode requires an object not coming from interp stack to be
* kept alive, the tmp_handle below can be used. This handle will keep only one object
* pinned by the GC. Ideally, once this object is no longer needed, the handle should be
* cleared. If we will need to have more objects pinned simultaneously, additional handles
* can be reserved here.
*/
MonoObjectHandle tmp_handle = MONO_HANDLE_NEW (MonoObject, NULL);
if (method_entry (context, frame,
#if DEBUG_INTERP
&tracing,
#endif
&ex)) {
if (ex)
THROW_EX (ex, NULL);
EXCEPTION_CHECKPOINT;
}
if (!clause_args) {
context->stack_pointer = (guchar*)frame->stack + frame->imethod->alloca_size;
g_assert (context->stack_pointer < context->stack_end);
/* Make sure the stack pointer is bumped before we store any references on the stack */
mono_compiler_barrier ();
}
INIT_INTERP_STATE (frame, clause_args);
#ifdef ENABLE_EXPERIMENT_TIERED
mini_tiered_inc (frame->imethod->method, &frame->imethod->tiered_counter, 0);
#endif
//g_print ("(%p) Call %s\n", mono_thread_internal_current (), mono_method_get_full_name (frame->imethod->method));
#if defined(ENABLE_HYBRID_SUSPEND) || defined(ENABLE_COOP_SUSPEND)
mono_threads_safepoint ();
#endif
main_loop:
/*
* using while (ip < end) may result in a 15% performance drop,
* but it may be useful for debug
*/
while (1) {
#if PROFILE_INTERP
frame->imethod->opcounts++;
total_executed_opcodes++;
#endif
MintOpcode opcode;
DUMP_INSTR();
MINT_IN_SWITCH (*ip) {
MINT_IN_CASE(MINT_INITLOCAL)
MINT_IN_CASE(MINT_INITLOCALS)
memset (locals + ip [1], 0, ip [2]);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NOP)
MINT_IN_CASE(MINT_IL_SEQ_POINT)
MINT_IN_CASE(MINT_NIY)
MINT_IN_CASE(MINT_DEF)
MINT_IN_CASE(MINT_DUMMY_USE)
g_assert_not_reached ();
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BREAK)
++ip;
SAVE_INTERP_STATE (frame);
do_debugger_tramp (mono_component_debugger ()->user_break, frame);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BREAKPOINT)
++ip;
mono_break ();
MINT_IN_BREAK;
MINT_IN_CASE(MINT_INIT_ARGLIST) {
const guint16 *call_ip = frame->parent->state.ip - 6;
g_assert_checked (*call_ip == MINT_CALL_VARARG);
int params_stack_size = call_ip [5];
MonoMethodSignature *sig = (MonoMethodSignature*)frame->parent->imethod->data_items [call_ip [4]];
// we are being overly conservative with the size here, for simplicity
gpointer arglist = frame_data_allocator_alloc (&context->data_stack, frame, params_stack_size + MINT_STACK_SLOT_SIZE);
init_arglist (frame, sig, STACK_ADD_BYTES (frame->stack, ip [2]), (char*)arglist);
// save the arglist for future access with MINT_ARGLIST
LOCAL_VAR (ip [1], gpointer) = arglist;
ip += 3;
MINT_IN_BREAK;
}
#define LDC(n) do { LOCAL_VAR (ip [1], gint32) = (n); ip += 2; } while (0)
MINT_IN_CASE(MINT_LDC_I4_M1)
LDC(-1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_0)
LDC(0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_1)
LDC(1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_2)
LDC(2);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_3)
LDC(3);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_4)
LDC(4);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_5)
LDC(5);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_6)
LDC(6);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_7)
LDC(7);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_8)
LDC(8);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4_S)
LOCAL_VAR (ip [1], gint32) = (short)ip [2];
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I4)
LOCAL_VAR (ip [1], gint32) = READ32 (ip + 2);
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I8_0)
LOCAL_VAR (ip [1], gint64) = 0;
ip += 2;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I8)
LOCAL_VAR (ip [1], gint64) = READ64 (ip + 2);
ip += 6;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_I8_S)
LOCAL_VAR (ip [1], gint64) = (short)ip [2];
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDC_R4) {
LOCAL_VAR (ip [1], gint32) = READ32(ip + 2); /* not union usage */
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDC_R8)
LOCAL_VAR (ip [1], gint64) = READ64 (ip + 2); /* note union usage */
ip += 6;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_TAILCALL)
MINT_IN_CASE(MINT_TAILCALL_VIRT)
MINT_IN_CASE(MINT_JMP) {
gboolean is_tailcall = *ip != MINT_JMP;
InterpMethod *new_method;
if (is_tailcall) {
guint16 params_offset = ip [1];
guint16 params_size = ip [3];
// Copy the params to their location at the start of the frame
memmove (frame->stack, (guchar*)frame->stack + params_offset, params_size);
new_method = (InterpMethod*)frame->imethod->data_items [ip [2]];
if (*ip == MINT_TAILCALL_VIRT) {
gint16 slot = (gint16)ip [4];
MonoObject *this_arg = LOCAL_VAR (0, MonoObject*);
new_method = get_virtual_method_fast (new_method, this_arg->vtable, slot);
if (m_class_is_valuetype (this_arg->vtable->klass) && m_class_is_valuetype (new_method->method->klass)) {
/* unbox */
gpointer unboxed = mono_object_unbox_internal (this_arg);
LOCAL_VAR (0, gpointer) = unboxed;
}
}
} else {
new_method = (InterpMethod*)frame->imethod->data_items [ip [1]];
}
if (frame->imethod->prof_flags & MONO_PROFILER_CALL_INSTRUMENTATION_TAIL_CALL)
MONO_PROFILER_RAISE (method_tail_call, (frame->imethod->method, new_method->method));
if (!new_method->transformed) {
MonoException *ex = do_transform_method (new_method, frame, context);
if (ex)
THROW_EX (ex, ip);
EXCEPTION_CHECKPOINT;
}
/*
* It's possible for the caller stack frame to be smaller
* than the callee stack frame (at the interp level)
*/
context->stack_pointer = (guchar*)frame->stack + new_method->alloca_size;
if (G_UNLIKELY (context->stack_pointer >= context->stack_end)) {
context->stack_end = context->stack_real_end;
THROW_EX (mono_domain_get ()->stack_overflow_ex, ip);
}
frame->imethod = new_method;
ip = frame->imethod->code;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CALL_DELEGATE) {
// FIXME We don't need to encode the whole signature, just param_count
MonoMethodSignature *csignature = (MonoMethodSignature*)frame->imethod->data_items [ip [4]];
int param_count = csignature->param_count;
return_offset = ip [1];
call_args_offset = ip [2];
MonoDelegate *del = LOCAL_VAR (call_args_offset, MonoDelegate*);
gboolean is_multicast = del->method == NULL;
InterpMethod *del_imethod = (InterpMethod*)del->interp_invoke_impl;
if (!del_imethod) {
// FIXME push/pop LMF
if (is_multicast) {
error_init_reuse (error);
MonoMethod *invoke = mono_get_delegate_invoke_internal (del->object.vtable->klass);
del_imethod = mono_interp_get_imethod (mono_marshal_get_delegate_invoke (invoke, del), error);
del->interp_invoke_impl = del_imethod;
mono_error_assert_ok (error);
} else if (!del->interp_method) {
// Not created from interpreted code
error_init_reuse (error);
g_assert (del->method);
del_imethod = mono_interp_get_imethod (del->method, error);
del->interp_method = del_imethod;
del->interp_invoke_impl = del_imethod;
mono_error_assert_ok (error);
} else {
del_imethod = (InterpMethod*)del->interp_method;
if (del_imethod->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
error_init_reuse (error);
del_imethod = mono_interp_get_imethod (mono_marshal_get_native_wrapper (del_imethod->method, FALSE, FALSE), error);
mono_error_assert_ok (error);
del->interp_invoke_impl = del_imethod;
} else if (del_imethod->method->flags & METHOD_ATTRIBUTE_VIRTUAL && !del->target && !m_class_is_valuetype (del_imethod->method->klass)) {
// 'this' is passed dynamically, we need to recompute the target method
// with each call
del_imethod = get_virtual_method (del_imethod, LOCAL_VAR (call_args_offset + MINT_STACK_SLOT_SIZE, MonoObject*)->vtable);
} else {
del->interp_invoke_impl = del_imethod;
}
}
}
cmethod = del_imethod;
if (!is_multicast) {
if (cmethod->param_count == param_count + 1) {
// Target method is static but the delegate has a target object. We handle
// this separately from the case below, because, for these calls, the instance
// is allowed to be null.
LOCAL_VAR (call_args_offset, MonoObject*) = del->target;
} else if (del->target) {
MonoObject *this_arg = del->target;
// replace the MonoDelegate* on the stack with 'this' pointer
if (m_class_is_valuetype (this_arg->vtable->klass) && m_class_is_valuetype (cmethod->method->klass)) {
gpointer unboxed = mono_object_unbox_internal (this_arg);
LOCAL_VAR (call_args_offset, gpointer) = unboxed;
} else {
LOCAL_VAR (call_args_offset, MonoObject*) = this_arg;
}
} else {
// skip the delegate pointer for static calls
// FIXME we could avoid memmove
memmove (locals + call_args_offset, locals + call_args_offset + MINT_STACK_SLOT_SIZE, ip [3]);
}
}
ip += 5;
goto call;
}
MINT_IN_CASE(MINT_CALLI) {
gboolean need_unbox;
/* In mixed mode, stay in the interpreter for simplicity even if there is an AOT version of the callee */
cmethod = ftnptr_to_imethod (LOCAL_VAR (ip [2], gpointer), &need_unbox);
if (cmethod->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
// FIXME push/pop LMF
cmethod = mono_interp_get_imethod (mono_marshal_get_native_wrapper (cmethod->method, FALSE, FALSE), error);
mono_interp_error_cleanup (error); /* FIXME: don't swallow the error */
}
return_offset = ip [1];
call_args_offset = ip [3];
if (need_unbox) {
MonoObject *this_arg = LOCAL_VAR (call_args_offset, MonoObject*);
LOCAL_VAR (call_args_offset, gpointer) = mono_object_unbox_internal (this_arg);
}
ip += 4;
goto call;
}
MINT_IN_CASE(MINT_CALLI_NAT_FAST) {
MonoMethodSignature *csignature = (MonoMethodSignature*)frame->imethod->data_items [ip [4]];
int opcode = ip [5];
gboolean save_last_error = ip [6];
stackval *ret = (stackval*)(locals + ip [1]);
gpointer target_ip = LOCAL_VAR (ip [2], gpointer);
stackval *args = (stackval*)(locals + ip [3]);
/* for calls, have ip pointing at the start of next instruction */
frame->state.ip = ip + 7;
do_icall_wrapper (frame, csignature, opcode, ret, args, target_ip, save_last_error, &gc_transitions);
EXCEPTION_CHECKPOINT;
CHECK_RESUME_STATE (context);
ip += 7;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CALLI_NAT_DYNAMIC) {
MonoMethodSignature* csignature = (MonoMethodSignature*)frame->imethod->data_items [ip [4]];
return_offset = ip [1];
guchar* code = LOCAL_VAR (ip [2], guchar*);
call_args_offset = ip [3];
// FIXME push/pop LMF
cmethod = mono_interp_get_native_func_wrapper (frame->imethod, csignature, code);
ip += 5;
goto call;
}
MINT_IN_CASE(MINT_CALLI_NAT) {
MonoMethodSignature *csignature = (MonoMethodSignature*)frame->imethod->data_items [ip [4]];
InterpMethod *imethod = (InterpMethod*)frame->imethod->data_items [ip [5]];
guchar *code = LOCAL_VAR (ip [2], guchar*);
gboolean save_last_error = ip [6];
gpointer *cache = (gpointer*)&frame->imethod->data_items [ip [7]];
/* for calls, have ip pointing at the start of next instruction */
frame->state.ip = ip + 8;
ves_pinvoke_method (imethod, csignature, (MonoFuncV)code, context, frame, (stackval*)(locals + ip [1]), (stackval*)(locals + ip [3]), save_last_error, cache, &gc_transitions);
EXCEPTION_CHECKPOINT;
CHECK_RESUME_STATE (context);
ip += 8;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CALLVIRT_FAST) {
MonoObject *this_arg;
int slot;
cmethod = (InterpMethod*)frame->imethod->data_items [ip [3]];
return_offset = ip [1];
call_args_offset = ip [2];
this_arg = LOCAL_VAR (call_args_offset, MonoObject*);
slot = (gint16)ip [4];
ip += 5;
// FIXME push/pop LMF
cmethod = get_virtual_method_fast (cmethod, this_arg->vtable, slot);
if (m_class_is_valuetype (this_arg->vtable->klass) && m_class_is_valuetype (cmethod->method->klass)) {
/* unbox */
gpointer unboxed = mono_object_unbox_internal (this_arg);
LOCAL_VAR (call_args_offset, gpointer) = unboxed;
}
InterpMethodCodeType code_type = cmethod->code_type;
g_assert (code_type == IMETHOD_CODE_UNKNOWN ||
code_type == IMETHOD_CODE_INTERP ||
code_type == IMETHOD_CODE_COMPILED);
if (G_UNLIKELY (code_type == IMETHOD_CODE_UNKNOWN)) {
// FIXME push/pop LMF
MonoMethodSignature *sig = mono_method_signature_internal (cmethod->method);
if (mono_interp_jit_call_supported (cmethod->method, sig))
code_type = IMETHOD_CODE_COMPILED;
else
code_type = IMETHOD_CODE_INTERP;
cmethod->code_type = code_type;
}
if (code_type == IMETHOD_CODE_INTERP) {
goto call;
} else if (code_type == IMETHOD_CODE_COMPILED) {
frame->state.ip = ip;
error_init_reuse (error);
do_jit_call (context, (stackval*)(locals + return_offset), (stackval*)(locals + call_args_offset), frame, cmethod, error);
if (!is_ok (error)) {
MonoException *ex = interp_error_convert_to_exception (frame, error, ip);
THROW_EX (ex, ip);
}
CHECK_RESUME_STATE (context);
}
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CALL_VARARG) {
// Same as MINT_CALL, except at ip [4] we have the index for the csignature,
// which is required by the called method to set up the arglist.
cmethod = (InterpMethod*)frame->imethod->data_items [ip [3]];
return_offset = ip [1];
call_args_offset = ip [2];
ip += 6;
goto call;
}
MINT_IN_CASE(MINT_CALLVIRT) {
// FIXME CALLVIRT opcodes are not used on netcore. We should kill them.
cmethod = (InterpMethod*)frame->imethod->data_items [ip [3]];
return_offset = ip [1];
call_args_offset = ip [2];
MonoObject *this_arg = LOCAL_VAR (call_args_offset, MonoObject*);
// FIXME push/pop LMF
cmethod = get_virtual_method (cmethod, this_arg->vtable);
if (m_class_is_valuetype (this_arg->vtable->klass) && m_class_is_valuetype (cmethod->method->klass)) {
/* unbox */
gpointer unboxed = mono_object_unbox_internal (this_arg);
LOCAL_VAR (call_args_offset, gpointer) = unboxed;
}
#ifdef ENABLE_EXPERIMENT_TIERED
ip += 5;
#else
ip += 4;
#endif
goto call;
}
MINT_IN_CASE(MINT_CALL) {
cmethod = (InterpMethod*)frame->imethod->data_items [ip [3]];
return_offset = ip [1];
call_args_offset = ip [2];
#ifdef ENABLE_EXPERIMENT_TIERED
ip += 5;
#else
ip += 4;
#endif
call:
/*
* Make a non-recursive call by loading the new interpreter state based on child frame,
* and going back to the main loop.
*/
SAVE_INTERP_STATE (frame);
// Allocate child frame.
// FIXME: Add stack overflow checks
{
InterpFrame *child_frame = frame->next_free;
if (!child_frame) {
child_frame = g_newa0 (InterpFrame, 1);
// Not free currently, but will be when allocation attempted.
frame->next_free = child_frame;
}
reinit_frame (child_frame, frame, cmethod, locals + return_offset, locals + call_args_offset);
frame = child_frame;
}
if (method_entry (context, frame,
#if DEBUG_INTERP
&tracing,
#endif
&ex)) {
if (ex)
THROW_EX (ex, NULL);
EXCEPTION_CHECKPOINT;
}
context->stack_pointer = (guchar*)frame->stack + cmethod->alloca_size;
if (G_UNLIKELY (context->stack_pointer >= context->stack_end)) {
context->stack_end = context->stack_real_end;
THROW_EX (mono_domain_get ()->stack_overflow_ex, ip);
}
/* Make sure the stack pointer is bumped before we store any references on the stack */
mono_compiler_barrier ();
INIT_INTERP_STATE (frame, NULL);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_JIT_CALL) {
InterpMethod *rmethod = (InterpMethod*)frame->imethod->data_items [ip [3]];
error_init_reuse (error);
/* for calls, have ip pointing at the start of next instruction */
frame->state.ip = ip + 4;
do_jit_call (context, (stackval*)(locals + ip [1]), (stackval*)(locals + ip [2]), frame, rmethod, error);
if (!is_ok (error)) {
MonoException *ex = interp_error_convert_to_exception (frame, error, ip);
THROW_EX (ex, ip);
}
CHECK_RESUME_STATE (context);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_JIT_CALL2) {
#ifdef ENABLE_EXPERIMENT_TIERED
InterpMethod *rmethod = (InterpMethod *) READ64 (ip + 2);
error_init_reuse (error);
frame->state.ip = ip + 6;
do_jit_call (context, (stackval*)(locals + ip [1]), frame, rmethod, error);
if (!is_ok (error)) {
MonoException *ex = interp_error_convert_to_exception (frame, error);
THROW_EX (ex, ip);
}
CHECK_RESUME_STATE (context);
ip += 6;
#else
g_error ("MINT_JIT_ICALL2 shouldn't be used");
#endif
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CALLRUN) {
g_assert_not_reached ();
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_RET)
frame->retval [0] = LOCAL_VAR (ip [1], stackval);
goto exit_frame;
MINT_IN_CASE(MINT_RET_I4_IMM)
frame->retval [0].data.i = (gint16)ip [1];
goto exit_frame;
MINT_IN_CASE(MINT_RET_I8_IMM)
frame->retval [0].data.l = (gint16)ip [1];
goto exit_frame;
MINT_IN_CASE(MINT_RET_VOID)
goto exit_frame;
MINT_IN_CASE(MINT_RET_VT) {
memmove (frame->retval, locals + ip [1], ip [2]);
goto exit_frame;
}
MINT_IN_CASE(MINT_RET_LOCALLOC)
frame->retval [0] = LOCAL_VAR (ip [1], stackval);
frame_data_allocator_pop (&context->data_stack, frame);
goto exit_frame;
MINT_IN_CASE(MINT_RET_VOID_LOCALLOC)
frame_data_allocator_pop (&context->data_stack, frame);
goto exit_frame;
MINT_IN_CASE(MINT_RET_VT_LOCALLOC) {
memmove (frame->retval, locals + ip [1], ip [2]);
frame_data_allocator_pop (&context->data_stack, frame);
goto exit_frame;
}
#ifdef ENABLE_EXPERIMENT_TIERED
#define BACK_BRANCH_PROFILE(offset) do { \
if (offset < 0) \
mini_tiered_inc (frame->imethod->method, &frame->imethod->tiered_counter, 0); \
} while (0);
#else
#define BACK_BRANCH_PROFILE(offset)
#endif
MINT_IN_CASE(MINT_BR_S) {
short br_offset = (short) *(ip + 1);
BACK_BRANCH_PROFILE (br_offset);
ip += br_offset;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BR) {
gint32 br_offset = (gint32) READ32(ip + 1);
BACK_BRANCH_PROFILE (br_offset);
ip += br_offset;
MINT_IN_BREAK;
}
#define ZEROP_S(datatype, op) \
if (LOCAL_VAR (ip [1], datatype) op 0) { \
gint16 br_offset = (gint16) ip [2]; \
BACK_BRANCH_PROFILE (br_offset); \
ip += br_offset; \
} else \
ip += 3;
#define ZEROP(datatype, op) \
if (LOCAL_VAR (ip [1], datatype) op 0) { \
gint32 br_offset = (gint32)READ32(ip + 2); \
BACK_BRANCH_PROFILE (br_offset); \
ip += br_offset; \
} else \
ip += 4;
MINT_IN_CASE(MINT_BRFALSE_I4_S)
ZEROP_S(gint32, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_I8_S)
ZEROP_S(gint64, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_R4_S)
ZEROP_S(float, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_R8_S)
ZEROP_S(double, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_I4)
ZEROP(gint32, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_I8)
ZEROP(gint64, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_R4)
ZEROP_S(float, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_R8)
ZEROP_S(double, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_I4_S)
ZEROP_S(gint32, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_I8_S)
ZEROP_S(gint64, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_R4_S)
ZEROP_S(float, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_R8_S)
ZEROP_S(double, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_I4)
ZEROP(gint32, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_I8)
ZEROP(gint64, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_R4)
ZEROP(float, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_R8)
ZEROP(double, !=);
MINT_IN_BREAK;
#define CONDBR_S(cond) \
if (cond) { \
gint16 br_offset = (gint16) ip [3]; \
BACK_BRANCH_PROFILE (br_offset); \
ip += br_offset; \
} else \
ip += 4;
#define BRELOP_S(datatype, op) \
CONDBR_S(LOCAL_VAR (ip [1], datatype) op LOCAL_VAR (ip [2], datatype))
#define CONDBR(cond) \
if (cond) { \
gint32 br_offset = (gint32) READ32 (ip + 3); \
BACK_BRANCH_PROFILE (br_offset); \
ip += br_offset; \
} else \
ip += 5;
#define BRELOP(datatype, op) \
CONDBR(LOCAL_VAR (ip [1], datatype) op LOCAL_VAR (ip [2], datatype))
MINT_IN_CASE(MINT_BEQ_I4_S)
BRELOP_S(gint32, ==)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BEQ_I8_S)
BRELOP_S(gint64, ==)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BEQ_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(!isunordered (f1, f2) && f1 == f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BEQ_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(!mono_isunordered (d1, d2) && d1 == d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BEQ_I4)
BRELOP(gint32, ==)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BEQ_I8)
BRELOP(gint64, ==)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BEQ_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(!isunordered (f1, f2) && f1 == f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BEQ_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(!mono_isunordered (d1, d2) && d1 == d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_I4_S)
BRELOP_S(gint32, >=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_I8_S)
BRELOP_S(gint64, >=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(!isunordered (f1, f2) && f1 >= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(!mono_isunordered (d1, d2) && d1 >= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_I4)
BRELOP(gint32, >=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_I8)
BRELOP(gint64, >=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(!isunordered (f1, f2) && f1 >= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(!mono_isunordered (d1, d2) && d1 >= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_I4_S)
BRELOP_S(gint32, >)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_I8_S)
BRELOP_S(gint64, >)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(!isunordered (f1, f2) && f1 > f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(!mono_isunordered (d1, d2) && d1 > d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_I4)
BRELOP(gint32, >)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_I8)
BRELOP(gint64, >)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(!isunordered (f1, f2) && f1 > f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(!mono_isunordered (d1, d2) && d1 > d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_I4_S)
BRELOP_S(gint32, <)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_I8_S)
BRELOP_S(gint64, <)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(!isunordered (f1, f2) && f1 < f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(!mono_isunordered (d1, d2) && d1 < d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_I4)
BRELOP(gint32, <)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_I8)
BRELOP(gint64, <)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(!isunordered (f1, f2) && f1 < f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(!mono_isunordered (d1, d2) && d1 < d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_I4_S)
BRELOP_S(gint32, <=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_I8_S)
BRELOP_S(gint64, <=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(!isunordered (f1, f2) && f1 <= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(!mono_isunordered (d1, d2) && d1 <= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_I4)
BRELOP(gint32, <=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_I8)
BRELOP(gint64, <=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(!isunordered (f1, f2) && f1 <= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(!mono_isunordered (d1, d2) && d1 <= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BNE_UN_I4_S)
BRELOP_S(gint32, !=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_I8_S)
BRELOP_S(gint64, !=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(isunordered (f1, f2) || f1 != f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BNE_UN_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(mono_isunordered (d1, d2) || d1 != d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BNE_UN_I4)
BRELOP(gint32, !=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_I8)
BRELOP(gint64, !=)
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(isunordered (f1, f2) || f1 != f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BNE_UN_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(mono_isunordered (d1, d2) || d1 != d2)
MINT_IN_BREAK;
}
#define BRELOP_S_CAST(datatype, op) \
if (LOCAL_VAR (ip [1], datatype) op LOCAL_VAR (ip [2], datatype)) { \
gint16 br_offset = (gint16) ip [3]; \
BACK_BRANCH_PROFILE (br_offset); \
ip += br_offset; \
} else \
ip += 4;
#define BRELOP_CAST(datatype, op) \
if (LOCAL_VAR (ip [1], datatype) op LOCAL_VAR (ip [2], datatype)) { \
gint32 br_offset = (gint32)READ32(ip + 3); \
BACK_BRANCH_PROFILE (br_offset); \
ip += br_offset; \
} else \
ip += 5;
MINT_IN_CASE(MINT_BGE_UN_I4_S)
BRELOP_S_CAST(guint32, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_I8_S)
BRELOP_S_CAST(guint64, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(isunordered (f1, f2) || f1 >= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_UN_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(mono_isunordered (d1, d2) || d1 >= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_UN_I4)
BRELOP_CAST(guint32, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_I8)
BRELOP_CAST(guint64, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(isunordered (f1, f2) || f1 >= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGE_UN_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(mono_isunordered (d1, d2) || d1 >= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_UN_I4_S)
BRELOP_S_CAST(guint32, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_I8_S)
BRELOP_S_CAST(guint64, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(isunordered (f1, f2) || f1 > f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_UN_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(mono_isunordered (d1, d2) || d1 > d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_UN_I4)
BRELOP_CAST(guint32, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_I8)
BRELOP_CAST(guint64, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(isunordered (f1, f2) || f1 > f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BGT_UN_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(mono_isunordered (d1, d2) || d1 > d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_UN_I4_S)
BRELOP_S_CAST(guint32, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_I8_S)
BRELOP_S_CAST(guint64, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(isunordered (f1, f2) || f1 <= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_UN_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(mono_isunordered (d1, d2) || d1 <= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_UN_I4)
BRELOP_CAST(guint32, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_I8)
BRELOP_CAST(guint64, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(isunordered (f1, f2) || f1 <= f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLE_UN_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(mono_isunordered (d1, d2) || d1 <= d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_UN_I4_S)
BRELOP_S_CAST(guint32, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_I8_S)
BRELOP_S_CAST(guint64, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_R4_S) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR_S(isunordered (f1, f2) || f1 < f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_UN_R8_S) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR_S(mono_isunordered (d1, d2) || d1 < d2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_UN_I4)
BRELOP_CAST(guint32, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_I8)
BRELOP_CAST(guint64, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_R4) {
float f1 = LOCAL_VAR (ip [1], float);
float f2 = LOCAL_VAR (ip [2], float);
CONDBR(isunordered (f1, f2) || f1 < f2)
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BLT_UN_R8) {
double d1 = LOCAL_VAR (ip [1], double);
double d2 = LOCAL_VAR (ip [2], double);
CONDBR(mono_isunordered (d1, d2) || d1 < d2)
MINT_IN_BREAK;
}
#define ZEROP_SP(datatype, op) \
if (LOCAL_VAR (ip [1], datatype) op 0) { \
gint16 br_offset = (gint16) ip [2]; \
BACK_BRANCH_PROFILE (br_offset); \
SAFEPOINT; \
ip += br_offset; \
} else \
ip += 3;
MINT_IN_CASE(MINT_BRFALSE_I4_SP) ZEROP_SP(gint32, ==); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRFALSE_I8_SP) ZEROP_SP(gint64, ==); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_I4_SP) ZEROP_SP(gint32, !=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK;
#define CONDBR_SP(cond) \
if (cond) { \
gint16 br_offset = (gint16) ip [3]; \
BACK_BRANCH_PROFILE (br_offset); \
SAFEPOINT; \
ip += br_offset; \
} else \
ip += 4;
#define BRELOP_SP(datatype, op) \
CONDBR_SP(LOCAL_VAR (ip [1], datatype) op LOCAL_VAR (ip [2], datatype))
MINT_IN_CASE(MINT_BEQ_I4_SP) BRELOP_SP(gint32, ==); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BEQ_I8_SP) BRELOP_SP(gint64, ==); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_I4_SP) BRELOP_SP(gint32, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_I8_SP) BRELOP_SP(gint64, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_I4_SP) BRELOP_SP(gint32, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_I8_SP) BRELOP_SP(gint64, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_I4_SP) BRELOP_SP(gint32, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_I8_SP) BRELOP_SP(gint64, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_I4_SP) BRELOP_SP(gint32, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_I8_SP) BRELOP_SP(gint64, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_I4_SP) BRELOP_SP(guint32, !=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_I8_SP) BRELOP_SP(guint64, !=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_I4_SP) BRELOP_SP(guint32, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_I8_SP) BRELOP_SP(guint64, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_I4_SP) BRELOP_SP(guint32, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_I8_SP) BRELOP_SP(guint64, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_I4_SP) BRELOP_SP(guint32, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_I8_SP) BRELOP_SP(guint64, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_I4_SP) BRELOP_SP(guint32, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_I8_SP) BRELOP_SP(guint64, <); MINT_IN_BREAK;
#define BRELOP_IMM_SP(datatype, op) \
CONDBR_SP(LOCAL_VAR (ip [1], datatype) op (datatype)(gint16)ip [2])
MINT_IN_CASE(MINT_BEQ_I4_IMM_SP) BRELOP_IMM_SP(gint32, ==); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BEQ_I8_IMM_SP) BRELOP_IMM_SP(gint64, ==); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_I4_IMM_SP) BRELOP_IMM_SP(gint32, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_I8_IMM_SP) BRELOP_IMM_SP(gint64, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_I4_IMM_SP) BRELOP_IMM_SP(gint32, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_I8_IMM_SP) BRELOP_IMM_SP(gint64, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_I4_IMM_SP) BRELOP_IMM_SP(gint32, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_I8_IMM_SP) BRELOP_IMM_SP(gint64, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_I4_IMM_SP) BRELOP_IMM_SP(gint32, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_I8_IMM_SP) BRELOP_IMM_SP(gint64, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_I4_IMM_SP) BRELOP_IMM_SP(guint32, !=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BNE_UN_I8_IMM_SP) BRELOP_IMM_SP(guint64, !=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_I4_IMM_SP) BRELOP_IMM_SP(guint32, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGE_UN_I8_IMM_SP) BRELOP_IMM_SP(guint64, >=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_I4_IMM_SP) BRELOP_IMM_SP(guint32, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BGT_UN_I8_IMM_SP) BRELOP_IMM_SP(guint64, >); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_I4_IMM_SP) BRELOP_IMM_SP(guint32, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLE_UN_I8_IMM_SP) BRELOP_IMM_SP(guint64, <=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_I4_IMM_SP) BRELOP_IMM_SP(guint32, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_BLT_UN_I8_IMM_SP) BRELOP_IMM_SP(guint64, <); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SWITCH) {
guint32 val = LOCAL_VAR (ip [1], guint32);
guint32 n = READ32 (ip + 2);
ip += 4;
if (val < n) {
ip += 2 * val;
int offset = READ32 (ip);
ip += offset;
} else {
ip += 2 * n;
}
MINT_IN_BREAK;
}
#define LDIND(datatype,casttype,unaligned) do { \
gpointer ptr = LOCAL_VAR (ip [2], gpointer); \
NULL_CHECK (ptr); \
if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \
memcpy (locals + ip [1], ptr, sizeof (datatype)); \
else \
LOCAL_VAR (ip [1], datatype) = *(casttype*)ptr; \
ip += 3; \
} while (0)
MINT_IN_CASE(MINT_LDIND_I1)
LDIND(int, gint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_U1)
LDIND(int, guint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_I2)
LDIND(int, gint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_U2)
LDIND(int, guint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_I4) {
LDIND(int, gint32, FALSE);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDIND_I8)
#ifdef NO_UNALIGNED_ACCESS
LDIND(gint64, gint64, TRUE);
#else
LDIND(gint64, gint64, FALSE);
#endif
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_R4)
LDIND(float, gfloat, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_R8)
#ifdef NO_UNALIGNED_ACCESS
LDIND(double, gdouble, TRUE);
#else
LDIND(double, gdouble, FALSE);
#endif
MINT_IN_BREAK;
#define LDIND_OFFSET(datatype,casttype,unaligned) do { \
gpointer ptr = LOCAL_VAR (ip [2], gpointer); \
NULL_CHECK (ptr); \
ptr = (char*)ptr + LOCAL_VAR (ip [3], mono_i); \
if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \
memcpy (locals + ip [1], ptr, sizeof (datatype)); \
else \
LOCAL_VAR (ip [1], datatype) = *(casttype*)ptr; \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_LDIND_OFFSET_I1)
LDIND_OFFSET(int, gint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_U1)
LDIND_OFFSET(int, guint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_I2)
LDIND_OFFSET(int, gint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_U2)
LDIND_OFFSET(int, guint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_I4)
LDIND_OFFSET(int, gint32, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_I8)
#ifdef NO_UNALIGNED_ACCESS
LDIND_OFFSET(gint64, gint64, TRUE);
#else
LDIND_OFFSET(gint64, gint64, FALSE);
#endif
MINT_IN_BREAK;
#define LDIND_OFFSET_IMM(datatype,casttype,unaligned) do { \
gpointer ptr = LOCAL_VAR (ip [2], gpointer); \
NULL_CHECK (ptr); \
ptr = (char*)ptr + (gint16)ip [3]; \
if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \
memcpy (locals + ip [1], ptr, sizeof (datatype)); \
else \
LOCAL_VAR (ip [1], datatype) = *(casttype*)ptr; \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_LDIND_OFFSET_IMM_I1)
LDIND_OFFSET_IMM(int, gint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_IMM_U1)
LDIND_OFFSET_IMM(int, guint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_IMM_I2)
LDIND_OFFSET_IMM(int, gint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_IMM_U2)
LDIND_OFFSET_IMM(int, guint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_IMM_I4)
LDIND_OFFSET_IMM(int, gint32, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDIND_OFFSET_IMM_I8)
#ifdef NO_UNALIGNED_ACCESS
LDIND_OFFSET_IMM(gint64, gint64, TRUE);
#else
LDIND_OFFSET_IMM(gint64, gint64, FALSE);
#endif
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_REF) {
gpointer ptr = LOCAL_VAR (ip [1], gpointer);
NULL_CHECK (ptr);
mono_gc_wbarrier_generic_store_internal (ptr, LOCAL_VAR (ip [2], MonoObject*));
ip += 3;
MINT_IN_BREAK;
}
#define STIND(datatype,unaligned) do { \
gpointer ptr = LOCAL_VAR (ip [1], gpointer); \
NULL_CHECK (ptr); \
if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \
memcpy (ptr, locals + ip [2], sizeof (datatype)); \
else \
*(datatype*)ptr = LOCAL_VAR (ip [2], datatype); \
ip += 3; \
} while (0)
MINT_IN_CASE(MINT_STIND_I1)
STIND(gint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_I2)
STIND(gint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_I4)
STIND(gint32, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_I8)
#ifdef NO_UNALIGNED_ACCESS
STIND(gint64, TRUE);
#else
STIND(gint64, FALSE);
#endif
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_R4)
STIND(float, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_R8)
#ifdef NO_UNALIGNED_ACCESS
STIND(double, TRUE);
#else
STIND(double, FALSE);
#endif
MINT_IN_BREAK;
#define STIND_OFFSET(datatype,unaligned) do { \
gpointer ptr = LOCAL_VAR (ip [1], gpointer); \
NULL_CHECK (ptr); \
ptr = (char*)ptr + LOCAL_VAR (ip [2], mono_i); \
if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \
memcpy (ptr, locals + ip [3], sizeof (datatype)); \
else \
*(datatype*)ptr = LOCAL_VAR (ip [3], datatype); \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_STIND_OFFSET_I1)
STIND_OFFSET(gint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_OFFSET_I2)
STIND_OFFSET(gint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_OFFSET_I4)
STIND_OFFSET(gint32, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_OFFSET_I8)
#ifdef NO_UNALIGNED_ACCESS
STIND_OFFSET(gint64, TRUE);
#else
STIND_OFFSET(gint64, FALSE);
#endif
MINT_IN_BREAK;
#define STIND_OFFSET_IMM(datatype,unaligned) do { \
gpointer ptr = LOCAL_VAR (ip [1], gpointer); \
NULL_CHECK (ptr); \
ptr = (char*)ptr + (gint16)ip [3]; \
if (unaligned && ((gsize)ptr % SIZEOF_VOID_P)) \
memcpy (ptr, locals + ip [2], sizeof (datatype)); \
else \
*(datatype*)ptr = LOCAL_VAR (ip [2], datatype); \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_STIND_OFFSET_IMM_I1)
STIND_OFFSET_IMM(gint8, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_OFFSET_IMM_I2)
STIND_OFFSET_IMM(gint16, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_OFFSET_IMM_I4)
STIND_OFFSET_IMM(gint32, FALSE);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_STIND_OFFSET_IMM_I8)
#ifdef NO_UNALIGNED_ACCESS
STIND_OFFSET_IMM(gint64, TRUE);
#else
STIND_OFFSET_IMM(gint64, FALSE);
#endif
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MONO_ATOMIC_STORE_I4)
mono_atomic_store_i32 (LOCAL_VAR (ip [1], gint32*), LOCAL_VAR (ip [2], gint32));
ip += 3;
MINT_IN_BREAK;
#define BINOP(datatype, op) \
LOCAL_VAR (ip [1], datatype) = LOCAL_VAR (ip [2], datatype) op LOCAL_VAR (ip [3], datatype); \
ip += 4;
MINT_IN_CASE(MINT_ADD_I4)
BINOP(gint32, +);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_I8)
BINOP(gint64, +);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_R4)
BINOP(float, +);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_R8)
BINOP(double, +);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD1_I4)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) + 1;
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_I4_IMM)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) + (gint16)ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD1_I8)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) + 1;
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_I8_IMM)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) + (gint16)ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SUB_I4)
BINOP(gint32, -);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SUB_I8)
BINOP(gint64, -);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SUB_R4)
BINOP(float, -);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SUB_R8)
BINOP(double, -);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SUB1_I4)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) - 1;
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SUB1_I8)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) - 1;
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MUL_I4)
BINOP(gint32, *);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MUL_I8)
BINOP(gint64, *);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MUL_I4_IMM)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) * (gint16)ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MUL_I8_IMM)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) * (gint16)ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MUL_R4)
BINOP(float, *);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MUL_R8)
BINOP(double, *);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_DIV_I4) {
gint32 i1 = LOCAL_VAR (ip [2], gint32);
gint32 i2 = LOCAL_VAR (ip [3], gint32);
if (i2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
if (i2 == (-1) && i1 == G_MININT32)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = i1 / i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_DIV_I8) {
gint64 l1 = LOCAL_VAR (ip [2], gint64);
gint64 l2 = LOCAL_VAR (ip [3], gint64);
if (l2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
if (l2 == (-1) && l1 == G_MININT64)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = l1 / l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_DIV_R4)
BINOP(float, /);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_DIV_R8)
BINOP(double, /);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_DIV_UN_I4) {
guint32 i2 = LOCAL_VAR (ip [3], guint32);
if (i2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
LOCAL_VAR (ip [1], guint32) = LOCAL_VAR (ip [2], guint32) / i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_DIV_UN_I8) {
guint64 l2 = LOCAL_VAR (ip [3], guint64);
if (l2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
LOCAL_VAR (ip [1], guint64) = LOCAL_VAR (ip [2], guint64) / l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_REM_I4) {
gint32 i1 = LOCAL_VAR (ip [2], gint32);
gint32 i2 = LOCAL_VAR (ip [3], gint32);
if (i2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
if (i2 == (-1) && i1 == G_MININT32)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = i1 % i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_REM_I8) {
gint64 l1 = LOCAL_VAR (ip [2], gint64);
gint64 l2 = LOCAL_VAR (ip [3], gint64);
if (l2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
if (l2 == (-1) && l1 == G_MININT64)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = l1 % l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_REM_R4)
LOCAL_VAR (ip [1], float) = fmodf (LOCAL_VAR (ip [2], float), LOCAL_VAR (ip [3], float));
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_REM_R8)
LOCAL_VAR (ip [1], double) = fmod (LOCAL_VAR (ip [2], double), LOCAL_VAR (ip [3], double));
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_REM_UN_I4) {
guint32 i2 = LOCAL_VAR (ip [3], guint32);
if (i2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
LOCAL_VAR (ip [1], guint32) = LOCAL_VAR (ip [2], guint32) % i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_REM_UN_I8) {
guint64 l2 = LOCAL_VAR (ip [3], guint64);
if (l2 == 0)
THROW_EX (interp_get_exception_divide_by_zero (frame, ip), ip);
LOCAL_VAR (ip [1], guint64) = LOCAL_VAR (ip [2], guint64) % l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_AND_I4)
BINOP(gint32, &);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_AND_I8)
BINOP(gint64, &);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_OR_I4)
BINOP(gint32, |);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_OR_I8)
BINOP(gint64, |);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_XOR_I4)
BINOP(gint32, ^);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_XOR_I8)
BINOP(gint64, ^);
MINT_IN_BREAK;
#define SHIFTOP(datatype, op) \
LOCAL_VAR (ip [1], datatype) = LOCAL_VAR (ip [2], datatype) op LOCAL_VAR (ip [3], gint32); \
ip += 4;
MINT_IN_CASE(MINT_SHL_I4)
SHIFTOP(gint32, <<);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHL_I8)
SHIFTOP(gint64, <<);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_I4)
SHIFTOP(gint32, >>);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_I8)
SHIFTOP(gint64, >>);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_UN_I4)
SHIFTOP(guint32, >>);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_UN_I8)
SHIFTOP(guint64, >>);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHL_I4_IMM)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) << ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHL_I8_IMM)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) << ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_I4_IMM)
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], gint32) >> ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_I8_IMM)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint64) >> ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_UN_I4_IMM)
LOCAL_VAR (ip [1], guint32) = LOCAL_VAR (ip [2], guint32) >> ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SHR_UN_I8_IMM)
LOCAL_VAR (ip [1], guint64) = LOCAL_VAR (ip [2], guint64) >> ip [3];
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NEG_I4)
LOCAL_VAR (ip [1], gint32) = - LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NEG_I8)
LOCAL_VAR (ip [1], gint64) = - LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NEG_R4)
LOCAL_VAR (ip [1], float) = - LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NEG_R8)
LOCAL_VAR (ip [1], double) = - LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NOT_I4)
LOCAL_VAR (ip [1], gint32) = ~ LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_NOT_I8)
LOCAL_VAR (ip [1], gint64) = ~ LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I1_I4)
// FIXME read casted var directly and remove redundant conv opcodes
LOCAL_VAR (ip [1], gint32) = (gint8)LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I1_I8)
LOCAL_VAR (ip [1], gint32) = (gint8)LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I1_R4)
LOCAL_VAR (ip [1], gint32) = (gint8) (gint32) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I1_R8)
/* without gint32 cast, C compiler is allowed to use undefined
* behaviour if data.f is bigger than >255. See conv.fpint section
* in C standard:
* > The conversion truncates; that is, the fractional part
* > is discarded. The behavior is undefined if the truncated
* > value cannot be represented in the destination type.
* */
LOCAL_VAR (ip [1], gint32) = (gint8) (gint32) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U1_I4)
LOCAL_VAR (ip [1], gint32) = (guint8) LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U1_I8)
LOCAL_VAR (ip [1], gint32) = (guint8) LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U1_R4)
LOCAL_VAR (ip [1], gint32) = (guint8) (guint32) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U1_R8)
LOCAL_VAR (ip [1], gint32) = (guint8) (guint32) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I2_I4)
LOCAL_VAR (ip [1], gint32) = (gint16) LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I2_I8)
LOCAL_VAR (ip [1], gint32) = (gint16) LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I2_R4)
LOCAL_VAR (ip [1], gint32) = (gint16) (gint32) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I2_R8)
LOCAL_VAR (ip [1], gint32) = (gint16) (gint32) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U2_I4)
LOCAL_VAR (ip [1], gint32) = (guint16) LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U2_I8)
LOCAL_VAR (ip [1], gint32) = (guint16) LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U2_R4)
LOCAL_VAR (ip [1], gint32) = (guint16) (guint32) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U2_R8)
LOCAL_VAR (ip [1], gint32) = (guint16) (guint32) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I4_R4)
LOCAL_VAR (ip [1], gint32) = (gint32) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I4_R8)
LOCAL_VAR (ip [1], gint32) = (gint32) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U4_R4)
#ifdef MONO_ARCH_EMULATE_FCONV_TO_U4
LOCAL_VAR (ip [1], gint32) = mono_rconv_u4 (LOCAL_VAR (ip [2], float));
#else
LOCAL_VAR (ip [1], gint32) = (guint32) LOCAL_VAR (ip [2], float);
#endif
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U4_R8)
#ifdef MONO_ARCH_EMULATE_FCONV_TO_U4
LOCAL_VAR (ip [1], gint32) = mono_fconv_u4 (LOCAL_VAR (ip [2], double));
#else
LOCAL_VAR (ip [1], gint32) = (guint32) LOCAL_VAR (ip [2], double);
#endif
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I8_I4)
LOCAL_VAR (ip [1], gint64) = LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I8_U4)
LOCAL_VAR (ip [1], gint64) = (guint32) LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I8_R4)
LOCAL_VAR (ip [1], gint64) = (gint64) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_I8_R8)
LOCAL_VAR (ip [1], gint64) = (gint64) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R4_I4)
LOCAL_VAR (ip [1], float) = (float) LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R4_I8)
LOCAL_VAR (ip [1], float) = (float) LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R4_R8)
LOCAL_VAR (ip [1], float) = (float) LOCAL_VAR (ip [2], double);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R8_I4)
LOCAL_VAR (ip [1], double) = (double) LOCAL_VAR (ip [2], gint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R8_I8)
LOCAL_VAR (ip [1], double) = (double) LOCAL_VAR (ip [2], gint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R8_R4)
LOCAL_VAR (ip [1], double) = (double) LOCAL_VAR (ip [2], float);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U8_R4)
#ifdef MONO_ARCH_EMULATE_FCONV_TO_U8
LOCAL_VAR (ip [1], gint64) = mono_rconv_u8 (LOCAL_VAR (ip [2], float));
#else
LOCAL_VAR (ip [1], gint64) = (guint64) LOCAL_VAR (ip [2], float);
#endif
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_U8_R8)
#ifdef MONO_ARCH_EMULATE_FCONV_TO_U8
LOCAL_VAR (ip [1], gint64) = mono_fconv_u8 (LOCAL_VAR (ip [2], double));
#else
LOCAL_VAR (ip [1], gint64) = (guint64) LOCAL_VAR (ip [2], double);
#endif
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CPOBJ) {
MonoClass* const c = (MonoClass*)frame->imethod->data_items[ip [3]];
g_assert (m_class_is_valuetype (c));
/* if this assertion fails, we need to add a write barrier */
g_assert (!MONO_TYPE_IS_REFERENCE (m_class_get_byval_arg (c)));
stackval_from_data (m_class_get_byval_arg (c), (stackval*)LOCAL_VAR (ip [1], gpointer), LOCAL_VAR (ip [2], gpointer), FALSE);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CPOBJ_VT) {
MonoClass* const c = (MonoClass*)frame->imethod->data_items[ip [3]];
mono_value_copy_internal (LOCAL_VAR (ip [1], gpointer), LOCAL_VAR (ip [2], gpointer), c);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDOBJ_VT) {
guint16 size = ip [3];
memcpy (locals + ip [1], LOCAL_VAR (ip [2], gpointer), size);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDSTR)
LOCAL_VAR (ip [1], gpointer) = frame->imethod->data_items [ip [2]];
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSTR_TOKEN) {
MonoString *s = NULL;
guint32 strtoken = (guint32)(gsize)frame->imethod->data_items [ip [2]];
MonoMethod *method = frame->imethod->method;
if (method->wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD) {
s = (MonoString*)mono_method_get_wrapper_data (method, strtoken);
} else if (method->wrapper_type != MONO_WRAPPER_NONE) {
// FIXME push/pop LMF
s = mono_string_new_wrapper_internal ((const char*)mono_method_get_wrapper_data (method, strtoken));
} else {
g_assert_not_reached ();
}
LOCAL_VAR (ip [1], gpointer) = s;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWOBJ_ARRAY) {
MonoClass *newobj_class;
guint32 token = ip [3];
guint16 param_count = ip [4];
newobj_class = (MonoClass*) frame->imethod->data_items [token];
// FIXME push/pop LMF
LOCAL_VAR (ip [1], MonoObject*) = ves_array_create (newobj_class, param_count, (stackval*)(locals + ip [2]), error);
if (!is_ok (error))
THROW_EX (interp_error_convert_to_exception (frame, error, ip), ip);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWOBJ_STRING) {
cmethod = (InterpMethod*)frame->imethod->data_items [ip [3]];
return_offset = ip [1];
call_args_offset = ip [2];
// `this` is implicit null. The created string will be returned
// by the call, even though the call has void return (?!).
LOCAL_VAR (call_args_offset, gpointer) = NULL;
ip += 4;
goto call;
}
MINT_IN_CASE(MINT_NEWOBJ) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [4]];
INIT_VTABLE (vtable);
guint16 imethod_index = ip [3];
return_offset = ip [1];
call_args_offset = ip [2];
// FIXME push/pop LMF
MonoObject *o = mono_gc_alloc_obj (vtable, m_class_get_instance_size (vtable->klass));
if (G_UNLIKELY (!o)) {
mono_error_set_out_of_memory (error, "Could not allocate %i bytes", m_class_get_instance_size (vtable->klass));
THROW_EX (interp_error_convert_to_exception (frame, error, ip), ip);
}
// This is return value
LOCAL_VAR (return_offset, MonoObject*) = o;
// Set `this` arg for ctor call
LOCAL_VAR (call_args_offset, MonoObject*) = o;
ip += 5;
cmethod = (InterpMethod*)frame->imethod->data_items [imethod_index];
goto call;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWOBJ_INLINED) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [2]];
INIT_VTABLE (vtable);
// FIXME push/pop LMF
MonoObject *o = mono_gc_alloc_obj (vtable, m_class_get_instance_size (vtable->klass));
if (G_UNLIKELY (!o)) {
mono_error_set_out_of_memory (error, "Could not allocate %i bytes", m_class_get_instance_size (vtable->klass));
THROW_EX (interp_error_convert_to_exception (frame, error, ip), ip);
}
// This is return value
LOCAL_VAR (ip [1], MonoObject*) = o;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWOBJ_VT) {
guint16 imethod_index = ip [3];
guint16 ret_size = ip [4];
return_offset = ip [1];
call_args_offset = ip [2];
gpointer this_vt = locals + return_offset;
// clear the valuetype
memset (this_vt, 0, ret_size);
// pass the address of the valuetype
LOCAL_VAR (call_args_offset, gpointer) = this_vt;
ip += 5;
cmethod = (InterpMethod*)frame->imethod->data_items [imethod_index];
goto call;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWOBJ_VT_INLINED) {
guint16 ret_size = ip [3];
gpointer this_vt = locals + ip [2];
memset (this_vt, 0, ret_size);
LOCAL_VAR (ip [1], gpointer) = this_vt;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWOBJ_SLOW) {
guint32 const token = ip [3];
return_offset = ip [1];
call_args_offset = ip [2];
cmethod = (InterpMethod*)frame->imethod->data_items [token];
MonoClass * const newobj_class = cmethod->method->klass;
/*
* First arg is the object.
* a constructor returns void, but we need to return the object we created
*/
g_assert (!m_class_is_valuetype (newobj_class));
// FIXME push/pop LMF
MonoVTable *vtable = mono_class_vtable_checked (newobj_class, error);
if (!is_ok (error) || !mono_runtime_class_init_full (vtable, error)) {
MonoException *exc = interp_error_convert_to_exception (frame, error, ip);
g_assert (exc);
THROW_EX (exc, ip);
}
error_init_reuse (error);
MonoObject* o = mono_object_new_checked (newobj_class, error);
LOCAL_VAR (return_offset, MonoObject*) = o; // return value
LOCAL_VAR (call_args_offset, MonoObject*) = o; // first parameter
mono_interp_error_cleanup (error); // FIXME: do not swallow the error
EXCEPTION_CHECKPOINT;
ip += 4;
goto call;
}
MINT_IN_CASE(MINT_INTRINS_SPAN_CTOR) {
gpointer ptr = LOCAL_VAR (ip [2], gpointer);
int len = LOCAL_VAR (ip [3], gint32);
if (len < 0)
THROW_EX (interp_get_exception_argument_out_of_range ("length", frame, ip), ip);
gpointer span = locals + ip [1];
*(gpointer*)span = ptr;
*(gint32*)((gpointer*)span + 1) = len;
ip += 4;;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_CLEAR_WITH_REFERENCES) {
gpointer p = LOCAL_VAR (ip [1], gpointer);
size_t size = LOCAL_VAR (ip [2], mono_u) * sizeof (gpointer);
mono_gc_bzero_aligned (p, size);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_MARVIN_BLOCK) {
interp_intrins_marvin_block ((guint32*)(locals + ip [1]), (guint32*)(locals + ip [2]));
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_ASCII_CHARS_TO_UPPERCASE) {
LOCAL_VAR (ip [1], gint32) = interp_intrins_ascii_chars_to_uppercase (LOCAL_VAR (ip [2], guint32));
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_MEMORYMARSHAL_GETARRAYDATAREF) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], gpointer) = (guint8*)o + MONO_STRUCT_OFFSET (MonoArray, vector);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_ORDINAL_IGNORE_CASE_ASCII) {
LOCAL_VAR (ip [1], gint32) = interp_intrins_ordinal_ignore_case_ascii (LOCAL_VAR (ip [2], guint32), LOCAL_VAR (ip [3], guint32));
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_64ORDINAL_IGNORE_CASE_ASCII) {
LOCAL_VAR (ip [1], gint32) = interp_intrins_64ordinal_ignore_case_ascii (LOCAL_VAR (ip [2], guint64), LOCAL_VAR (ip [3], guint64));
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_U32_TO_DECSTR) {
MonoArray **cache_addr = (MonoArray**)frame->imethod->data_items [ip [3]];
MonoVTable *string_vtable = (MonoVTable*)frame->imethod->data_items [ip [4]];
LOCAL_VAR (ip [1], MonoObject*) = (MonoObject*)interp_intrins_u32_to_decstr (LOCAL_VAR (ip [2], guint32), *cache_addr, string_vtable);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_WIDEN_ASCII_TO_UTF16) {
LOCAL_VAR (ip [1], mono_u) = interp_intrins_widen_ascii_to_utf16 (LOCAL_VAR (ip [2], guint8*), LOCAL_VAR (ip [3], mono_unichar2*), LOCAL_VAR (ip [4], mono_u));
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_UNSAFE_BYTE_OFFSET) {
LOCAL_VAR (ip [1], mono_u) = LOCAL_VAR (ip [3], guint8*) - LOCAL_VAR (ip [2], guint8*);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_RUNTIMEHELPERS_OBJECT_HAS_COMPONENT_SIZE) {
MonoObject *obj = LOCAL_VAR (ip [2], MonoObject*);
LOCAL_VAR (ip [1], gint32) = (obj->vtable->flags & MONO_VT_FLAG_ARRAY_OR_STRING) != 0;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CASTCLASS_INTERFACE)
MINT_IN_CASE(MINT_ISINST_INTERFACE) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
if (o) {
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
gboolean isinst;
if (MONO_VTABLE_IMPLEMENTS_INTERFACE (o->vtable, m_class_get_interface_id (c))) {
isinst = TRUE;
} else if (m_class_is_array_special_interface (c)) {
/* slow path */
// FIXME push/pop LMF
isinst = mono_interp_isinst (o, c); // FIXME: do not swallow the error
} else {
isinst = FALSE;
}
if (!isinst) {
gboolean const isinst_instr = *ip == MINT_ISINST_INTERFACE;
if (isinst_instr)
LOCAL_VAR (ip [1], MonoObject*) = NULL;
else
THROW_EX (interp_get_exception_invalid_cast (frame, ip), ip);
} else {
LOCAL_VAR (ip [1], MonoObject*) = o;
}
} else {
LOCAL_VAR (ip [1], MonoObject*) = NULL;
}
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CASTCLASS_COMMON)
MINT_IN_CASE(MINT_ISINST_COMMON) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
if (o) {
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
gboolean isinst = mono_class_has_parent_fast (o->vtable->klass, c);
if (!isinst) {
gboolean const isinst_instr = *ip == MINT_ISINST_COMMON;
if (isinst_instr)
LOCAL_VAR (ip [1], MonoObject*) = NULL;
else
THROW_EX (interp_get_exception_invalid_cast (frame, ip), ip);
} else {
LOCAL_VAR (ip [1], MonoObject*) = o;
}
} else {
LOCAL_VAR (ip [1], MonoObject*) = NULL;
}
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CASTCLASS)
MINT_IN_CASE(MINT_ISINST) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
if (o) {
MonoClass* const c = (MonoClass*)frame->imethod->data_items [ip [3]];
// FIXME push/pop LMF
if (!mono_interp_isinst (o, c)) { // FIXME: do not swallow the error
gboolean const isinst_instr = *ip == MINT_ISINST;
if (isinst_instr)
LOCAL_VAR (ip [1], MonoObject*) = NULL;
else
THROW_EX (interp_get_exception_invalid_cast (frame, ip), ip);
} else {
LOCAL_VAR (ip [1], MonoObject*) = o;
}
} else {
LOCAL_VAR (ip [1], MonoObject*) = NULL;
}
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_R_UN_I4)
LOCAL_VAR (ip [1], double) = (double)LOCAL_VAR (ip [2], guint32);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CONV_R_UN_I8)
LOCAL_VAR (ip [1], double) = (double)LOCAL_VAR (ip [2], guint64);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_UNBOX) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
if (!(m_class_get_rank (o->vtable->klass) == 0 && m_class_get_element_class (o->vtable->klass) == m_class_get_element_class (c)))
THROW_EX (interp_get_exception_invalid_cast (frame, ip), ip);
LOCAL_VAR (ip [1], gpointer) = mono_object_unbox_internal (o);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_THROW) {
MonoException *ex = LOCAL_VAR (ip [1], MonoException*);
if (!ex)
ex = interp_get_exception_null_reference (frame, ip);
THROW_EX (ex, ip);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_SAFEPOINT)
SAFEPOINT;
++ip;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLDA_UNSAFE) {
LOCAL_VAR (ip [1], gpointer) = (char*)LOCAL_VAR (ip [2], gpointer) + ip [3];
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDFLDA) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], gpointer) = (char *)o + ip [3];
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CKNULL) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], MonoObject*) = o;
ip += 3;
MINT_IN_BREAK;
}
#define LDFLD_UNALIGNED(datatype, fieldtype, unaligned) do { \
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*); \
NULL_CHECK (o); \
if (unaligned) \
memcpy (locals + ip [1], (char *)o + ip [3], sizeof (fieldtype)); \
else \
LOCAL_VAR (ip [1], datatype) = * (fieldtype *)((char *)o + ip [3]) ; \
ip += 4; \
} while (0)
#define LDFLD(datamem, fieldtype) LDFLD_UNALIGNED(datamem, fieldtype, FALSE)
MINT_IN_CASE(MINT_LDFLD_I1) LDFLD(gint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_U1) LDFLD(gint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_I2) LDFLD(gint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_U2) LDFLD(gint32, guint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_I4) LDFLD(gint32, gint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_I8) LDFLD(gint64, gint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_R4) LDFLD(float, float); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_R8) LDFLD(double, double); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_O) LDFLD(gpointer, gpointer); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_I8_UNALIGNED) LDFLD_UNALIGNED(gint64, gint64, TRUE); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_R8_UNALIGNED) LDFLD_UNALIGNED(double, double, TRUE); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDFLD_VT) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
memcpy (locals + ip [1], (char *)o + ip [3], ip [4]);
ip += 5;
MINT_IN_BREAK;
}
#define STFLD_UNALIGNED(datatype, fieldtype, unaligned) do { \
MonoObject *o = LOCAL_VAR (ip [1], MonoObject*); \
NULL_CHECK (o); \
if (unaligned) \
memcpy ((char *)o + ip [3], locals + ip [2], sizeof (fieldtype)); \
else \
* (fieldtype *)((char *)o + ip [3]) = LOCAL_VAR (ip [2], datatype); \
ip += 4; \
} while (0)
#define STFLD(datamem, fieldtype) STFLD_UNALIGNED(datamem, fieldtype, FALSE)
MINT_IN_CASE(MINT_STFLD_I1) STFLD(gint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_U1) STFLD(gint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_I2) STFLD(gint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_U2) STFLD(gint32, guint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_I4) STFLD(gint32, gint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_I8) STFLD(gint64, gint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_R4) STFLD(float, float); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_R8) STFLD(double, double); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_O) {
MonoObject *o = LOCAL_VAR (ip [1], MonoObject*);
NULL_CHECK (o);
mono_gc_wbarrier_set_field_internal (o, (char*)o + ip [3], LOCAL_VAR (ip [2], MonoObject*));
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_STFLD_I8_UNALIGNED) STFLD_UNALIGNED(gint64, gint64, TRUE); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_R8_UNALIGNED) STFLD_UNALIGNED(double, double, TRUE); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STFLD_VT_NOREF) {
MonoObject *o = LOCAL_VAR (ip [1], MonoObject*);
NULL_CHECK (o);
memcpy ((char*)o + ip [3], locals + ip [2], ip [4]);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_STFLD_VT) {
MonoClass *klass = (MonoClass*)frame->imethod->data_items [ip [4]];
MonoObject *o = LOCAL_VAR (ip [1], MonoObject*);
NULL_CHECK (o);
mono_value_copy_internal ((char*)o + ip [3], locals + ip [2], klass);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDSFLDA) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [2]];
INIT_VTABLE (vtable);
LOCAL_VAR (ip [1], gpointer) = frame->imethod->data_items [ip [3]];
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDTSFLDA) {
MonoInternalThread *thread = mono_thread_internal_current ();
guint32 offset = READ32 (ip + 2);
LOCAL_VAR (ip [1], gpointer) = ((char*)thread->static_data [offset & 0x3f]) + (offset >> 6);
ip += 4;
MINT_IN_BREAK;
}
/* We init class here to preserve cctor order */
#define LDSFLD(datatype, fieldtype) { \
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [2]]; \
INIT_VTABLE (vtable); \
LOCAL_VAR (ip [1], datatype) = * (fieldtype *)(frame->imethod->data_items [ip [3]]) ; \
ip += 4; \
}
MINT_IN_CASE(MINT_LDSFLD_I1) LDSFLD(gint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_U1) LDSFLD(gint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_I2) LDSFLD(gint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_U2) LDSFLD(gint32, guint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_I4) LDSFLD(gint32, gint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_I8) LDSFLD(gint64, gint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_R4) LDSFLD(float, float); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_R8) LDSFLD(double, double); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_O) LDSFLD(gpointer, gpointer); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDSFLD_VT) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [2]];
INIT_VTABLE (vtable);
gpointer addr = frame->imethod->data_items [ip [3]];
guint16 size = ip [4];
memcpy (locals + ip [1], addr, size);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDSFLD_W) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [READ32 (ip + 2)];
INIT_VTABLE (vtable);
gpointer addr = frame->imethod->data_items [READ32 (ip + 4)];
MonoClass *klass = frame->imethod->data_items [READ32 (ip + 6)];
stackval_from_data (m_class_get_byval_arg (klass), (stackval*)(locals + ip [1]), addr, FALSE);
ip += 8;
MINT_IN_BREAK;
}
#define STSFLD(datatype, fieldtype) { \
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [2]]; \
INIT_VTABLE (vtable); \
* (fieldtype *)(frame->imethod->data_items [ip [3]]) = LOCAL_VAR (ip [1], datatype); \
ip += 4; \
}
MINT_IN_CASE(MINT_STSFLD_I1) STSFLD(gint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_U1) STSFLD(gint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_I2) STSFLD(gint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_U2) STSFLD(gint32, guint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_I4) STSFLD(gint32, gint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_I8) STSFLD(gint64, gint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_R4) STSFLD(float, float); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_R8) STSFLD(double, double); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_O) STSFLD(gpointer, gpointer); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STSFLD_VT) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [ip [2]];
INIT_VTABLE (vtable);
gpointer addr = frame->imethod->data_items [ip [3]];
memcpy (addr, locals + ip [1], ip [4]);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_STSFLD_W) {
MonoVTable *vtable = (MonoVTable*) frame->imethod->data_items [READ32 (ip + 2)];
INIT_VTABLE (vtable);
gpointer addr = frame->imethod->data_items [READ32 (ip + 4)];
MonoClass *klass = frame->imethod->data_items [READ32 (ip + 6)];
stackval_to_data (m_class_get_byval_arg (klass), (stackval*)(locals + ip [1]), addr, FALSE);
ip += 8;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_STOBJ_VT) {
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
mono_value_copy_internal (LOCAL_VAR (ip [1], gpointer), locals + ip [2], c);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U8_I4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint64) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U8_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < 0)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint64) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I8_U8) {
guint64 val = LOCAL_VAR (ip [2], guint64);
if (val > G_MAXINT64)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U8_R4) {
float val = LOCAL_VAR (ip [2], float);
if (!mono_try_trunc_u64 (val, (guint64*)(locals + ip [1])))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U8_R8) {
double val = LOCAL_VAR (ip [2], double);
if (!mono_try_trunc_u64 (val, (guint64*)(locals + ip [1])))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I8_R4) {
float val = LOCAL_VAR (ip [2], float);
if (!mono_try_trunc_i64 (val, (gint64*)(locals + ip [1])))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I8_R8) {
double val = LOCAL_VAR (ip [2], double);
if (!mono_try_trunc_i64 (val, (gint64*)(locals + ip [1])))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BOX) {
MonoVTable *vtable = (MonoVTable*)frame->imethod->data_items [ip [3]];
// FIXME push/pop LMF
MonoObject *o = mono_gc_alloc_obj (vtable, m_class_get_instance_size (vtable->klass));
MONO_HANDLE_ASSIGN_RAW (tmp_handle, o);
stackval_to_data (m_class_get_byval_arg (vtable->klass), (stackval*)(locals + ip [2]), mono_object_get_data (o), FALSE);
MONO_HANDLE_ASSIGN_RAW (tmp_handle, NULL);
LOCAL_VAR (ip [1], MonoObject*) = o;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BOX_VT) {
MonoVTable *vtable = (MonoVTable*)frame->imethod->data_items [ip [3]];
MonoClass *c = vtable->klass;
// FIXME push/pop LMF
MonoObject* o = mono_gc_alloc_obj (vtable, m_class_get_instance_size (c));
MONO_HANDLE_ASSIGN_RAW (tmp_handle, o);
mono_value_copy_internal (mono_object_get_data (o), locals + ip [2], c);
MONO_HANDLE_ASSIGN_RAW (tmp_handle, NULL);
LOCAL_VAR (ip [1], MonoObject*) = o;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BOX_PTR) {
MonoVTable *vtable = (MonoVTable*)frame->imethod->data_items [ip [3]];
MonoClass *c = vtable->klass;
// FIXME push/pop LMF
MonoObject* o = mono_gc_alloc_obj (vtable, m_class_get_instance_size (c));
MONO_HANDLE_ASSIGN_RAW (tmp_handle, o);
mono_value_copy_internal (mono_object_get_data (o), LOCAL_VAR (ip [2], gpointer), c);
MONO_HANDLE_ASSIGN_RAW (tmp_handle, NULL);
LOCAL_VAR (ip [1], MonoObject*) = o;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_BOX_NULLABLE_PTR) {
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
// FIXME push/pop LMF
LOCAL_VAR (ip [1], MonoObject*) = mono_nullable_box (LOCAL_VAR (ip [2], gpointer), c, error);
mono_interp_error_cleanup (error); /* FIXME: don't swallow the error */
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_NEWARR) {
// FIXME push/pop LMF
MonoVTable *vtable = (MonoVTable*)frame->imethod->data_items [ip [3]];
LOCAL_VAR (ip [1], MonoObject*) = (MonoObject*) mono_array_new_specific_checked (vtable, LOCAL_VAR (ip [2], gint32), error);
if (!is_ok (error)) {
THROW_EX (interp_error_convert_to_exception (frame, error, ip), ip);
}
ip += 4;
/*if (profiling_classes) {
guint count = GPOINTER_TO_UINT (g_hash_table_lookup (profiling_classes, o->vtable->klass));
count++;
g_hash_table_insert (profiling_classes, o->vtable->klass, GUINT_TO_POINTER (count));
}*/
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDLEN) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], mono_u) = mono_array_length_internal ((MonoArray *)o);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDLEN_SPAN) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
// FIXME What's the point of this opcode ? It's just a LDFLD
gsize offset_length = (gsize)(gint16)ip [3];
LOCAL_VAR (ip [1], mono_u) = *(gint32 *) ((guint8 *) o + offset_length);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_GETCHR) {
MonoString *s = LOCAL_VAR (ip [2], MonoString*);
NULL_CHECK (s);
int i32 = LOCAL_VAR (ip [3], int);
if (i32 < 0 || i32 >= mono_string_length_internal (s))
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = mono_string_chars_internal (s)[i32];
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_GETITEM_SPAN) {
guint8 *span = LOCAL_VAR (ip [2], guint8*);
int index = LOCAL_VAR (ip [3], int);
NULL_CHECK (span);
gsize offset_length = (gsize)(gint16)ip [5];
const gint32 length = *(gint32 *) (span + offset_length);
if (index < 0 || index >= length)
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip);
gsize element_size = (gsize)(gint16)ip [4];
gsize offset_pointer = (gsize)(gint16)ip [6];
const gpointer pointer = *(gpointer *)(span + offset_pointer);
LOCAL_VAR (ip [1], gpointer) = (guint8 *) pointer + index * element_size;
ip += 7;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_STRLEN) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], gint32) = mono_string_length_internal ((MonoString*) o);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ARRAY_RANK) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], gint32) = m_class_get_rank (mono_object_class (o));
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ARRAY_ELEMENT_SIZE) {
// FIXME push/pop LMF
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], gint32) = mono_array_element_size (mono_object_class (o));
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ARRAY_IS_PRIMITIVE) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], gint32) = m_class_is_primitive (m_class_get_element_class (mono_object_class (o)));
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDELEMA1) {
/* No bounds, one direction */
MonoArray *ao = LOCAL_VAR (ip [2], MonoArray*);
NULL_CHECK (ao);
gint32 index = LOCAL_VAR (ip [3], gint32);
if (index >= ao->max_length)
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip);
guint16 size = ip [4];
LOCAL_VAR (ip [1], gpointer) = mono_array_addr_with_size_fast (ao, size, index);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDELEMA) {
guint16 rank = ip [3];
guint16 esize = ip [4];
stackval *sp = (stackval*)(locals + ip [2]);
MonoArray *ao = (MonoArray*) sp [0].data.o;
NULL_CHECK (ao);
g_assert (ao->bounds);
guint32 pos = 0;
for (int i = 0; i < rank; i++) {
gint32 idx = sp [i + 1].data.i;
gint32 lower = ao->bounds [i].lower_bound;
guint32 len = ao->bounds [i].length;
if (idx < lower || (guint32)(idx - lower) >= len)
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip);
pos = (pos * len) + (guint32)(idx - lower);
}
LOCAL_VAR (ip [1], gpointer) = mono_array_addr_with_size_fast (ao, esize, pos);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDELEMA_TC) {
// FIXME push/pop LMF
stackval *sp = (stackval*)(locals + ip [2]);
MonoObject *o = (MonoObject*) sp [0].data.o;
NULL_CHECK (o);
MonoClass *klass = (MonoClass*)frame->imethod->data_items [ip [3]];
MonoException *ex = ves_array_element_address (frame, klass, (MonoArray *) o, (gpointer*)(locals + ip [1]), sp + 1, TRUE);
if (ex)
THROW_EX (ex, ip);
ip += 4;
MINT_IN_BREAK;
}
#define LDELEM(datatype,elemtype) do { \
MonoArray *o = LOCAL_VAR (ip [2], MonoArray*); \
NULL_CHECK (o); \
gint32 aindex = LOCAL_VAR (ip [3], gint32); \
if (aindex >= mono_array_length_internal (o)) \
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip); \
LOCAL_VAR (ip [1], datatype) = mono_array_get_fast (o, elemtype, aindex); \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_LDELEM_I1) LDELEM(gint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_U1) LDELEM(gint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_I2) LDELEM(gint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_U2) LDELEM(gint32, guint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_I4) LDELEM(gint32, gint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_U4) LDELEM(gint32, guint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_I8) LDELEM(gint64, guint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_I) LDELEM(mono_u, mono_i); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_R4) LDELEM(float, float); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_R8) LDELEM(double, double); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_REF) LDELEM(gpointer, gpointer); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LDELEM_VT) {
MonoArray *o = LOCAL_VAR (ip [2], MonoArray*);
NULL_CHECK (o);
mono_u aindex = LOCAL_VAR (ip [3], gint32);
if (aindex >= mono_array_length_internal (o))
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip);
guint16 size = ip [4];
char *src_addr = mono_array_addr_with_size_fast ((MonoArray *) o, size, aindex);
memcpy (locals + ip [1], src_addr, size);
ip += 5;
MINT_IN_BREAK;
}
#define STELEM_PROLOG(o, aindex) do { \
o = LOCAL_VAR (ip [1], MonoArray*); \
NULL_CHECK (o); \
aindex = LOCAL_VAR (ip [2], gint32); \
if (aindex >= mono_array_length_internal (o)) \
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip); \
} while (0)
#define STELEM(datatype, elemtype) do { \
MonoArray *o; \
gint32 aindex; \
STELEM_PROLOG(o, aindex); \
mono_array_set_fast (o, elemtype, aindex, LOCAL_VAR (ip [3], datatype)); \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_STELEM_I1) STELEM(gint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_U1) STELEM(gint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_I2) STELEM(gint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_U2) STELEM(gint32, guint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_I4) STELEM(gint32, gint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_I8) STELEM(gint64, gint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_I) STELEM(mono_u, mono_i); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_R4) STELEM(float, float); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_R8) STELEM(double, double); MINT_IN_BREAK;
MINT_IN_CASE(MINT_STELEM_REF) {
MonoArray *o;
gint32 aindex;
STELEM_PROLOG(o, aindex);
MonoObject *ref = LOCAL_VAR (ip [3], MonoObject*);
if (ref) {
// FIXME push/pop LMF
gboolean isinst = mono_interp_isinst (ref, m_class_get_element_class (mono_object_class (o)));
if (!isinst)
THROW_EX (interp_get_exception_array_type_mismatch (frame, ip), ip);
}
mono_array_setref_fast ((MonoArray *) o, aindex, ref);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_STELEM_VT) {
MonoArray *o = LOCAL_VAR (ip [1], MonoArray*);
NULL_CHECK (o);
gint32 aindex = LOCAL_VAR (ip [2], gint32);
if (aindex >= mono_array_length_internal (o))
THROW_EX (interp_get_exception_index_out_of_range (frame, ip), ip);
guint16 size = ip [5];
char *dst_addr = mono_array_addr_with_size_fast ((MonoArray *) o, size, aindex);
MonoClass *klass_vt = (MonoClass*)frame->imethod->data_items [ip [4]];
mono_value_copy_internal (dst_addr, locals + ip [3], klass_vt);
ip += 6;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I4_U4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I4_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < G_MININT32 || val > G_MAXINT32)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint32) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I4_U8) {
guint64 val = LOCAL_VAR (ip [2], guint64);
if (val > G_MAXINT32)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint32) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I4_R4) {
float val = LOCAL_VAR (ip [2], float);
double val_r8 = (double)val;
if (val_r8 > ((double)G_MININT32 - 1) && val_r8 < ((double)G_MAXINT32 + 1))
LOCAL_VAR (ip [1], gint32) = (gint32) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I4_R8) {
double val = LOCAL_VAR (ip [2], double);
if (val > ((double)G_MININT32 - 1) && val < ((double)G_MAXINT32 + 1))
LOCAL_VAR (ip [1], gint32) = (gint32) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U4_I4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U4_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < 0 || val > G_MAXUINT32)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (guint32) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U4_R4) {
float val = LOCAL_VAR (ip [2], float);
double val_r8 = val;
if (val_r8 > -1.0 && val_r8 < ((double)G_MAXUINT32 + 1))
LOCAL_VAR (ip [1], gint32) = (guint32)val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U4_R8) {
double val = LOCAL_VAR (ip [2], double);
if (val > -1.0 && val < ((double)G_MAXUINT32 + 1))
LOCAL_VAR (ip [1], gint32) = (guint32)val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I2_I4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < G_MININT16 || val > G_MAXINT16)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint16)val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I2_U4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0 || val > G_MAXINT16)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint16)val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I2_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < G_MININT16 || val > G_MAXINT16)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint16) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I2_U8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < 0 || val > G_MAXINT16)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint16) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I2_R4) {
float val = LOCAL_VAR (ip [2], float);
if (val > (G_MININT16 - 1) && val < (G_MAXINT16 + 1))
LOCAL_VAR (ip [1], gint32) = (gint16) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I2_R8) {
double val = LOCAL_VAR (ip [2], double);
if (val > (G_MININT16 - 1) && val < (G_MAXINT16 + 1))
LOCAL_VAR (ip [1], gint32) = (gint16) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U2_I4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0 || val > G_MAXUINT16)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U2_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < 0 || val > G_MAXUINT16)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (guint16) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U2_R4) {
float val = LOCAL_VAR (ip [2], float);
if (val > -1.0f && val < (G_MAXUINT16 + 1))
LOCAL_VAR (ip [1], gint32) = (guint16) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U2_R8) {
double val = LOCAL_VAR (ip [2], double);
if (val > -1.0 && val < (G_MAXUINT16 + 1))
LOCAL_VAR (ip [1], gint32) = (guint16) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I1_I4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < G_MININT8 || val > G_MAXINT8)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I1_U4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0 || val > G_MAXINT8)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I1_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < G_MININT8 || val > G_MAXINT8)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint8) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I1_U8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < 0 || val > G_MAXINT8)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (gint8) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I1_R4) {
float val = LOCAL_VAR (ip [2], float);
if (val > (G_MININT8 - 1) && val < (G_MAXINT8 + 1))
LOCAL_VAR (ip [1], gint32) = (gint8) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_I1_R8) {
double val = LOCAL_VAR (ip [2], double);
if (val > (G_MININT8 - 1) && val < (G_MAXINT8 + 1))
LOCAL_VAR (ip [1], gint32) = (gint8) val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U1_I4) {
gint32 val = LOCAL_VAR (ip [2], gint32);
if (val < 0 || val > G_MAXUINT8)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U1_I8) {
gint64 val = LOCAL_VAR (ip [2], gint64);
if (val < 0 || val > G_MAXUINT8)
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = (guint8) val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U1_R4) {
float val = LOCAL_VAR (ip [2], float);
if (val > -1.0f && val < (G_MAXUINT8 + 1))
LOCAL_VAR (ip [1], gint32) = (guint8)val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CONV_OVF_U1_R8) {
double val = LOCAL_VAR (ip [2], double);
if (val > -1.0 && val < (G_MAXUINT8 + 1))
LOCAL_VAR (ip [1], gint32) = (guint8)val;
else
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CKFINITE) {
double val = LOCAL_VAR (ip [2], double);
if (!mono_isfinite (val))
THROW_EX (interp_get_exception_arithmetic (frame, ip), ip);
LOCAL_VAR (ip [1], double) = val;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MKREFANY) {
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
gpointer addr = LOCAL_VAR (ip [2], gpointer);
/* Write the typedref value */
MonoTypedRef *tref = (MonoTypedRef*)(locals + ip [1]);
tref->klass = c;
tref->type = m_class_get_byval_arg (c);
tref->value = addr;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_REFANYTYPE) {
MonoTypedRef *tref = (MonoTypedRef*)(locals + ip [2]);
LOCAL_VAR (ip [1], gpointer) = tref->type;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_REFANYVAL) {
MonoTypedRef *tref = (MonoTypedRef*)(locals + ip [2]);
MonoClass *c = (MonoClass*)frame->imethod->data_items [ip [3]];
if (c != tref->klass)
THROW_EX (interp_get_exception_invalid_cast (frame, ip), ip);
LOCAL_VAR (ip [1], gpointer) = tref->value;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDTOKEN)
// FIXME same as MINT_MONO_LDPTR
LOCAL_VAR (ip [1], gpointer) = frame->imethod->data_items [ip [2]];
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ADD_OVF_I4) {
gint32 i1 = LOCAL_VAR (ip [2], gint32);
gint32 i2 = LOCAL_VAR (ip [3], gint32);
if (CHECK_ADD_OVERFLOW (i1, i2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = i1 + i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ADD_OVF_I8) {
gint64 l1 = LOCAL_VAR (ip [2], gint64);
gint64 l2 = LOCAL_VAR (ip [3], gint64);
if (CHECK_ADD_OVERFLOW64 (l1, l2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = l1 + l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ADD_OVF_UN_I4) {
guint32 i1 = LOCAL_VAR (ip [2], guint32);
guint32 i2 = LOCAL_VAR (ip [3], guint32);
if (CHECK_ADD_OVERFLOW_UN (i1, i2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint32) = i1 + i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ADD_OVF_UN_I8) {
guint64 l1 = LOCAL_VAR (ip [2], guint64);
guint64 l2 = LOCAL_VAR (ip [3], guint64);
if (CHECK_ADD_OVERFLOW64_UN (l1, l2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint64) = l1 + l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MUL_OVF_I4) {
gint32 i1 = LOCAL_VAR (ip [2], gint32);
gint32 i2 = LOCAL_VAR (ip [3], gint32);
if (CHECK_MUL_OVERFLOW (i1, i2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = i1 * i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MUL_OVF_I8) {
gint64 l1 = LOCAL_VAR (ip [2], gint64);
gint64 l2 = LOCAL_VAR (ip [3], gint64);
if (CHECK_MUL_OVERFLOW64 (l1, l2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = l1 * l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MUL_OVF_UN_I4) {
guint32 i1 = LOCAL_VAR (ip [2], guint32);
guint32 i2 = LOCAL_VAR (ip [3], guint32);
if (CHECK_MUL_OVERFLOW_UN (i1, i2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint32) = i1 * i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MUL_OVF_UN_I8) {
guint64 l1 = LOCAL_VAR (ip [2], guint64);
guint64 l2 = LOCAL_VAR (ip [3], guint64);
if (CHECK_MUL_OVERFLOW64_UN (l1, l2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint64) = l1 * l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_SUB_OVF_I4) {
gint32 i1 = LOCAL_VAR (ip [2], gint32);
gint32 i2 = LOCAL_VAR (ip [3], gint32);
if (CHECK_SUB_OVERFLOW (i1, i2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint32) = i1 - i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_SUB_OVF_I8) {
gint64 l1 = LOCAL_VAR (ip [2], gint64);
gint64 l2 = LOCAL_VAR (ip [3], gint64);
if (CHECK_SUB_OVERFLOW64 (l1, l2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = l1 - l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_SUB_OVF_UN_I4) {
guint32 i1 = LOCAL_VAR (ip [2], guint32);
guint32 i2 = LOCAL_VAR (ip [3], guint32);
if (CHECK_SUB_OVERFLOW_UN (i1, i2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], guint32) = i1 - i2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_SUB_OVF_UN_I8) {
guint64 l1 = LOCAL_VAR (ip [2], guint64);
guint64 l2 = LOCAL_VAR (ip [3], guint64);
if (CHECK_SUB_OVERFLOW64_UN (l1, l2))
THROW_EX (interp_get_exception_overflow (frame, ip), ip);
LOCAL_VAR (ip [1], gint64) = l1 - l2;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ENDFINALLY) {
guint16 clause_index = *(ip + 1);
guint16 *ret_ip = *(guint16**)(locals + frame->imethod->clause_data_offsets [clause_index]);
if (!ret_ip) {
// this clause was called from EH, return to eh
g_assert (clause_args && clause_args->exec_frame == frame);
goto exit_clause;
}
ip = ret_ip;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_CALL_HANDLER)
MINT_IN_CASE(MINT_CALL_HANDLER_S) {
gboolean short_offset = *ip == MINT_CALL_HANDLER_S;
const guint16 *ret_ip = short_offset ? (ip + 3) : (ip + 4);
guint16 clause_index = *(ret_ip - 1);
*(const guint16**)(locals + frame->imethod->clause_data_offsets [clause_index]) = ret_ip;
// jump to clause
ip += short_offset ? (gint16)*(ip + 1) : (gint32)READ32 (ip + 1);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LEAVE)
MINT_IN_CASE(MINT_LEAVE_S)
MINT_IN_CASE(MINT_LEAVE_CHECK)
MINT_IN_CASE(MINT_LEAVE_S_CHECK) {
int opcode = *ip;
gboolean const check = opcode == MINT_LEAVE_CHECK || opcode == MINT_LEAVE_S_CHECK;
if (check && frame->imethod->method->wrapper_type != MONO_WRAPPER_RUNTIME_INVOKE) {
MonoException *abort_exc = mono_interp_leave (frame);
if (abort_exc)
THROW_EX (abort_exc, ip);
}
gboolean const short_offset = opcode == MINT_LEAVE_S || opcode == MINT_LEAVE_S_CHECK;
ip += short_offset ? (gint16)*(ip + 1) : (gint32)READ32 (ip + 1);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ICALL_V_V)
MINT_IN_CASE(MINT_ICALL_P_V)
MINT_IN_CASE(MINT_ICALL_PP_V)
MINT_IN_CASE(MINT_ICALL_PPP_V)
MINT_IN_CASE(MINT_ICALL_PPPP_V)
MINT_IN_CASE(MINT_ICALL_PPPPP_V)
MINT_IN_CASE(MINT_ICALL_PPPPPP_V)
frame->state.ip = ip + 3;
do_icall_wrapper (frame, NULL, *ip, NULL, (stackval*)(locals + ip [1]), frame->imethod->data_items [ip [2]], FALSE, &gc_transitions);
EXCEPTION_CHECKPOINT;
CHECK_RESUME_STATE (context);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_ICALL_V_P)
MINT_IN_CASE(MINT_ICALL_P_P)
MINT_IN_CASE(MINT_ICALL_PP_P)
MINT_IN_CASE(MINT_ICALL_PPP_P)
MINT_IN_CASE(MINT_ICALL_PPPP_P)
MINT_IN_CASE(MINT_ICALL_PPPPP_P)
MINT_IN_CASE(MINT_ICALL_PPPPPP_P)
frame->state.ip = ip + 4;
do_icall_wrapper (frame, NULL, *ip, (stackval*)(locals + ip [1]), (stackval*)(locals + ip [2]), frame->imethod->data_items [ip [3]], FALSE, &gc_transitions);
EXCEPTION_CHECKPOINT;
CHECK_RESUME_STATE (context);
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MONO_LDPTR)
LOCAL_VAR (ip [1], gpointer) = frame->imethod->data_items [ip [2]];
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MONO_NEWOBJ)
// FIXME push/pop LMF
LOCAL_VAR (ip [1], MonoObject*) = mono_interp_new ((MonoClass*)frame->imethod->data_items [ip [2]]); // FIXME: do not swallow the error
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MONO_RETOBJ)
// FIXME push/pop LMF
stackval_from_data (mono_method_signature_internal (frame->imethod->method)->ret, frame->stack, LOCAL_VAR (ip [1], gpointer),
mono_method_signature_internal (frame->imethod->method)->pinvoke && !mono_method_signature_internal (frame->imethod->method)->marshalling_disabled);
frame_data_allocator_pop (&context->data_stack, frame);
goto exit_frame;
MINT_IN_CASE(MINT_MONO_SGEN_THREAD_INFO)
LOCAL_VAR (ip [1], gpointer) = mono_tls_get_sgen_thread_info ();
ip += 2;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MONO_MEMORY_BARRIER) {
++ip;
mono_memory_barrier ();
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MONO_EXCHANGE_I8) {
gboolean flag = FALSE;
gint64 *dest = LOCAL_VAR (ip [2], gint64*);
gint64 exch = LOCAL_VAR (ip [3], gint64);
#if SIZEOF_VOID_P == 4
if (G_UNLIKELY (((size_t)dest) & 0x7)) {
gint64 result;
mono_interlocked_lock ();
result = *dest;
*dest = exch;
mono_interlocked_unlock ();
LOCAL_VAR (ip [1], gint64) = result;
flag = TRUE;
}
#endif
if (!flag)
LOCAL_VAR (ip [1], gint64) = mono_atomic_xchg_i64 (dest, exch);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MONO_LDDOMAIN)
LOCAL_VAR (ip [1], gpointer) = mono_domain_get ();
ip += 2;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MONO_ENABLE_GCTRANS)
gc_transitions = TRUE;
ip++;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SDB_INTR_LOC)
if (G_UNLIKELY (ss_enabled)) {
typedef void (*T) (void);
static T ss_tramp;
if (!ss_tramp) {
// FIXME push/pop LMF
void *tramp = mini_get_single_step_trampoline ();
mono_memory_barrier ();
ss_tramp = (T)tramp;
}
/*
* Make this point to the MINT_SDB_SEQ_POINT instruction which follows this since
* the address of that instruction is stored as the seq point address. Add also
* 1 to offset subtraction from interp_frame_get_ip.
*/
frame->state.ip = ip + 2;
/*
* Use the same trampoline as the JIT. This ensures that
* the debugger has the context for the last interpreter
* native frame.
*/
do_debugger_tramp (ss_tramp, frame);
CHECK_RESUME_STATE (context);
}
++ip;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SDB_SEQ_POINT)
/* Just a placeholder for a breakpoint */
++ip;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SDB_BREAKPOINT) {
typedef void (*T) (void);
static T bp_tramp;
if (!bp_tramp) {
// FIXME push/pop LMF
void *tramp = mini_get_breakpoint_trampoline ();
mono_memory_barrier ();
bp_tramp = (T)tramp;
}
/* Add 1 to offset subtraction from interp_frame_get_ip */
frame->state.ip = ip + 1;
/* Use the same trampoline as the JIT */
do_debugger_tramp (bp_tramp, frame);
CHECK_RESUME_STATE (context);
++ip;
MINT_IN_BREAK;
}
#define RELOP(datatype, op) \
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], datatype) op LOCAL_VAR (ip [3], datatype); \
ip += 4;
#define RELOP_FP(datatype, op, noorder) do { \
datatype a1 = LOCAL_VAR (ip [2], datatype); \
datatype a2 = LOCAL_VAR (ip [3], datatype); \
if (mono_isunordered (a1, a2)) \
LOCAL_VAR (ip [1], gint32) = noorder; \
else \
LOCAL_VAR (ip [1], gint32) = a1 op a2; \
ip += 4; \
} while (0)
MINT_IN_CASE(MINT_CEQ_I4)
RELOP(gint32, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CEQ0_I4)
LOCAL_VAR (ip [1], gint32) = (LOCAL_VAR (ip [2], gint32) == 0);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CEQ_I8)
RELOP(gint64, ==);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CEQ_R4)
RELOP_FP(float, ==, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CEQ_R8)
RELOP_FP(double, ==, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CNE_I4)
RELOP(gint32, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CNE_I8)
RELOP(gint64, !=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CNE_R4)
RELOP_FP(float, !=, 1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CNE_R8)
RELOP_FP(double, !=, 1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_I4)
RELOP(gint32, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_I8)
RELOP(gint64, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_R4)
RELOP_FP(float, >, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_R8)
RELOP_FP(double, >, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGE_I4)
RELOP(gint32, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGE_I8)
RELOP(gint64, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGE_R4)
RELOP_FP(float, >=, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGE_R8)
RELOP_FP(double, >=, 0);
MINT_IN_BREAK;
#define RELOP_CAST(datatype, op) \
LOCAL_VAR (ip [1], gint32) = LOCAL_VAR (ip [2], datatype) op LOCAL_VAR (ip [3], datatype); \
ip += 4;
MINT_IN_CASE(MINT_CGE_UN_I4)
RELOP_CAST(guint32, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGE_UN_I8)
RELOP_CAST(guint64, >=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_UN_I4)
RELOP_CAST(guint32, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_UN_I8)
RELOP_CAST(guint64, >);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_UN_R4)
RELOP_FP(float, >, 1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CGT_UN_R8)
RELOP_FP(double, >, 1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_I4)
RELOP(gint32, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_I8)
RELOP(gint64, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_R4)
RELOP_FP(float, <, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_R8)
RELOP_FP(double, <, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_UN_I4)
RELOP_CAST(guint32, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_UN_I8)
RELOP_CAST(guint64, <);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_UN_R4)
RELOP_FP(float, <, 1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLT_UN_R8)
RELOP_FP(double, <, 1);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLE_I4)
RELOP(gint32, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLE_I8)
RELOP(gint64, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLE_UN_I4)
RELOP_CAST(guint32, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLE_UN_I8)
RELOP_CAST(guint64, <=);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLE_R4)
RELOP_FP(float, <=, 0);
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CLE_R8)
RELOP_FP(double, <=, 0);
MINT_IN_BREAK;
#undef RELOP
#undef RELOP_FP
#undef RELOP_CAST
MINT_IN_CASE(MINT_LDFTN_ADDR) {
LOCAL_VAR (ip [1], gpointer) = frame->imethod->data_items [ip [2]];
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDFTN) {
InterpMethod *m = (InterpMethod*)frame->imethod->data_items [ip [2]];
// FIXME push/pop LMF
LOCAL_VAR (ip [1], gpointer) = imethod_to_ftnptr (m, FALSE);
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDVIRTFTN) {
InterpMethod *virtual_method = (InterpMethod*)frame->imethod->data_items [ip [3]];
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
// FIXME push/pop LMF
InterpMethod *res_method = get_virtual_method (virtual_method, o->vtable);
gboolean need_unbox = m_class_is_valuetype (res_method->method->klass) && !m_class_is_valuetype (virtual_method->method->klass);
LOCAL_VAR (ip [1], gpointer) = imethod_to_ftnptr (res_method, need_unbox);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDFTN_DYNAMIC) {
error_init_reuse (error);
MonoMethod *cmethod = LOCAL_VAR (ip [2], MonoMethod*);
// FIXME push/pop LMF
if (G_UNLIKELY (mono_method_has_unmanaged_callers_only_attribute (cmethod))) {
cmethod = mono_marshal_get_managed_wrapper (cmethod, NULL, (MonoGCHandle)0, error);
mono_error_assert_ok (error);
gpointer addr = mini_get_interp_callbacks ()->create_method_pointer (cmethod, TRUE, error);
LOCAL_VAR (ip [1], gpointer) = addr;
} else {
InterpMethod *m = mono_interp_get_imethod (cmethod, error);
mono_error_assert_ok (error);
LOCAL_VAR (ip [1], gpointer) = imethod_to_ftnptr (m, FALSE);
}
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_PROF_ENTER) {
guint16 flag = ip [1];
ip += 2;
if ((flag & TRACING_FLAG) || ((flag & PROFILING_FLAG) && MONO_PROFILER_ENABLED (method_enter) &&
(frame->imethod->prof_flags & MONO_PROFILER_CALL_INSTRUMENTATION_ENTER_CONTEXT))) {
MonoProfilerCallContext *prof_ctx = g_new0 (MonoProfilerCallContext, 1);
prof_ctx->interp_frame = frame;
prof_ctx->method = frame->imethod->method;
// FIXME push/pop LMF
if (flag & TRACING_FLAG)
mono_trace_enter_method (frame->imethod->method, frame->imethod->jinfo, prof_ctx);
if (flag & PROFILING_FLAG)
MONO_PROFILER_RAISE (method_enter, (frame->imethod->method, prof_ctx));
g_free (prof_ctx);
} else if ((flag & PROFILING_FLAG) && MONO_PROFILER_ENABLED (method_enter)) {
MONO_PROFILER_RAISE (method_enter, (frame->imethod->method, NULL));
}
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_PROF_EXIT)
MINT_IN_CASE(MINT_PROF_EXIT_VOID) {
gboolean is_void = ip [0] == MINT_PROF_EXIT_VOID;
guint16 flag = is_void ? ip [1] : ip [2];
// Set retval
if (!is_void) {
int i32 = READ32 (ip + 3);
if (i32)
memmove (frame->retval, locals + ip [1], i32);
else
frame->retval [0] = LOCAL_VAR (ip [1], stackval);
}
if ((flag & TRACING_FLAG) || ((flag & PROFILING_FLAG) && MONO_PROFILER_ENABLED (method_leave) &&
(frame->imethod->prof_flags & MONO_PROFILER_CALL_INSTRUMENTATION_LEAVE_CONTEXT))) {
MonoProfilerCallContext *prof_ctx = g_new0 (MonoProfilerCallContext, 1);
prof_ctx->interp_frame = frame;
prof_ctx->method = frame->imethod->method;
if (!is_void)
prof_ctx->return_value = frame->retval;
// FIXME push/pop LMF
if (flag & TRACING_FLAG)
mono_trace_leave_method (frame->imethod->method, frame->imethod->jinfo, prof_ctx);
if (flag & PROFILING_FLAG)
MONO_PROFILER_RAISE (method_leave, (frame->imethod->method, prof_ctx));
g_free (prof_ctx);
} else if ((flag & PROFILING_FLAG) && MONO_PROFILER_ENABLED (method_enter)) {
MONO_PROFILER_RAISE (method_leave, (frame->imethod->method, NULL));
}
frame_data_allocator_pop (&context->data_stack, frame);
goto exit_frame;
}
MINT_IN_CASE(MINT_PROF_COVERAGE_STORE) {
++ip;
guint32 *p = (guint32*)GINT_TO_POINTER (READ64 (ip));
*p = 1;
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LDLOCA_S)
LOCAL_VAR (ip [1], gpointer) = locals + ip [2];
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_OFF)
// This opcode is resolved to a normal MINT_MOV when emitting compacted instructions
g_assert_not_reached ();
MINT_IN_BREAK;
#define MOV(argtype1,argtype2) \
LOCAL_VAR (ip [1], argtype1) = LOCAL_VAR (ip [2], argtype2); \
ip += 3;
// When loading from a local, we might need to sign / zero extend to 4 bytes
// which is our minimum "register" size in interp. They are only needed when
// the address of the local is taken and we should try to optimize them out
// because the local can't be propagated.
MINT_IN_CASE(MINT_MOV_I1) MOV(guint32, gint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_U1) MOV(guint32, guint8); MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_I2) MOV(guint32, gint16); MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_U2) MOV(guint32, guint16); MINT_IN_BREAK;
// Normal moves between locals
MINT_IN_CASE(MINT_MOV_4) MOV(guint32, guint32); MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_8) MOV(guint64, guint64); MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_VT) {
guint16 size = ip [3];
memmove (locals + ip [1], locals + ip [2], size);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MOV_8_2)
LOCAL_VAR (ip [1], guint64) = LOCAL_VAR (ip [2], guint64);
LOCAL_VAR (ip [3], guint64) = LOCAL_VAR (ip [4], guint64);
ip += 5;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_8_3)
LOCAL_VAR (ip [1], guint64) = LOCAL_VAR (ip [2], guint64);
LOCAL_VAR (ip [3], guint64) = LOCAL_VAR (ip [4], guint64);
LOCAL_VAR (ip [5], guint64) = LOCAL_VAR (ip [6], guint64);
ip += 7;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_MOV_8_4)
LOCAL_VAR (ip [1], guint64) = LOCAL_VAR (ip [2], guint64);
LOCAL_VAR (ip [3], guint64) = LOCAL_VAR (ip [4], guint64);
LOCAL_VAR (ip [5], guint64) = LOCAL_VAR (ip [6], guint64);
LOCAL_VAR (ip [7], guint64) = LOCAL_VAR (ip [8], guint64);
ip += 9;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOCALLOC) {
int len = LOCAL_VAR (ip [2], gint32);
gpointer mem = frame_data_allocator_alloc (&context->data_stack, frame, ALIGN_TO (len, MINT_VT_ALIGNMENT));
if (frame->imethod->init_locals)
memset (mem, 0, len);
LOCAL_VAR (ip [1], gpointer) = mem;
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_ENDFILTER)
/* top of stack is result of filter */
frame->retval->data.i = LOCAL_VAR (ip [1], gint32);
goto exit_clause;
MINT_IN_CASE(MINT_INITOBJ)
memset (LOCAL_VAR (ip [1], gpointer), 0, ip [2]);
ip += 3;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_CPBLK) {
gpointer dest = LOCAL_VAR (ip [1], gpointer);
gpointer src = LOCAL_VAR (ip [2], gpointer);
guint32 size = LOCAL_VAR (ip [3], guint32);
if (size && (!dest || !src))
THROW_EX (interp_get_exception_null_reference(frame, ip), ip);
else
memcpy (dest, src, size);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INITBLK) {
gpointer dest = LOCAL_VAR (ip [1], gpointer);
guint32 size = LOCAL_VAR (ip [3], guint32);
if (size)
NULL_CHECK (dest);
memset (dest, LOCAL_VAR (ip [2], gint32), size);
ip += 4;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_RETHROW) {
int exvar_offset = ip [1];
THROW_EX_GENERAL (*(MonoException**)(frame_locals (frame) + exvar_offset), ip, TRUE);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_MONO_RETHROW) {
/*
* need to clarify what this should actually do:
*
* Takes an exception from the stack and rethrows it.
* This is useful for wrappers that don't want to have to
* use CEE_THROW and lose the exception stacktrace.
*/
MonoException *exc = LOCAL_VAR (ip [1], MonoException*);
if (!exc)
exc = interp_get_exception_null_reference (frame, ip);
THROW_EX_GENERAL (exc, ip, TRUE);
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_LD_DELEGATE_METHOD_PTR) {
// FIXME push/pop LMF
MonoDelegate *del = LOCAL_VAR (ip [2], MonoDelegate*);
if (!del->interp_method) {
/* Not created from interpreted code */
error_init_reuse (error);
g_assert (del->method);
del->interp_method = mono_interp_get_imethod (del->method, error);
mono_error_assert_ok (error);
}
g_assert (del->interp_method);
LOCAL_VAR (ip [1], gpointer) = imethod_to_ftnptr (del->interp_method, FALSE);
ip += 3;
MINT_IN_BREAK;
}
#define MATH_UNOP(mathfunc) \
LOCAL_VAR (ip [1], double) = mathfunc (LOCAL_VAR (ip [2], double)); \
ip += 3;
#define MATH_BINOP(mathfunc) \
LOCAL_VAR (ip [1], double) = mathfunc (LOCAL_VAR (ip [2], double), LOCAL_VAR (ip [3], double)); \
ip += 4;
MINT_IN_CASE(MINT_ASIN) MATH_UNOP(asin); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ASINH) MATH_UNOP(asinh); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ACOS) MATH_UNOP(acos); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ACOSH) MATH_UNOP(acosh); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ATAN) MATH_UNOP(atan); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ATANH) MATH_UNOP(atanh); MINT_IN_BREAK;
MINT_IN_CASE(MINT_CEILING) MATH_UNOP(ceil); MINT_IN_BREAK;
MINT_IN_CASE(MINT_COS) MATH_UNOP(cos); MINT_IN_BREAK;
MINT_IN_CASE(MINT_CBRT) MATH_UNOP(cbrt); MINT_IN_BREAK;
MINT_IN_CASE(MINT_COSH) MATH_UNOP(cosh); MINT_IN_BREAK;
MINT_IN_CASE(MINT_EXP) MATH_UNOP(exp); MINT_IN_BREAK;
MINT_IN_CASE(MINT_FLOOR) MATH_UNOP(floor); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOG) MATH_UNOP(log); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOG2) MATH_UNOP(log2); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOG10) MATH_UNOP(log10); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SIN) MATH_UNOP(sin); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SQRT) MATH_UNOP(sqrt); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SINH) MATH_UNOP(sinh); MINT_IN_BREAK;
MINT_IN_CASE(MINT_TAN) MATH_UNOP(tan); MINT_IN_BREAK;
MINT_IN_CASE(MINT_TANH) MATH_UNOP(tanh); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ATAN2) MATH_BINOP(atan2); MINT_IN_BREAK;
MINT_IN_CASE(MINT_POW) MATH_BINOP(pow); MINT_IN_BREAK;
MINT_IN_CASE(MINT_FMA)
LOCAL_VAR (ip [1], double) = fma (LOCAL_VAR (ip [2], double), LOCAL_VAR (ip [3], double), LOCAL_VAR (ip [4], double));
ip += 5;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SCALEB)
LOCAL_VAR (ip [1], double) = scalbn (LOCAL_VAR (ip [2], double), LOCAL_VAR (ip [3], gint32));
ip += 4;
MINT_IN_BREAK;
#define MATH_UNOPF(mathfunc) \
LOCAL_VAR (ip [1], float) = mathfunc (LOCAL_VAR (ip [2], float)); \
ip += 3;
#define MATH_BINOPF(mathfunc) \
LOCAL_VAR (ip [1], float) = mathfunc (LOCAL_VAR (ip [2], float), LOCAL_VAR (ip [3], float)); \
ip += 4;
MINT_IN_CASE(MINT_ASINF) MATH_UNOPF(asinf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ASINHF) MATH_UNOPF(asinhf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ACOSF) MATH_UNOPF(acosf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ACOSHF) MATH_UNOPF(acoshf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ATANF) MATH_UNOPF(atanf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ATANHF) MATH_UNOPF(atanhf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_CEILINGF) MATH_UNOPF(ceilf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_COSF) MATH_UNOPF(cosf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_CBRTF) MATH_UNOPF(cbrtf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_COSHF) MATH_UNOPF(coshf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_EXPF) MATH_UNOPF(expf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_FLOORF) MATH_UNOPF(floorf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOGF) MATH_UNOPF(logf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOG2F) MATH_UNOPF(log2f); MINT_IN_BREAK;
MINT_IN_CASE(MINT_LOG10F) MATH_UNOPF(log10f); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SINF) MATH_UNOPF(sinf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SQRTF) MATH_UNOPF(sqrtf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_SINHF) MATH_UNOPF(sinhf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_TANF) MATH_UNOPF(tanf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_TANHF) MATH_UNOPF(tanhf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_ATAN2F) MATH_BINOPF(atan2f); MINT_IN_BREAK;
MINT_IN_CASE(MINT_POWF) MATH_BINOPF(powf); MINT_IN_BREAK;
MINT_IN_CASE(MINT_FMAF)
LOCAL_VAR (ip [1], float) = fmaf (LOCAL_VAR (ip [2], float), LOCAL_VAR (ip [3], float), LOCAL_VAR (ip [4], float));
ip += 5;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_SCALEBF)
LOCAL_VAR (ip [1], float) = scalbnf (LOCAL_VAR (ip [2], float), LOCAL_VAR (ip [3], gint32));
ip += 4;
MINT_IN_BREAK;
MINT_IN_CASE(MINT_INTRINS_ENUM_HASFLAG) {
MonoClass *klass = (MonoClass*)frame->imethod->data_items [ip [4]];
LOCAL_VAR (ip [1], gint32) = mono_interp_enum_hasflag ((stackval*)(locals + ip [2]), (stackval*)(locals + ip [3]), klass);
ip += 5;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_GET_HASHCODE) {
LOCAL_VAR (ip [1], gint32) = mono_object_hash_internal (LOCAL_VAR (ip [2], MonoObject*));
ip += 3;
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_INTRINS_GET_TYPE) {
MonoObject *o = LOCAL_VAR (ip [2], MonoObject*);
NULL_CHECK (o);
LOCAL_VAR (ip [1], MonoObject*) = (MonoObject*) o->vtable->type;
ip += 3;
MINT_IN_BREAK;
}
#if !USE_COMPUTED_GOTO
default:
interp_error_xsx ("Unimplemented opcode: %04x %s at 0x%x\n", *ip, mono_interp_opname (*ip), ip - frame->imethod->code);
#endif
}
}
g_assert_not_reached ();
resume:
g_assert (context->has_resume_state);
g_assert (frame->imethod);
if (frame == context->handler_frame) {
/*
* When running finally blocks, we can have the same frame twice on the stack. If we have
* clause_args information, we need to check whether resuming should happen inside this
* finally block, or in some other part of the method, in which case we need to exit.
*/
if (clause_args && frame == clause_args->exec_frame && context->handler_ip >= clause_args->end_at_ip) {
goto exit_clause;
} else {
/* Set the current execution state to the resume state in context */
ip = context->handler_ip;
/* spec says stack should be empty at endfinally so it should be at the start too */
locals = (guchar*)frame->stack;
g_assert (context->exc_gchandle);
clear_resume_state (context);
// goto main_loop instead of MINT_IN_DISPATCH helps the compiler and therefore conserves stack.
// This is a slow/rare path and conserving stack is preferred over its performance otherwise.
goto main_loop;
}
} else if (clause_args && frame == clause_args->exec_frame) {
/*
* This frame doesn't handle the resume state and it is the first frame invoked from EH.
* We can't just return to parent. We must first exit the EH mechanism and start resuming
* again from the original frame.
*/
goto exit_clause;
}
// Because we are resuming in another frame, bypassing a normal ret opcode,
// we need to make sure to reset the localloc stack
frame_data_allocator_pop (&context->data_stack, frame);
// fall through
exit_frame:
g_assert_checked (frame->imethod);
if (frame->parent && frame->parent->state.ip) {
/* Return to the main loop after a non-recursive interpreter call */
//printf ("R: %s -> %s %p\n", mono_method_get_full_name (frame->imethod->method), mono_method_get_full_name (frame->parent->imethod->method), frame->parent->state.ip);
g_assert_checked (frame->stack);
frame = frame->parent;
/*
* FIXME We should be able to avoid dereferencing imethod here, if we will have
* a param_area and all calls would inherit the same sp, or if we are full coop.
*/
context->stack_pointer = (guchar*)frame->stack + frame->imethod->alloca_size;
LOAD_INTERP_STATE (frame);
CHECK_RESUME_STATE (context);
goto main_loop;
}
exit_clause:
if (!clause_args)
context->stack_pointer = (guchar*)frame->stack;
DEBUG_LEAVE ();
HANDLE_FUNCTION_RETURN ();
}
static void
interp_parse_options (const char *options)
{
char **args, **ptr;
if (!options)
return;
args = g_strsplit (options, ",", -1);
for (ptr = args; ptr && *ptr; ptr ++) {
char *arg = *ptr;
if (strncmp (arg, "jit=", 4) == 0)
mono_interp_jit_classes = g_slist_prepend (mono_interp_jit_classes, arg + 4);
else if (strncmp (arg, "interp-only=", strlen ("interp-only=")) == 0)
mono_interp_only_classes = g_slist_prepend (mono_interp_only_classes, arg + strlen ("interp-only="));
else if (strncmp (arg, "-inline", 7) == 0)
mono_interp_opt &= ~INTERP_OPT_INLINE;
else if (strncmp (arg, "-cprop", 6) == 0)
mono_interp_opt &= ~INTERP_OPT_CPROP;
else if (strncmp (arg, "-super", 6) == 0)
mono_interp_opt &= ~INTERP_OPT_SUPER_INSTRUCTIONS;
else if (strncmp (arg, "-bblocks", 8) == 0)
mono_interp_opt &= ~INTERP_OPT_BBLOCKS;
else if (strncmp (arg, "-all", 4) == 0)
mono_interp_opt = INTERP_OPT_NONE;
}
}
/*
* interp_set_resume_state:
*
* Set the state the interpeter will continue to execute from after execution returns to the interpreter.
* If INTERP_FRAME is NULL, that means the exception is caught in an AOTed frame and the interpreter needs to
* unwind back to AOT code.
*/
static void
interp_set_resume_state (MonoJitTlsData *jit_tls, MonoObject *ex, MonoJitExceptionInfo *ei, MonoInterpFrameHandle interp_frame, gpointer handler_ip)
{
ThreadContext *context;
g_assert (jit_tls);
context = (ThreadContext*)jit_tls->interp_context;
g_assert (context);
context->has_resume_state = TRUE;
context->handler_frame = (InterpFrame*)interp_frame;
context->handler_ei = ei;
if (context->exc_gchandle)
mono_gchandle_free_internal (context->exc_gchandle);
context->exc_gchandle = mono_gchandle_new_internal ((MonoObject*)ex, FALSE);
/* Ditto */
if (context->handler_frame) {
if (ei)
*(MonoObject**)(frame_locals (context->handler_frame) + ei->exvar_offset) = ex;
}
context->handler_ip = (const guint16*)handler_ip;
}
static void
interp_get_resume_state (const MonoJitTlsData *jit_tls, gboolean *has_resume_state, MonoInterpFrameHandle *interp_frame, gpointer *handler_ip)
{
g_assert (jit_tls);
ThreadContext *context = (ThreadContext*)jit_tls->interp_context;
*has_resume_state = context ? context->has_resume_state : FALSE;
if (!*has_resume_state)
return;
*interp_frame = context->handler_frame;
*handler_ip = (gpointer)context->handler_ip;
}
/*
* interp_run_finally:
*
* Run the finally clause identified by CLAUSE_INDEX in the intepreter frame given by
* frame->interp_frame.
* Return TRUE if the finally clause threw an exception.
*/
static gboolean
interp_run_finally (StackFrameInfo *frame, int clause_index, gpointer handler_ip, gpointer handler_ip_end)
{
InterpFrame *iframe = (InterpFrame*)frame->interp_frame;
ThreadContext *context = get_context ();
FrameClauseArgs clause_args;
const guint16 *state_ip;
memset (&clause_args, 0, sizeof (FrameClauseArgs));
clause_args.start_with_ip = (const guint16*)handler_ip;
clause_args.end_at_ip = (const guint16*)handler_ip_end;
clause_args.exec_frame = iframe;
state_ip = iframe->state.ip;
iframe->state.ip = NULL;
InterpFrame* const next_free = iframe->next_free;
iframe->next_free = NULL;
// this informs MINT_ENDFINALLY to return to EH
*(guint16**)(frame_locals (iframe) + iframe->imethod->clause_data_offsets [clause_index]) = NULL;
interp_exec_method (iframe, context, &clause_args);
iframe->next_free = next_free;
iframe->state.ip = state_ip;
check_pending_unwind (context);
if (context->has_resume_state) {
return TRUE;
} else {
return FALSE;
}
}
/*
* interp_run_filter:
*
* Run the filter clause identified by CLAUSE_INDEX in the intepreter frame given by
* frame->interp_frame.
*/
// Do not inline in case order of frame addresses matters.
static MONO_NEVER_INLINE gboolean
interp_run_filter (StackFrameInfo *frame, MonoException *ex, int clause_index, gpointer handler_ip, gpointer handler_ip_end)
{
InterpFrame *iframe = (InterpFrame*)frame->interp_frame;
ThreadContext *context = get_context ();
stackval retval;
FrameClauseArgs clause_args;
/*
* Have to run the clause in a new frame which is a copy of IFRAME, since
* during debugging, there are two copies of the frame on the stack.
*/
InterpFrame child_frame = {0};
child_frame.parent = iframe;
child_frame.imethod = iframe->imethod;
child_frame.stack = (stackval*)context->stack_pointer;
child_frame.retval = &retval;
/* Copy the stack frame of the original method */
memcpy (child_frame.stack, iframe->stack, iframe->imethod->locals_size);
// Write the exception object in its reserved stack slot
*((MonoException**)((char*)child_frame.stack + iframe->imethod->clause_data_offsets [clause_index])) = ex;
context->stack_pointer += iframe->imethod->alloca_size;
g_assert (context->stack_pointer < context->stack_end);
memset (&clause_args, 0, sizeof (FrameClauseArgs));
clause_args.start_with_ip = (const guint16*)handler_ip;
clause_args.end_at_ip = (const guint16*)handler_ip_end;
clause_args.exec_frame = &child_frame;
interp_exec_method (&child_frame, context, &clause_args);
/* Copy back the updated frame */
memcpy (iframe->stack, child_frame.stack, iframe->imethod->locals_size);
context->stack_pointer = (guchar*)child_frame.stack;
check_pending_unwind (context);
/* ENDFILTER stores the result into child_frame->retval */
return retval.data.i ? TRUE : FALSE;
}
/* Returns TRUE if there is a pending exception */
static gboolean
interp_run_clause_with_il_state (gpointer il_state_ptr, int clause_index, gpointer handler_ip, gpointer handler_ip_end,
MonoObject *ex, gboolean *filtered, MonoExceptionEnum clause_type)
{
MonoMethodILState *il_state = (MonoMethodILState*)il_state_ptr;
MonoMethodSignature *sig;
ThreadContext *context = get_context ();
stackval *orig_sp;
stackval *sp, *sp_args;
InterpMethod *imethod;
FrameClauseArgs clause_args;
ERROR_DECL (error);
sig = mono_method_signature_internal (il_state->method);
g_assert (sig);
imethod = mono_interp_get_imethod (il_state->method, error);
mono_error_assert_ok (error);
orig_sp = sp_args = sp = (stackval*)context->stack_pointer;
gpointer ret_addr = NULL;
int findex = 0;
if (sig->ret->type != MONO_TYPE_VOID) {
ret_addr = il_state->data [findex];
findex ++;
}
if (sig->hasthis) {
if (il_state->data [findex])
sp_args->data.p = *(gpointer*)il_state->data [findex];
sp_args++;
findex ++;
}
for (int i = 0; i < sig->param_count; ++i) {
if (il_state->data [findex]) {
int size = stackval_from_data (sig->params [i], sp_args, il_state->data [findex], FALSE);
sp_args = STACK_ADD_BYTES (sp_args, size);
} else {
int size = stackval_size (sig->params [i], FALSE);
sp_args = STACK_ADD_BYTES (sp_args, size);
}
findex ++;
}
/* Allocate frame */
InterpFrame frame = {0};
frame.imethod = imethod;
frame.stack = sp;
frame.retval = sp;
context->stack_pointer = (guchar*)sp_args;
context->stack_pointer += imethod->alloca_size;
g_assert (context->stack_pointer < context->stack_end);
MonoMethodHeader *header = mono_method_get_header_internal (il_state->method, error);
mono_error_assert_ok (error);
/* Init locals */
if (header->num_locals)
memset (frame_locals (&frame) + imethod->local_offsets [0], 0, imethod->locals_size);
/* Copy locals from il_state */
int locals_start = findex;
for (int i = 0; i < header->num_locals; ++i) {
if (il_state->data [locals_start + i])
stackval_from_data (header->locals [i], (stackval*)(frame_locals (&frame) + imethod->local_offsets [i]), il_state->data [locals_start + i], FALSE);
}
memset (&clause_args, 0, sizeof (FrameClauseArgs));
clause_args.start_with_ip = (const guint16*)handler_ip;
if (clause_type == MONO_EXCEPTION_CLAUSE_NONE || clause_type == MONO_EXCEPTION_CLAUSE_FILTER)
clause_args.end_at_ip = (const guint16*)clause_args.start_with_ip + 0xffffff;
else
clause_args.end_at_ip = (const guint16*)handler_ip_end;
clause_args.exec_frame = &frame;
if (clause_type == MONO_EXCEPTION_CLAUSE_NONE || clause_type == MONO_EXCEPTION_CLAUSE_FILTER)
*(MonoObject**)(frame_locals (&frame) + imethod->jinfo->clauses [clause_index].exvar_offset) = ex;
else
// this informs MINT_ENDFINALLY to return to EH
*(guint16**)(frame_locals (&frame) + imethod->clause_data_offsets [clause_index]) = NULL;
/* Set in mono_handle_exception () */
context->has_resume_state = FALSE;
interp_exec_method (&frame, context, &clause_args);
/* Write back args */
sp_args = sp;
findex = 0;
if (sig->ret->type != MONO_TYPE_VOID)
findex ++;
if (sig->hasthis) {
// FIXME: This
sp_args++;
findex ++;
}
for (int i = 0; i < sig->param_count; ++i) {
if (il_state->data [findex]) {
int size = stackval_to_data (sig->params [i], sp_args, il_state->data [findex], FALSE);
sp_args = STACK_ADD_BYTES (sp_args, size);
} else {
int size = stackval_size (sig->params [i], FALSE);
sp_args = STACK_ADD_BYTES (sp_args, size);
}
findex ++;
}
/* Write back locals */
for (int i = 0; i < header->num_locals; ++i) {
if (il_state->data [locals_start + i])
stackval_to_data (header->locals [i], (stackval*)(frame_locals (&frame) + imethod->local_offsets [i]), il_state->data [locals_start + i], FALSE);
}
mono_metadata_free_mh (header);
if (clause_type == MONO_EXCEPTION_CLAUSE_NONE && ret_addr) {
stackval_to_data (sig->ret, frame.retval, ret_addr, FALSE);
} else if (clause_type == MONO_EXCEPTION_CLAUSE_FILTER) {
g_assert (filtered);
*filtered = frame.retval->data.i;
}
memset (orig_sp, 0, (guint8*)context->stack_pointer - (guint8*)orig_sp);
context->stack_pointer = (guchar*)orig_sp;
check_pending_unwind (context);
return context->has_resume_state;
}
typedef struct {
InterpFrame *current;
} StackIter;
static gpointer
interp_frame_get_ip (MonoInterpFrameHandle frame)
{
InterpFrame *iframe = (InterpFrame*)frame;
g_assert (iframe->imethod);
/*
* For calls, state.ip points to the instruction following the call, so we need to subtract
* in order to get inside the call instruction range. Other instructions that set the IP for
* the rest of the runtime to see, like throws and sdb breakpoints, will need to account for
* this subtraction that we are doing here.
*/
return (gpointer)(iframe->state.ip - 1);
}
/*
* interp_frame_iter_init:
*
* Initialize an iterator for iterating through interpreted frames.
*/
static void
interp_frame_iter_init (MonoInterpStackIter *iter, gpointer interp_exit_data)
{
StackIter *stack_iter = (StackIter*)iter;
stack_iter->current = (InterpFrame*)interp_exit_data;
}
/*
* interp_frame_iter_next:
*
* Fill out FRAME with date for the next interpreter frame.
*/
static gboolean
interp_frame_iter_next (MonoInterpStackIter *iter, StackFrameInfo *frame)
{
StackIter *stack_iter = (StackIter*)iter;
InterpFrame *iframe = stack_iter->current;
memset (frame, 0, sizeof (StackFrameInfo));
/* pinvoke frames doesn't have imethod set */
while (iframe && !(iframe->imethod && iframe->imethod->code && iframe->imethod->jinfo))
iframe = iframe->parent;
if (!iframe)
return FALSE;
MonoMethod *method = iframe->imethod->method;
frame->interp_frame = iframe;
frame->method = method;
frame->actual_method = method;
if (method && ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) || (method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME)))) {
frame->native_offset = -1;
frame->type = FRAME_TYPE_MANAGED_TO_NATIVE;
} else {
frame->type = FRAME_TYPE_INTERP;
/* This is the offset in the interpreter IR. */
frame->native_offset = (guint8*)interp_frame_get_ip (iframe) - (guint8*)iframe->imethod->code;
if (!method->wrapper_type || method->wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD)
frame->managed = TRUE;
}
frame->ji = iframe->imethod->jinfo;
frame->frame_addr = iframe;
stack_iter->current = iframe->parent;
return TRUE;
}
static MonoJitInfo*
interp_find_jit_info (MonoMethod *method)
{
InterpMethod* imethod;
imethod = lookup_imethod (method);
if (imethod)
return imethod->jinfo;
else
return NULL;
}
static void
interp_set_breakpoint (MonoJitInfo *jinfo, gpointer ip)
{
guint16 *code = (guint16*)ip;
g_assert (*code == MINT_SDB_SEQ_POINT);
*code = MINT_SDB_BREAKPOINT;
}
static void
interp_clear_breakpoint (MonoJitInfo *jinfo, gpointer ip)
{
guint16 *code = (guint16*)ip;
g_assert (*code == MINT_SDB_BREAKPOINT);
*code = MINT_SDB_SEQ_POINT;
}
static MonoJitInfo*
interp_frame_get_jit_info (MonoInterpFrameHandle frame)
{
InterpFrame *iframe = (InterpFrame*)frame;
g_assert (iframe->imethod);
return iframe->imethod->jinfo;
}
static gpointer
interp_frame_get_arg (MonoInterpFrameHandle frame, int pos)
{
InterpFrame *iframe = (InterpFrame*)frame;
g_assert (iframe->imethod);
return (char*)iframe->stack + get_arg_offset_fast (iframe->imethod, NULL, pos + iframe->imethod->hasthis);
}
static gpointer
interp_frame_get_local (MonoInterpFrameHandle frame, int pos)
{
InterpFrame *iframe = (InterpFrame*)frame;
g_assert (iframe->imethod);
return frame_locals (iframe) + iframe->imethod->local_offsets [pos];
}
static gpointer
interp_frame_get_this (MonoInterpFrameHandle frame)
{
InterpFrame *iframe = (InterpFrame*)frame;
g_assert (iframe->imethod);
g_assert (iframe->imethod->hasthis);
return iframe->stack;
}
static MonoInterpFrameHandle
interp_frame_get_parent (MonoInterpFrameHandle frame)
{
InterpFrame *iframe = (InterpFrame*)frame;
return iframe->parent;
}
static void
interp_start_single_stepping (void)
{
ss_enabled = TRUE;
}
static void
interp_stop_single_stepping (void)
{
ss_enabled = FALSE;
}
/*
* interp_mark_stack:
*
* Mark the interpreter stack frames for a thread.
*
*/
static void
interp_mark_stack (gpointer thread_data, GcScanFunc func, gpointer gc_data, gboolean precise)
{
MonoThreadInfo *info = (MonoThreadInfo*)thread_data;
if (!mono_use_interpreter)
return;
if (precise)
return;
/*
* We explicitly mark the frames instead of registering the stack fragments as GC roots, so
* we have to process less data and avoid false pinning from data which is above 'pos'.
*
* The stack frame handling code uses compiler write barriers only, but the calling code
* in sgen-mono.c already did a mono_memory_barrier_process_wide () so we can
* process these data structures normally.
*/
MonoJitTlsData *jit_tls = (MonoJitTlsData *)info->tls [TLS_KEY_JIT_TLS];
if (!jit_tls)
return;
ThreadContext *context = (ThreadContext*)jit_tls->interp_context;
if (!context || !context->stack_start)
return;
// FIXME: Scan the whole area with 1 call
for (gpointer *p = (gpointer*)context->stack_start; p < (gpointer*)context->stack_pointer; p++)
func (p, gc_data);
FrameDataFragment *frag;
for (frag = context->data_stack.first; frag; frag = frag->next) {
// FIXME: Scan the whole area with 1 call
for (gpointer *p = (gpointer*)&frag->data; p < (gpointer*)frag->pos; ++p)
func (p, gc_data);
if (frag == context->data_stack.current)
break;
}
}
#if COUNT_OPS
static int
opcode_count_comparer (const void * pa, const void * pb)
{
long counta = opcode_counts [*(int*)pa];
long countb = opcode_counts [*(int*)pb];
if (counta < countb)
return 1;
else if (counta > countb)
return -1;
else
return 0;
}
static void
interp_print_op_count (void)
{
int ordered_ops [MINT_LASTOP];
int i;
long total_ops = 0;
for (i = 0; i < MINT_LASTOP; i++) {
ordered_ops [i] = i;
total_ops += opcode_counts [i];
}
qsort (ordered_ops, MINT_LASTOP, sizeof (int), opcode_count_comparer);
g_print ("total ops %ld\n", total_ops);
for (i = 0; i < MINT_LASTOP; i++) {
long count = opcode_counts [ordered_ops [i]];
g_print ("%s : %ld (%.2lf%%)\n", mono_interp_opname (ordered_ops [i]), count, (double)count / total_ops * 100);
}
}
#endif
#if PROFILE_INTERP
static InterpMethod **imethods;
static int num_methods;
const int opcount_threshold = 100000;
static void
interp_add_imethod (gpointer method, gpointer user_data)
{
InterpMethod *imethod = (InterpMethod*) method;
if (imethod->opcounts > opcount_threshold)
imethods [num_methods++] = imethod;
}
static int
imethod_opcount_comparer (gconstpointer m1, gconstpointer m2)
{
long diff = (*(InterpMethod**)m2)->opcounts > (*(InterpMethod**)m1)->opcounts;
if (diff > 0)
return 1;
else if (diff < 0)
return -1;
else
return 0;
}
static void
interp_print_method_counts (void)
{
MonoJitMemoryManager *jit_mm = get_default_jit_mm ();
jit_mm_lock (jit_mm);
imethods = (InterpMethod**) malloc (jit_mm->interp_code_hash.num_entries * sizeof (InterpMethod*));
mono_internal_hash_table_apply (&jit_mm->interp_code_hash, interp_add_imethod, NULL);
jit_mm_unlock (jit_mm);
qsort (imethods, num_methods, sizeof (InterpMethod*), imethod_opcount_comparer);
printf ("Total executed opcodes %ld\n", total_executed_opcodes);
long cumulative_executed_opcodes = 0;
for (int i = 0; i < num_methods; i++) {
cumulative_executed_opcodes += imethods [i]->opcounts;
printf ("%d%% Opcounts %ld, calls %ld, Method %s, imethod ptr %p\n", (int)(cumulative_executed_opcodes * 100 / total_executed_opcodes), imethods [i]->opcounts, imethods [i]->calls, mono_method_full_name (imethods [i]->method, TRUE), imethods [i]);
}
}
#endif
static void
interp_set_optimizations (guint32 opts)
{
mono_interp_opt = opts;
}
static void
invalidate_transform (gpointer imethod_, gpointer user_data)
{
InterpMethod *imethod = (InterpMethod *) imethod_;
imethod->transformed = FALSE;
}
static void
copy_imethod_for_frame (InterpFrame *frame)
{
InterpMethod *copy = (InterpMethod *) m_method_alloc0 (frame->imethod->method, sizeof (InterpMethod));
memcpy (copy, frame->imethod, sizeof (InterpMethod));
copy->next_jit_code_hash = NULL; /* we don't want that in our copy */
frame->imethod = copy;
/* Note: The copy will be around until the method is unloaded. Ideally we
* would reclaim its memory when the corresponding InterpFrame is popped.
*/
}
static void
metadata_update_backup_frames (MonoThreadInfo *info, InterpFrame *frame)
{
while (frame) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_METADATA_UPDATE, "threadinfo=%p, copy imethod for method=%s", info, mono_method_full_name (frame->imethod->method, 1));
copy_imethod_for_frame (frame);
frame = frame->parent;
}
}
static void
metadata_update_prepare_to_invalidate (void)
{
/* (1) make a copy of imethod for every interpframe that is on the stack,
* so we do not invalidate currently running methods */
FOREACH_THREAD_EXCLUDE (info, MONO_THREAD_INFO_FLAGS_NO_GC) {
if (!info || !info->jit_data)
continue;
MonoLMF *lmf = info->jit_data->lmf;
while (lmf) {
if (((gsize) lmf->previous_lmf) & 2) {
MonoLMFExt *ext = (MonoLMFExt *) lmf;
if (ext->kind == MONO_LMFEXT_INTERP_EXIT || ext->kind == MONO_LMFEXT_INTERP_EXIT_WITH_CTX) {
InterpFrame *frame = ext->interp_exit_data;
metadata_update_backup_frames (info, frame);
}
}
lmf = (MonoLMF *)(((gsize) lmf->previous_lmf) & ~3);
}
} FOREACH_THREAD_END
/* (2) invalidate all the registered imethods */
}
static void
interp_invalidate_transformed (void)
{
gboolean need_stw_restart = FALSE;
if (mono_metadata_has_updates ()) {
mono_stop_world (MONO_THREAD_INFO_FLAGS_NO_GC);
metadata_update_prepare_to_invalidate ();
need_stw_restart = TRUE;
}
// FIXME: Enumerate all memory managers
MonoJitMemoryManager *jit_mm = get_default_jit_mm ();
jit_mm_lock (jit_mm);
mono_internal_hash_table_apply (&jit_mm->interp_code_hash, invalidate_transform, NULL);
jit_mm_unlock (jit_mm);
if (need_stw_restart)
mono_restart_world (MONO_THREAD_INFO_FLAGS_NO_GC);
}
typedef struct {
MonoJitInfo **jit_info_array;
gint size;
gint next;
} InterpCopyJitInfoFuncUserData;
static void
interp_copy_jit_info_func (gpointer imethod, gpointer user_data)
{
InterpCopyJitInfoFuncUserData *data = (InterpCopyJitInfoFuncUserData*)user_data;
if (data->next < data->size)
data->jit_info_array [data->next++] = ((InterpMethod *)imethod)->jinfo;
}
static void
interp_jit_info_foreach (InterpJitInfoFunc func, gpointer user_data)
{
InterpCopyJitInfoFuncUserData copy_jit_info_data;
// FIXME: Enumerate all memory managers
MonoJitMemoryManager *jit_mm = get_default_jit_mm ();
// Can't keep memory manager lock while iterating and calling callback since it might take other locks
// causing poential deadlock situations. Instead, create copy of interpreter imethod jinfo pointers into
// plain array and use pointers from array when when running callbacks.
copy_jit_info_data.size = mono_atomic_load_i32 (&(jit_mm->interp_code_hash.num_entries));
copy_jit_info_data.next = 0;
copy_jit_info_data.jit_info_array = (MonoJitInfo**) g_new (MonoJitInfo*, copy_jit_info_data.size);
if (copy_jit_info_data.jit_info_array) {
jit_mm_lock (jit_mm);
mono_internal_hash_table_apply (&jit_mm->interp_code_hash, interp_copy_jit_info_func, ©_jit_info_data);
jit_mm_unlock (jit_mm);
}
if (copy_jit_info_data.jit_info_array) {
for (size_t i = 0; i < copy_jit_info_data.next; ++i)
func (copy_jit_info_data.jit_info_array [i], user_data);
g_free (copy_jit_info_data.jit_info_array);
}
}
static gboolean
interp_sufficient_stack (gsize size)
{
ThreadContext *context = get_context ();
return (context->stack_pointer + size) < (context->stack_start + INTERP_STACK_SIZE);
}
static void
interp_cleanup (void)
{
#if COUNT_OPS
interp_print_op_count ();
#endif
#if PROFILE_INTERP
interp_print_method_counts ();
#endif
}
static void
register_interp_stats (void)
{
mono_counters_init ();
mono_counters_register ("Total transform time", MONO_COUNTER_INTERP | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &mono_interp_stats.transform_time);
mono_counters_register ("Methods transformed", MONO_COUNTER_INTERP | MONO_COUNTER_LONG, &mono_interp_stats.methods_transformed);
mono_counters_register ("Total cprop time", MONO_COUNTER_INTERP | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &mono_interp_stats.cprop_time);
mono_counters_register ("Total super instructions time", MONO_COUNTER_INTERP | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &mono_interp_stats.super_instructions_time);
mono_counters_register ("STLOC_NP count", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.stloc_nps);
mono_counters_register ("MOVLOC count", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.movlocs);
mono_counters_register ("Copy propagations", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.copy_propagations);
mono_counters_register ("Added pop count", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.added_pop_count);
mono_counters_register ("Constant folds", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.constant_folds);
mono_counters_register ("Ldlocas removed", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.ldlocas_removed);
mono_counters_register ("Super instructions", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.super_instructions);
mono_counters_register ("Killed instructions", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.killed_instructions);
mono_counters_register ("Emitted instructions", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.emitted_instructions);
mono_counters_register ("Methods inlined", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.inlined_methods);
mono_counters_register ("Inline failures", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.inline_failures);
}
#undef MONO_EE_CALLBACK
#define MONO_EE_CALLBACK(ret, name, sig) interp_ ## name,
static const MonoEECallbacks mono_interp_callbacks = {
MONO_EE_CALLBACKS
};
void
mono_ee_interp_init (const char *opts)
{
g_assert (mono_ee_api_version () == MONO_EE_API_VERSION);
g_assert (!interp_init_done);
interp_init_done = TRUE;
mono_native_tls_alloc (&thread_context_id, NULL);
set_context (NULL);
interp_parse_options (opts);
/* Don't do any optimizations if running under debugger */
if (mini_get_debug_options ()->mdb_optimizations)
mono_interp_opt = 0;
mono_interp_transform_init ();
mini_install_interp_callbacks (&mono_interp_callbacks);
register_interp_stats ();
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/ia64/Lparser.c | #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gparser.c"
#endif
| #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gparser.c"
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./docs/area-owners.md | # Pull Requests Tagging
If you need to tag folks on an issue or PR, you will generally want to tag the owners (not the lead) for [area](#areas) to which the change or issue is closest to. For areas which are large and can be operating system or architecture specific it's better to tag owners of [OS](#operating-systems) or [Architecture](#architectures).
## Areas
Note: Editing this file doesn't update the mapping used by `@msftbot` for area-specific issue/PR notifications. That configuration is part of the [`fabricbot.json`](../.github/fabricbot.json) file, and many areas use GitHub teams for those notifications. If you're a community member interested in receiving area-specific issue/PR notifications, you won't appear in this table or be added to those GitHub teams, but you can create a PR that updates `fabricbot.json` to add yourself to those notifications. See [automation.md](infra/automation.md) for more information on the schema and tools used by FabricBot.
| Area | Lead | Owners (area experts to tag in PR's and issues) | Notes |
|------------------------------------------------|---------------|-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| area-AssemblyLoader-coreclr | @agocke | @agocke @vitek-karas @vsadov | |
| area-AssemblyLoader-mono | @SamMonoRT | @lambdageek | |
| area-Build-mono | @steveisok | @akoeplinger | |
| area-Codeflow | @dotnet/dnr-codeflow | @dotnet/dnr-codeflow | Used for automated PR's that ingest code from other repos |
| area-Codegen-AOT-mono | @SamMonoRT | @vargaz | |
| area-CodeGen-coreclr | @JulieLeeMSFT | @BruceForstall @dotnet/jit-contrib | |
| area-Codegen-Interpreter-mono | @SamMonoRT | @BrzVlad | |
| area-Codegen-JIT-mono | @SamMonoRT | @vargaz | |
| area-Codegen-LLVM-mono | @SamMonoRT | @vargaz | |
| area-Codegen-meta-mono | @SamMonoRT | @vargaz | |
| area-CoreLib-mono | @steveisok | @vargaz | |
| area-CrossGen/NGEN-coreclr | @mangod9 | @dotnet/crossgen-contrib | |
| area-crossgen2-coreclr | @mangod9 | @trylek @dotnet/crossgen-contrib | |
| area-Debugger-mono | @lewing | @thaystg @radical | |
| area-DependencyModel | @ericstj | @dotnet/area-dependencymodel | <ul><li>Microsoft.Extensions.DependencyModel</li></ul> |
| area-Diagnostics-coreclr | @tommcdon | @tommcdon | |
| area-EnC-mono | @marek-safar | @lambdageek | Hot Reload on WebAssembly, Android, iOS, etc |
| area-ExceptionHandling-coreclr | @mangod9 | @janvorli | |
| area-Extensions-Caching | @ericstj | @dotnet/area-extensions-caching | |
| area-Extensions-Configuration | @ericstj | @dotnet/area-extensions-configuration | |
| area-Extensions-DependencyInjection | @ericstj | @dotnet/area-extensions-dependencyinjection | |
| area-Extensions-FileSystem | @jeffhandley | @dotnet/area-extensions-filesystem | |
| area-Extensions-Hosting | @ericstj | @dotnet/area-extensions-hosting | |
| area-Extensions-HttpClientFactory | @karelz | @dotnet/ncl | |
| area-Extensions-Logging | @ericstj | @dotnet/area-extensions-logging | |
| area-Extensions-Options | @ericstj | @dotnet/area-extensions-options | |
| area-Extensions-Primitives | @ericstj | @dotnet/area-extensions-primitives | |
| area-GC-coreclr | @mangod9 | @Maoni0 | |
| area-GC-mono | @SamMonoRT | @BrzVlad | |
| area-Host | @agocke | @jeffschwMSFT @vitek-karas @vsadov | Issues with dotnet.exe including bootstrapping, framework detection, hostfxr.dll and hostpolicy.dll |
| area-HostModel | @agocke | @vitek-karas | |
| area-ILTools-coreclr | @JulieLeeMSFT | @BruceForstall @dotnet/jit-contrib | |
| area-ILVerification | @JulieLeeMSFT | @BruceForstall @dotnet/jit-contrib | |
| area-Infrastructure | @agocke | @jeffschwMSFT @dleeapho | |
| area-Infrastructure-coreclr | @agocke | @jeffschwMSFT @trylek | |
| area-Infrastructure-installer | @dleeapho | @dleeapho @NikolaMilosavljevic | |
| area-Infrastructure-libraries | @ericstj | @dotnet/area-infrastructure-libraries | Covers:<ul><li>Packaging</li><li>Build and test infra for libraries in dotnet/runtime repo</li><li>VS integration</li></ul><br/> |
| area-Infrastructure-mono | @steveisok | @directhex | |
| area-Interop-coreclr | @jeffschwMSFT | @jeffschwMSFT @AaronRobinsonMSFT | |
| area-Interop-mono | @marek-safar | @lambdageek | |
| area-Meta | @danmoseley | @dotnet/area-meta | Cross-cutting concerns that span many or all areas, including project-wide code/test patterns and documentation. |
| area-Microsoft.CSharp | @jaredpar | @cston @333fred | Archived component - limited churn/contributions (see [#27790](https://github.com/dotnet/runtime/issues/27790)) |
| area-Microsoft.Extensions | @ericstj | @dotnet/area-microsoft-extensions | |
| area-Microsoft.VisualBasic | @jaredpar | @cston @333fred | Archived component - limited churn/contributions (see [#27790](https://github.com/dotnet/runtime/issues/27790)) |
| area-Microsoft.Win32 | @ericstj | @dotnet/area-microsoft-win32 | Including System.Windows.Extensions |
| area-NativeAOT-coreclr | @agocke | @MichalStrehovsky @jkotas | |
| area-PAL-coreclr | @mangod9 | @janvorli | |
| area-Performance-mono | @SamMonoRT | @SamMonoRT | |
| area-R2RDump-coreclr | @mangod9 | @trylek | |
| area-ReadyToRun-coreclr | @mangod9 | @trylek | |
| area-Serialization | @HongGit | @StephenMolloy @HongGit | Packages:<ul><li>System.Runtime.Serialization.Xml</li><li>System.Runtime.Serialization.Json</li><li>System.Private.DataContractSerialization</li><li>System.Xml.XmlSerializer</li></ul> Excluded:<ul><li>System.Runtime.Serialization.Formatters</li></ul> |
| area-Setup | @dleeapho | @NikolaMilosavljevic @dleeapho | Distro-specific (Linux, Mac and Windows) setup packages and msi files |
| area-Single-File | @agocke | @vitek-karas @vsadov | |
| area-Snap | @dleeapho | @dleeapho @leecow @MichaelSimons | |
| area-System.Buffers | @jeffhandley | @dotnet/area-system-buffers | |
| area-System.CodeDom | @ericstj | @dotnet/area-system-codedom | |
| area-System.Collections | @jeffhandley | @dotnet/area-system-collections | Excluded:<ul><li>System.Array -> System.Runtime</li></ul> |
| area-System.ComponentModel | @ericstj | @dotnet/area-system-componentmodel | |
| area-System.ComponentModel.Composition | @ericstj | @dotnet/area-system-componentmodel-composition | |
| area-System.ComponentModel.DataAnnotations | @ajcvickers | @lajones @ajcvickers | Included:<ul><li>System.ComponentModel.Annotations</li></ul> |
| area-System.Composition | @ericstj | @dotnet/area-system-composition | |
| area-System.Configuration | @ericstj | @dotnet/area-system-configuration | |
| area-System.Console | @jeffhandley | @dotnet/area-system-console | |
| area-System.Data | @ajcvickers | @ajcvickers @davoudeshtehari @david-engel | <ul><li>Odbc, OleDb - @saurabh500</li></ul> |
| area-System.Data.Odbc | @ajcvickers | @ajcvickers | |
| area-System.Data.OleDB | @ajcvickers | @ajcvickers | |
| area-System.Data.SqlClient | @David-Engel | @davoudeshtehari @david-engel @jrahnama | Archived component - limited churn/contributions (see https://devblogs.microsoft.com/dotnet/introducing-the-new-microsoftdatasqlclient/) |
| area-System.Diagnostics | @tommcdon | @tommcdon | |
| area-System.Diagnostics-coreclr | @tommcdon | @tommcdon | |
| area-System.Diagnostics-mono | @lewing | @thaystg @radical | |
| area-System.Diagnostics.Activity | @tommcdon | @eerhardt @maryamariyan @tarekgh | |
| area-System.Diagnostics.EventLog | @ericstj | @dotnet/area-system-diagnostics-eventlog | |
| area-System.Diagnostics.Metric | @tommcdon | @noahfalk | |
| area-System.Diagnostics.PerformanceCounter | @ericstj | @dotnet/area-system-diagnostics-performancecounter | |
| area-System.Diagnostics.Process | @jeffhandley | @dotnet/area-system-diagnostics-process | |
| area-System.Diagnostics.Tracing | @tommcdon | @noahfalk @tommcdon @tarekgh | Included: <ul><li>System.Diagnostics.DiagnosticSource</li><li>System.Diagnostics.TraceSource</li></ul> |
| area-System.Diagnostics.TraceSource | @ericstj | @dotnet/area-system-diagnostics-tracesource | |
| area-System.DirectoryServices | @ericstj | @dotnet/area-system-directoryservices | Consultants: @BRDPM @grubioe @jay98014 |
| area-System.Drawing | @ericstj | @dotnet/area-system-drawing | |
| area-System.Dynamic.Runtime | @jaredpar | @cston @333fred | Archived component - limited churn/contributions (see [#27790](https://github.com/dotnet/runtime/issues/27790)) |
| area-System.Formats.Asn1 | @jeffhandley | @dotnet/area-system-formats-asn1 | |
| area-System.Formats.Cbor | @jeffhandley | @dotnet/area-system-formats-cbor | |
| area-System.Globalization | @ericstj | @dotnet/area-system-globalization | |
| area-System.IO | @jeffhandley | @dotnet/area-system-io | |
| area-System.IO.Compression | @jeffhandley | @dotnet/area-system-io-compression | <ul><li>Also includes System.IO.Packaging</li></ul> |
| area-System.IO.Pipelines | @kevinpi | @davidfowl @halter73 @jkotalik | |
| area-System.Linq | @jeffhandley | @dotnet/area-system-linq | |
| area-System.Linq.Expressions | @jaredpar | @cston @333fred | Archived component - limited churn/contributions (see [#27790](https://github.com/dotnet/runtime/issues/27790)) |
| area-System.Linq.Parallel | @jeffhandley | @dotnet/area-system-linq-parallel | Consultants: @stephentoub @kouvel |
| area-System.Management | @ericstj | @dotnet/area-system-management | WMI |
| area-System.Memory | @jeffhandley | @dotnet/area-system-memory | |
| area-System.Net | @karelz | @dotnet/ncl | Included:<ul><li>System.Uri</li></ul> |
| area-System.Net.Http | @karelz | @dotnet/ncl | |
| area-System.Net.Quic | @karelz | @dotnet/ncl | |
| area-System.Net.Security | @karelz | @dotnet/ncl | |
| area-System.Net.Sockets | @karelz | @dotnet/ncl | |
| area-System.Numerics | @jeffhandley | @dotnet/area-system-numerics | |
| area-System.Numerics.Tensors | @jeffhandley | @dotnet/area-system-numerics-tensors | |
| area-System.Reflection | @ericstj | @dotnet/area-system-reflection | |
| area-System.Reflection-mono | @SamMonoRT | @lambdageek | MonoVM-specific reflection and reflection-emit issues |
| area-System.Reflection.Emit | @ericstj | @dotnet/area-system-reflection-emit | |
| area-System.Reflection.Metadata | @ericstj | @dotnet/area-system-reflection-metadata | Consultants: @tmat |
| area-System.Resources | @ericstj | @dotnet/area-system-resources | |
| area-System.Runtime | @jeffhandley | @dotnet/area-system-runtime | Included:<ul><li>System.Runtime.Serialization.Formatters</li><li>System.Runtime.InteropServices.RuntimeInfo</li><li>System.Array</li></ul>Excluded:<ul><li>Path -> System.IO</li><li>StopWatch -> System.Diagnostics</li><li>Uri -> System.Net</li><li>WebUtility -> System.Net</li></ul> |
| area-System.Runtime.Caching | @HongGit | @StephenMolloy @HongGit | |
| area-System.Runtime.CompilerServices | @ericstj | @dotnet/area-system-runtime-compilerservices | |
| area-System.Runtime.InteropServices | @jeffschwMSFT | @AaronRobinsonMSFT @jkoritzinsky | Excluded:<ul><li>System.Runtime.InteropServices.RuntimeInfo</li></ul> |
| area-System.Runtime.InteropServices.JavaScript | @lewing | @kjpou1 | |
| area-System.Runtime.Intrinsics | @jeffhandley | @dotnet/area-system-runtime-intrinsics | Consultants: @echesakovMSFT @kunalspathak |
| area-System.Security | @jeffhandley | @dotnet/area-system-security | |
| area-System.ServiceModel | @HongGit | @HongGit @mconnew | Repo: https://github.com/dotnet/WCF<br>Packages:<ul><li>System.ServiceModel.Primitives</li><li>System.ServiceModel.Http</li><li>System.ServiceModel.NetTcp</li><li>System.ServiceModel.Duplex</li><li>System.ServiceModel.Security</li></ul> |
| area-System.ServiceModel.Syndication | @HongGit | @StephenMolloy @HongGit | |
| area-System.ServiceProcess | @ericstj | @dotnet/area-system-serviceprocess | |
| area-System.Speech | @danmoseley | @danmoseley | |
| area-System.Text.Encoding | @jeffhandley | @dotnet/area-system-text-encoding | |
| area-System.Text.Encodings.Web | @jeffhandley | @dotnet/area-system-text-encodings-web | |
| area-System.Text.Json | @jeffhandley | @dotnet/area-system-text-json | |
| area-System.Text.RegularExpressions | @ericstj | @dotnet/area-system-text-regularexpressions | Consultants: @stephentoub |
| area-System.Threading | @mangod9 | @kouvel | |
| area-System.Threading.Channels | @ericstj | @dotnet/area-system-threading-channels | Consultants: @stephentoub |
| area-System.Threading.RateLimiting | @rafikiassumani-msft | @BrennanConroy @halter73 | Consultants: @eerhardt |
| area-System.Threading.Tasks | @ericstj | @dotnet/area-system-threading-tasks | Consultants: @stephentoub |
| area-System.Transactions | @HongGit | @HongGit | |
| area-System.Xml | @jeffhandley | @dotnet/area-system-xml | |
| area-Threading-mono | @SamMonoRT | @lambdageek | |
| area-TieredCompilation-coreclr | @mangod9 | @kouvel | |
| area-Tracing-coreclr | @tommcdon | @sywhang @josalem | |
| area-Tracing-mono | @steveisok | @lateralusX | |
| area-TypeSystem-coreclr | @mangod9 | @davidwrighton @MichalStrehovsky @janvorli @mangod9 | |
| area-UWP | @tommcdon | @jashook | UWP-specific issues including Microsoft.NETCore.UniversalWindowsPlatform and Microsoft.Net.UWPCoreRuntimeSdk |
| area-VM-coreclr | @mangod9 | @mangod9 | |
| area-VM-meta-mono | @SamMonoRT | @lambdageek | |
## Operating Systems
| Operating System | Lead | Owners (area experts to tag in PR's and issues) | Description |
|------------------|---------------|-----------------------------------------------------|--------------|
| os-alpine | | | |
| os-android | @steveisok | @akoeplinger | |
| os-freebsd | | | |
| os-mac-os-x | | | |
| os-maccatalyst | @steveisok | | |
| os-ios | @steveisok | @vargaz | |
| os-tvos | @steveisok | @vargaz | |
## Architectures
| Architecture | Lead | Owners (area experts to tag in PR's and issues) | Description |
|------------------|---------------|-----------------------------------------------------|--------------|
| arch-wasm | @lewing | @lewing @BrzVlad | |
## Community Triagers
The repo has a number of community members carrying the triager role. While not necessarily associated with a specific area, they may assist with labeling issues and pull requests. Currently, the following community members are triagers:
* @huoyaoyuan
* @SingleAccretion
* @teo-tsirpanis
* @tmds
* @vcsjones
| # Pull Requests Tagging
If you need to tag folks on an issue or PR, you will generally want to tag the owners (not the lead) for [area](#areas) to which the change or issue is closest to. For areas which are large and can be operating system or architecture specific it's better to tag owners of [OS](#operating-systems) or [Architecture](#architectures).
## Areas
Note: Editing this file doesn't update the mapping used by `@msftbot` for area-specific issue/PR notifications. That configuration is part of the [`fabricbot.json`](../.github/fabricbot.json) file, and many areas use GitHub teams for those notifications. If you're a community member interested in receiving area-specific issue/PR notifications, you won't appear in this table or be added to those GitHub teams, but you can create a PR that updates `fabricbot.json` to add yourself to those notifications. See [automation.md](infra/automation.md) for more information on the schema and tools used by FabricBot.
| Area | Lead | Owners (area experts to tag in PR's and issues) | Notes |
|------------------------------------------------|---------------|-----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| area-AssemblyLoader-coreclr | @agocke | @agocke @vitek-karas @vsadov | |
| area-AssemblyLoader-mono | @SamMonoRT | @lambdageek | |
| area-Build-mono | @steveisok | @akoeplinger | |
| area-Codeflow | @dotnet/dnr-codeflow | @dotnet/dnr-codeflow | Used for automated PR's that ingest code from other repos |
| area-Codegen-AOT-mono | @SamMonoRT | @vargaz | |
| area-CodeGen-coreclr | @JulieLeeMSFT | @BruceForstall @dotnet/jit-contrib | |
| area-Codegen-Interpreter-mono | @SamMonoRT | @BrzVlad | |
| area-Codegen-JIT-mono | @SamMonoRT | @vargaz | |
| area-Codegen-LLVM-mono | @SamMonoRT | @vargaz | |
| area-Codegen-meta-mono | @SamMonoRT | @vargaz | |
| area-CoreLib-mono | @steveisok | @vargaz | |
| area-CrossGen/NGEN-coreclr | @mangod9 | @dotnet/crossgen-contrib | |
| area-crossgen2-coreclr | @mangod9 | @trylek @dotnet/crossgen-contrib | |
| area-Debugger-mono | @lewing | @thaystg @radical | |
| area-DependencyModel | @ericstj | @dotnet/area-dependencymodel | <ul><li>Microsoft.Extensions.DependencyModel</li></ul> |
| area-Diagnostics-coreclr | @tommcdon | @tommcdon | |
| area-EnC-mono | @marek-safar | @lambdageek | Hot Reload on WebAssembly, Android, iOS, etc |
| area-ExceptionHandling-coreclr | @mangod9 | @janvorli | |
| area-Extensions-Caching | @ericstj | @dotnet/area-extensions-caching | |
| area-Extensions-Configuration | @ericstj | @dotnet/area-extensions-configuration | |
| area-Extensions-DependencyInjection | @ericstj | @dotnet/area-extensions-dependencyinjection | |
| area-Extensions-FileSystem | @jeffhandley | @dotnet/area-extensions-filesystem | |
| area-Extensions-Hosting | @ericstj | @dotnet/area-extensions-hosting | |
| area-Extensions-HttpClientFactory | @karelz | @dotnet/ncl | |
| area-Extensions-Logging | @ericstj | @dotnet/area-extensions-logging | |
| area-Extensions-Options | @ericstj | @dotnet/area-extensions-options | |
| area-Extensions-Primitives | @ericstj | @dotnet/area-extensions-primitives | |
| area-GC-coreclr | @mangod9 | @Maoni0 | |
| area-GC-mono | @SamMonoRT | @BrzVlad | |
| area-Host | @agocke | @jeffschwMSFT @vitek-karas @vsadov | Issues with dotnet.exe including bootstrapping, framework detection, hostfxr.dll and hostpolicy.dll |
| area-HostModel | @agocke | @vitek-karas | |
| area-ILTools-coreclr | @JulieLeeMSFT | @BruceForstall @dotnet/jit-contrib | |
| area-ILVerification | @JulieLeeMSFT | @BruceForstall @dotnet/jit-contrib | |
| area-Infrastructure | @agocke | @jeffschwMSFT @dleeapho | |
| area-Infrastructure-coreclr | @agocke | @jeffschwMSFT @trylek | |
| area-Infrastructure-installer | @dleeapho | @dleeapho @NikolaMilosavljevic | |
| area-Infrastructure-libraries | @ericstj | @dotnet/area-infrastructure-libraries | Covers:<ul><li>Packaging</li><li>Build and test infra for libraries in dotnet/runtime repo</li><li>VS integration</li></ul><br/> |
| area-Infrastructure-mono | @steveisok | @directhex | |
| area-Interop-coreclr | @jeffschwMSFT | @jeffschwMSFT @AaronRobinsonMSFT | |
| area-Interop-mono | @marek-safar | @lambdageek | |
| area-Meta | @danmoseley | @dotnet/area-meta | Cross-cutting concerns that span many or all areas, including project-wide code/test patterns and documentation. |
| area-Microsoft.CSharp | @jaredpar | @cston @333fred | Archived component - limited churn/contributions (see [#27790](https://github.com/dotnet/runtime/issues/27790)) |
| area-Microsoft.Extensions | @ericstj | @dotnet/area-microsoft-extensions | |
| area-Microsoft.VisualBasic | @jaredpar | @cston @333fred | Archived component - limited churn/contributions (see [#27790](https://github.com/dotnet/runtime/issues/27790)) |
| area-Microsoft.Win32 | @ericstj | @dotnet/area-microsoft-win32 | Including System.Windows.Extensions |
| area-NativeAOT-coreclr | @agocke | @MichalStrehovsky @jkotas | |
| area-PAL-coreclr | @mangod9 | @janvorli | |
| area-Performance-mono | @SamMonoRT | @SamMonoRT | |
| area-R2RDump-coreclr | @mangod9 | @trylek | |
| area-ReadyToRun-coreclr | @mangod9 | @trylek | |
| area-Serialization | @HongGit | @StephenMolloy @HongGit | Packages:<ul><li>System.Runtime.Serialization.Xml</li><li>System.Runtime.Serialization.Json</li><li>System.Private.DataContractSerialization</li><li>System.Xml.XmlSerializer</li></ul> Excluded:<ul><li>System.Runtime.Serialization.Formatters</li></ul> |
| area-Setup | @dleeapho | @NikolaMilosavljevic @dleeapho | Distro-specific (Linux, Mac and Windows) setup packages and msi files |
| area-Single-File | @agocke | @vitek-karas @vsadov | |
| area-Snap | @dleeapho | @dleeapho @leecow @MichaelSimons | |
| area-System.Buffers | @jeffhandley | @dotnet/area-system-buffers | |
| area-System.CodeDom | @ericstj | @dotnet/area-system-codedom | |
| area-System.Collections | @jeffhandley | @dotnet/area-system-collections | Excluded:<ul><li>System.Array -> System.Runtime</li></ul> |
| area-System.ComponentModel | @ericstj | @dotnet/area-system-componentmodel | |
| area-System.ComponentModel.Composition | @ericstj | @dotnet/area-system-componentmodel-composition | |
| area-System.ComponentModel.DataAnnotations | @ajcvickers | @lajones @ajcvickers | Included:<ul><li>System.ComponentModel.Annotations</li></ul> |
| area-System.Composition | @ericstj | @dotnet/area-system-composition | |
| area-System.Configuration | @ericstj | @dotnet/area-system-configuration | |
| area-System.Console | @jeffhandley | @dotnet/area-system-console | |
| area-System.Data | @ajcvickers | @ajcvickers @davoudeshtehari @david-engel | <ul><li>Odbc, OleDb - @saurabh500</li></ul> |
| area-System.Data.Odbc | @ajcvickers | @ajcvickers | |
| area-System.Data.OleDB | @ajcvickers | @ajcvickers | |
| area-System.Data.SqlClient | @David-Engel | @davoudeshtehari @david-engel @jrahnama | Archived component - limited churn/contributions (see https://devblogs.microsoft.com/dotnet/introducing-the-new-microsoftdatasqlclient/) |
| area-System.Diagnostics | @tommcdon | @tommcdon | |
| area-System.Diagnostics-coreclr | @tommcdon | @tommcdon | |
| area-System.Diagnostics-mono | @lewing | @thaystg @radical | |
| area-System.Diagnostics.Activity | @tommcdon | @eerhardt @maryamariyan @tarekgh | |
| area-System.Diagnostics.EventLog | @ericstj | @dotnet/area-system-diagnostics-eventlog | |
| area-System.Diagnostics.Metric | @tommcdon | @noahfalk | |
| area-System.Diagnostics.PerformanceCounter | @ericstj | @dotnet/area-system-diagnostics-performancecounter | |
| area-System.Diagnostics.Process | @jeffhandley | @dotnet/area-system-diagnostics-process | |
| area-System.Diagnostics.Tracing | @tommcdon | @noahfalk @tommcdon @tarekgh | Included: <ul><li>System.Diagnostics.DiagnosticSource</li><li>System.Diagnostics.TraceSource</li></ul> |
| area-System.Diagnostics.TraceSource | @ericstj | @dotnet/area-system-diagnostics-tracesource | |
| area-System.DirectoryServices | @ericstj | @dotnet/area-system-directoryservices | Consultants: @BRDPM @grubioe @jay98014 |
| area-System.Drawing | @ericstj | @dotnet/area-system-drawing | |
| area-System.Dynamic.Runtime | @jaredpar | @cston @333fred | Archived component - limited churn/contributions (see [#27790](https://github.com/dotnet/runtime/issues/27790)) |
| area-System.Formats.Asn1 | @jeffhandley | @dotnet/area-system-formats-asn1 | |
| area-System.Formats.Cbor | @jeffhandley | @dotnet/area-system-formats-cbor | |
| area-System.Globalization | @ericstj | @dotnet/area-system-globalization | |
| area-System.IO | @jeffhandley | @dotnet/area-system-io | |
| area-System.IO.Compression | @jeffhandley | @dotnet/area-system-io-compression | <ul><li>Also includes System.IO.Packaging</li></ul> |
| area-System.IO.Pipelines | @kevinpi | @davidfowl @halter73 @jkotalik | |
| area-System.Linq | @jeffhandley | @dotnet/area-system-linq | |
| area-System.Linq.Expressions | @jaredpar | @cston @333fred | Archived component - limited churn/contributions (see [#27790](https://github.com/dotnet/runtime/issues/27790)) |
| area-System.Linq.Parallel | @jeffhandley | @dotnet/area-system-linq-parallel | Consultants: @stephentoub @kouvel |
| area-System.Management | @ericstj | @dotnet/area-system-management | WMI |
| area-System.Memory | @jeffhandley | @dotnet/area-system-memory | |
| area-System.Net | @karelz | @dotnet/ncl | Included:<ul><li>System.Uri</li></ul> |
| area-System.Net.Http | @karelz | @dotnet/ncl | |
| area-System.Net.Quic | @karelz | @dotnet/ncl | |
| area-System.Net.Security | @karelz | @dotnet/ncl | |
| area-System.Net.Sockets | @karelz | @dotnet/ncl | |
| area-System.Numerics | @jeffhandley | @dotnet/area-system-numerics | |
| area-System.Numerics.Tensors | @jeffhandley | @dotnet/area-system-numerics-tensors | |
| area-System.Reflection | @ericstj | @dotnet/area-system-reflection | |
| area-System.Reflection-mono | @SamMonoRT | @lambdageek | MonoVM-specific reflection and reflection-emit issues |
| area-System.Reflection.Emit | @ericstj | @dotnet/area-system-reflection-emit | |
| area-System.Reflection.Metadata | @ericstj | @dotnet/area-system-reflection-metadata | Consultants: @tmat |
| area-System.Resources | @ericstj | @dotnet/area-system-resources | |
| area-System.Runtime | @jeffhandley | @dotnet/area-system-runtime | Included:<ul><li>System.Runtime.Serialization.Formatters</li><li>System.Runtime.InteropServices.RuntimeInfo</li><li>System.Array</li></ul>Excluded:<ul><li>Path -> System.IO</li><li>StopWatch -> System.Diagnostics</li><li>Uri -> System.Net</li><li>WebUtility -> System.Net</li></ul> |
| area-System.Runtime.Caching | @HongGit | @StephenMolloy @HongGit | |
| area-System.Runtime.CompilerServices | @ericstj | @dotnet/area-system-runtime-compilerservices | |
| area-System.Runtime.InteropServices | @jeffschwMSFT | @AaronRobinsonMSFT @jkoritzinsky | Excluded:<ul><li>System.Runtime.InteropServices.RuntimeInfo</li></ul> |
| area-System.Runtime.InteropServices.JavaScript | @lewing | @kjpou1 | |
| area-System.Runtime.Intrinsics | @jeffhandley | @dotnet/area-system-runtime-intrinsics | Consultants: @echesakovMSFT @kunalspathak |
| area-System.Security | @jeffhandley | @dotnet/area-system-security | |
| area-System.ServiceModel | @HongGit | @HongGit @mconnew | Repo: https://github.com/dotnet/WCF<br>Packages:<ul><li>System.ServiceModel.Primitives</li><li>System.ServiceModel.Http</li><li>System.ServiceModel.NetTcp</li><li>System.ServiceModel.Duplex</li><li>System.ServiceModel.Security</li></ul> |
| area-System.ServiceModel.Syndication | @HongGit | @StephenMolloy @HongGit | |
| area-System.ServiceProcess | @ericstj | @dotnet/area-system-serviceprocess | |
| area-System.Speech | @danmoseley | @danmoseley | |
| area-System.Text.Encoding | @jeffhandley | @dotnet/area-system-text-encoding | |
| area-System.Text.Encodings.Web | @jeffhandley | @dotnet/area-system-text-encodings-web | |
| area-System.Text.Json | @jeffhandley | @dotnet/area-system-text-json | |
| area-System.Text.RegularExpressions | @ericstj | @dotnet/area-system-text-regularexpressions | Consultants: @stephentoub |
| area-System.Threading | @mangod9 | @kouvel | |
| area-System.Threading.Channels | @ericstj | @dotnet/area-system-threading-channels | Consultants: @stephentoub |
| area-System.Threading.RateLimiting | @rafikiassumani-msft | @BrennanConroy @halter73 | Consultants: @eerhardt |
| area-System.Threading.Tasks | @ericstj | @dotnet/area-system-threading-tasks | Consultants: @stephentoub |
| area-System.Transactions | @HongGit | @HongGit | |
| area-System.Xml | @jeffhandley | @dotnet/area-system-xml | |
| area-Threading-mono | @SamMonoRT | @lambdageek | |
| area-TieredCompilation-coreclr | @mangod9 | @kouvel | |
| area-Tracing-coreclr | @tommcdon | @sywhang @josalem | |
| area-Tracing-mono | @steveisok | @lateralusX | |
| area-TypeSystem-coreclr | @mangod9 | @davidwrighton @MichalStrehovsky @janvorli @mangod9 | |
| area-UWP | @tommcdon | @jashook | UWP-specific issues including Microsoft.NETCore.UniversalWindowsPlatform and Microsoft.Net.UWPCoreRuntimeSdk |
| area-VM-coreclr | @mangod9 | @mangod9 | |
| area-VM-meta-mono | @SamMonoRT | @lambdageek | |
## Operating Systems
| Operating System | Lead | Owners (area experts to tag in PR's and issues) | Description |
|------------------|---------------|-----------------------------------------------------|--------------|
| os-alpine | | | |
| os-android | @steveisok | @akoeplinger | |
| os-freebsd | | | |
| os-mac-os-x | | | |
| os-maccatalyst | @steveisok | | |
| os-ios | @steveisok | @vargaz | |
| os-tvos | @steveisok | @vargaz | |
## Architectures
| Architecture | Lead | Owners (area experts to tag in PR's and issues) | Description |
|------------------|---------------|-----------------------------------------------------|--------------|
| arch-wasm | @lewing | @lewing @BrzVlad | |
## Community Triagers
The repo has a number of community members carrying the triager role. While not necessarily associated with a specific area, they may assist with labeling issues and pull requests. Currently, the following community members are triagers:
* @huoyaoyuan
* @SingleAccretion
* @teo-tsirpanis
* @tmds
* @vcsjones
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/mini/tramp-x86-gsharedvt.c | /**
* \file
* gsharedvt support code for x86
*
* Authors:
* Zoltan Varga <[email protected]>
*
* Copyright 2013 Xamarin, Inc (http://www.xamarin.com)
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "mini.h"
#include <mono/metadata/abi-details.h>
#ifdef MONO_ARCH_GSHAREDVT_SUPPORTED
gpointer
mono_x86_start_gsharedvt_call (GSharedVtCallInfo *info, gpointer *caller, gpointer *callee, gpointer mrgctx_reg)
{
int i;
int *map = info->map;
/* Set vtype ret arg */
if (info->vret_arg_slot != -1) {
callee [info->vret_arg_slot] = &callee [info->vret_slot];
}
/* Copy data from the caller argument area to the callee */
for (i = 0; i < info->map_count; ++i) {
int src = map [i * 2];
int dst = map [i * 2 + 1];
switch ((src >> 16) & 0x3) {
case 0:
callee [dst] = caller [src];
break;
case 1: {
int j, nslots;
gpointer *arg;
/* gsharedvt->normal */
nslots = src >> 18;
arg = (gpointer*)caller [src & 0xffff];
for (j = 0; j < nslots; ++j)
callee [dst + j] = arg [j];
break;
}
case 2:
/* gsharedvt arg, have to take its address */
callee [dst] = caller + (src & 0xffff);
break;
#if 0
int dst = map [i * 2 + 1];
if (dst >= 0xffff) {
/* gsharedvt arg, have to take its address */
callee [dst - 0xffff] = caller + map [i * 2];
} else {
callee [dst] = caller [map [i * 2]];
}
#endif
}
}
if (info->vcall_offset != -1) {
MonoObject *this_obj = (MonoObject*)caller [0];
if (G_UNLIKELY (!this_obj))
return NULL;
if (info->vcall_offset == MONO_GSHAREDVT_DEL_INVOKE_VT_OFFSET)
/* delegate invoke */
return ((MonoDelegate*)this_obj)->invoke_impl;
else
return *(gpointer*)((char*)this_obj->vtable + info->vcall_offset);
} else if (info->calli) {
/* The address to call is passed in the mrgctx reg */
return mrgctx_reg;
} else {
return info->addr;
}
}
gpointer
mono_arch_get_gsharedvt_trampoline (MonoTrampInfo **info, gboolean aot)
{
guint8 *code, *buf;
int buf_len, cfa_offset;
GSList *unwind_ops = NULL;
MonoJumpInfo *ji = NULL;
guint8 *br_out, *br [16];
int info_offset, mrgctx_offset;
buf_len = 320;
buf = code = mono_global_codeman_reserve (buf_len);
/*
* This trampoline is responsible for marshalling calls between normal code and gsharedvt code. The
* caller is a normal or gshared method which uses the signature of the inflated method to make the call, while
* the callee is a gsharedvt method which has a signature which uses valuetypes in place of type parameters, i.e.
* caller:
* foo<bool> (bool b)
* callee:
* T=<type used to represent vtype type arguments, currently TypedByRef>
* foo<T> (T b)
* The trampoline is responsible for marshalling the arguments and marshalling the result back. To simplify
* things, we create our own stack frame, and do most of the work in a C function, which receives a
* GSharedVtCallInfo structure as an argument. The structure should contain information to execute the C function to
* be as fast as possible. The argument is received in EAX from a gsharedvt trampoline. So the real
* call sequence looks like this:
* caller -> gsharedvt trampoline -> gsharevt in trampoline -> start_gsharedvt_call
* FIXME: Optimize this.
*/
cfa_offset = sizeof (target_mgreg_t);
mono_add_unwind_op_def_cfa (unwind_ops, code, buf, X86_ESP, cfa_offset);
mono_add_unwind_op_offset (unwind_ops, code, buf, X86_NREG, -cfa_offset);
x86_push_reg (code, X86_EBP);
cfa_offset += sizeof (target_mgreg_t);
mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
mono_add_unwind_op_offset (unwind_ops, code, buf, X86_EBP, - cfa_offset);
x86_mov_reg_reg (code, X86_EBP, X86_ESP);
mono_add_unwind_op_def_cfa_reg (unwind_ops, code, buf, X86_EBP);
/* Alloc stack frame/align stack */
x86_alu_reg_imm (code, X86_SUB, X86_ESP, 8);
info_offset = -4;
mrgctx_offset = - 8;
/* The info struct is put into EAX by the gsharedvt trampoline */
/* Save info struct addr */
x86_mov_membase_reg (code, X86_EBP, info_offset, X86_EAX, 4);
/* Save rgctx */
x86_mov_membase_reg (code, X86_EBP, mrgctx_offset, MONO_ARCH_RGCTX_REG, 4);
/* Allocate stack area used to pass arguments to the method */
x86_mov_reg_membase (code, X86_EAX, X86_EAX, MONO_STRUCT_OFFSET (GSharedVtCallInfo, stack_usage), sizeof (target_mgreg_t));
x86_alu_reg_reg (code, X86_SUB, X86_ESP, X86_EAX);
#if 0
/* Stack alignment check */
x86_mov_reg_reg (code, X86_ECX, X86_ESP);
x86_alu_reg_imm (code, X86_AND, X86_ECX, MONO_ARCH_FRAME_ALIGNMENT - 1);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, 0);
x86_branch_disp (code, X86_CC_EQ, 3, FALSE);
x86_breakpoint (code);
#endif
/* ecx = caller argument area */
x86_mov_reg_reg (code, X86_ECX, X86_EBP);
x86_alu_reg_imm (code, X86_ADD, X86_ECX, 8);
/* eax = callee argument area */
x86_mov_reg_reg (code, X86_EAX, X86_ESP);
/* Call start_gsharedvt_call */
/* Arg 4 */
x86_push_membase (code, X86_EBP, mrgctx_offset);
/* Arg3 */
x86_push_reg (code, X86_EAX);
/* Arg2 */
x86_push_reg (code, X86_ECX);
/* Arg1 */
x86_push_membase (code, X86_EBP, info_offset);
if (aot) {
code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, GUINT_TO_POINTER (MONO_JIT_ICALL_mono_x86_start_gsharedvt_call));
x86_call_reg (code, X86_EAX);
} else {
x86_call_code (code, mono_x86_start_gsharedvt_call);
}
x86_alu_reg_imm (code, X86_ADD, X86_ESP, 4 * 4);
/* The address to call is in eax */
/* The stack is now setup for the real call */
/* Load info struct */
x86_mov_reg_membase (code, X86_ECX, X86_EBP, info_offset, 4);
/* Load rgctx */
x86_mov_reg_membase (code, MONO_ARCH_RGCTX_REG, X86_EBP, mrgctx_offset, sizeof (target_mgreg_t));
/* Make the call */
x86_call_reg (code, X86_EAX);
/* The return value is either in registers, or stored to an area beginning at sp [info->vret_slot] */
/* EAX/EDX might contain the return value, only ECX is free */
/* Load info struct */
x86_mov_reg_membase (code, X86_ECX, X86_EBP, info_offset, 4);
/* Branch to the in/out handling code */
x86_alu_membase_imm (code, X86_CMP, X86_ECX, MONO_STRUCT_OFFSET (GSharedVtCallInfo, gsharedvt_in), 1);
br_out = code;
x86_branch32 (code, X86_CC_NE, 0, TRUE);
/*
* IN CASE
*/
/* Load ret marshal type */
x86_mov_reg_membase (code, X86_ECX, X86_ECX, MONO_STRUCT_OFFSET (GSharedVtCallInfo, ret_marshal), 4);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_NONE);
br [0] = code;
x86_branch8 (code, X86_CC_NE, 0, TRUE);
/* Normal return, no marshalling required */
x86_leave (code);
x86_ret (code);
/* Return value marshalling */
x86_patch (br [0], code);
/* Load info struct */
x86_mov_reg_membase (code, X86_EAX, X86_EBP, info_offset, 4);
/* Load 'vret_slot' */
x86_mov_reg_membase (code, X86_EAX, X86_EAX, MONO_STRUCT_OFFSET (GSharedVtCallInfo, vret_slot), 4);
/* Compute ret area address */
x86_shift_reg_imm (code, X86_SHL, X86_EAX, 2);
x86_alu_reg_reg (code, X86_ADD, X86_EAX, X86_ESP);
/* The callee does a ret $4, so sp is off by 4 */
x86_alu_reg_imm (code, X86_SUB, X86_EAX, sizeof (target_mgreg_t));
/* Branch to specific marshalling code */
// FIXME: Move the I4 case to the top */
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_DOUBLE_FPSTACK);
br [1] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_FLOAT_FPSTACK);
br [2] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_STACK_POP);
br [3] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_I1);
br [4] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_U1);
br [5] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_I2);
br [6] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_U2);
br [7] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
/* IREGS case */
/* Load both eax and edx for simplicity */
x86_mov_reg_membase (code, X86_EDX, X86_EAX, sizeof (target_mgreg_t), sizeof (target_mgreg_t));
x86_mov_reg_membase (code, X86_EAX, X86_EAX, 0, sizeof (target_mgreg_t));
x86_leave (code);
x86_ret (code);
/* DOUBLE_FPSTACK case */
x86_patch (br [1], code);
x86_fld_membase (code, X86_EAX, 0, TRUE);
x86_jump8 (code, 0);
x86_leave (code);
x86_ret (code);
/* FLOAT_FPSTACK case */
x86_patch (br [2], code);
x86_fld_membase (code, X86_EAX, 0, FALSE);
x86_leave (code);
x86_ret (code);
/* STACK_POP case */
x86_patch (br [3], code);
x86_leave (code);
x86_ret_imm (code, 4);
/* I1 case */
x86_patch (br [4], code);
x86_widen_membase (code, X86_EAX, X86_EAX, 0, TRUE, FALSE);
x86_leave (code);
x86_ret (code);
/* U1 case */
x86_patch (br [5], code);
x86_widen_membase (code, X86_EAX, X86_EAX, 0, FALSE, FALSE);
x86_leave (code);
x86_ret (code);
/* I2 case */
x86_patch (br [6], code);
x86_widen_membase (code, X86_EAX, X86_EAX, 0, TRUE, TRUE);
x86_leave (code);
x86_ret (code);
/* U2 case */
x86_patch (br [7], code);
x86_widen_membase (code, X86_EAX, X86_EAX, 0, FALSE, TRUE);
x86_leave (code);
x86_ret (code);
/*
* OUT CASE
*/
x86_patch (br_out, code);
/* Load ret marshal type into ECX */
x86_mov_reg_membase (code, X86_ECX, X86_ECX, MONO_STRUCT_OFFSET (GSharedVtCallInfo, ret_marshal), 4);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_NONE);
br [0] = code;
x86_branch8 (code, X86_CC_NE, 0, TRUE);
/* Normal return, no marshalling required */
x86_leave (code);
x86_ret (code);
/* Return value marshalling */
x86_patch (br [0], code);
/* EAX might contain the return value */
// FIXME: Use moves
x86_push_reg (code, X86_EAX);
/* Load info struct */
x86_mov_reg_membase (code, X86_EAX, X86_EBP, info_offset, 4);
/* Load 'vret_arg_slot' */
x86_mov_reg_membase (code, X86_EAX, X86_EAX, MONO_STRUCT_OFFSET (GSharedVtCallInfo, vret_arg_slot), 4);
/* Compute ret area address in the caller frame in EAX */
x86_shift_reg_imm (code, X86_SHL, X86_EAX, 2);
x86_alu_reg_reg (code, X86_ADD, X86_EAX, X86_EBP);
x86_alu_reg_imm (code, X86_ADD, X86_EAX, 8);
x86_mov_reg_membase (code, X86_EAX, X86_EAX, 0, sizeof (target_mgreg_t));
/* Branch to specific marshalling code */
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_DOUBLE_FPSTACK);
br [1] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_FLOAT_FPSTACK);
br [2] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_STACK_POP);
br [3] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_IREGS);
br [4] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
/* IREG case */
x86_mov_reg_reg (code, X86_ECX, X86_EAX);
x86_pop_reg (code, X86_EAX);
x86_mov_membase_reg (code, X86_ECX, 0, X86_EAX, sizeof (target_mgreg_t));
x86_leave (code);
x86_ret_imm (code, 4);
/* IREGS case */
x86_patch (br [4], code);
x86_mov_reg_reg (code, X86_ECX, X86_EAX);
x86_pop_reg (code, X86_EAX);
x86_mov_membase_reg (code, X86_ECX, sizeof (target_mgreg_t), X86_EDX, sizeof (target_mgreg_t));
x86_mov_membase_reg (code, X86_ECX, 0, X86_EAX, sizeof (target_mgreg_t));
x86_leave (code);
x86_ret_imm (code, 4);
/* DOUBLE_FPSTACK case */
x86_alu_reg_imm (code, X86_ADD, X86_ESP, 4);
x86_patch (br [1], code);
x86_fst_membase (code, X86_EAX, 0, TRUE, TRUE);
x86_jump8 (code, 0);
x86_leave (code);
x86_ret_imm (code, 4);
/* FLOAT_FPSTACK case */
x86_alu_reg_imm (code, X86_ADD, X86_ESP, 4);
x86_patch (br [2], code);
x86_fst_membase (code, X86_EAX, 0, FALSE, TRUE);
x86_leave (code);
x86_ret_imm (code, 4);
/* STACK_POP case */
x86_patch (br [3], code);
x86_leave (code);
x86_ret_imm (code, 4);
g_assertf (code - buf <= buf_len, "%d %d", (int)(code - buf), buf_len);
if (info)
*info = mono_tramp_info_create ("gsharedvt_trampoline", buf, code - buf, ji, unwind_ops);
mono_arch_flush_icache (buf, code - buf);
return buf;
}
#endif /* MONO_ARCH_GSHAREDVT_SUPPORTED */
| /**
* \file
* gsharedvt support code for x86
*
* Authors:
* Zoltan Varga <[email protected]>
*
* Copyright 2013 Xamarin, Inc (http://www.xamarin.com)
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "mini.h"
#include <mono/metadata/abi-details.h>
#ifdef MONO_ARCH_GSHAREDVT_SUPPORTED
gpointer
mono_x86_start_gsharedvt_call (GSharedVtCallInfo *info, gpointer *caller, gpointer *callee, gpointer mrgctx_reg)
{
int i;
int *map = info->map;
/* Set vtype ret arg */
if (info->vret_arg_slot != -1) {
callee [info->vret_arg_slot] = &callee [info->vret_slot];
}
/* Copy data from the caller argument area to the callee */
for (i = 0; i < info->map_count; ++i) {
int src = map [i * 2];
int dst = map [i * 2 + 1];
switch ((src >> 16) & 0x3) {
case 0:
callee [dst] = caller [src];
break;
case 1: {
int j, nslots;
gpointer *arg;
/* gsharedvt->normal */
nslots = src >> 18;
arg = (gpointer*)caller [src & 0xffff];
for (j = 0; j < nslots; ++j)
callee [dst + j] = arg [j];
break;
}
case 2:
/* gsharedvt arg, have to take its address */
callee [dst] = caller + (src & 0xffff);
break;
#if 0
int dst = map [i * 2 + 1];
if (dst >= 0xffff) {
/* gsharedvt arg, have to take its address */
callee [dst - 0xffff] = caller + map [i * 2];
} else {
callee [dst] = caller [map [i * 2]];
}
#endif
}
}
if (info->vcall_offset != -1) {
MonoObject *this_obj = (MonoObject*)caller [0];
if (G_UNLIKELY (!this_obj))
return NULL;
if (info->vcall_offset == MONO_GSHAREDVT_DEL_INVOKE_VT_OFFSET)
/* delegate invoke */
return ((MonoDelegate*)this_obj)->invoke_impl;
else
return *(gpointer*)((char*)this_obj->vtable + info->vcall_offset);
} else if (info->calli) {
/* The address to call is passed in the mrgctx reg */
return mrgctx_reg;
} else {
return info->addr;
}
}
gpointer
mono_arch_get_gsharedvt_trampoline (MonoTrampInfo **info, gboolean aot)
{
guint8 *code, *buf;
int buf_len, cfa_offset;
GSList *unwind_ops = NULL;
MonoJumpInfo *ji = NULL;
guint8 *br_out, *br [16];
int info_offset, mrgctx_offset;
buf_len = 320;
buf = code = mono_global_codeman_reserve (buf_len);
/*
* This trampoline is responsible for marshalling calls between normal code and gsharedvt code. The
* caller is a normal or gshared method which uses the signature of the inflated method to make the call, while
* the callee is a gsharedvt method which has a signature which uses valuetypes in place of type parameters, i.e.
* caller:
* foo<bool> (bool b)
* callee:
* T=<type used to represent vtype type arguments, currently TypedByRef>
* foo<T> (T b)
* The trampoline is responsible for marshalling the arguments and marshalling the result back. To simplify
* things, we create our own stack frame, and do most of the work in a C function, which receives a
* GSharedVtCallInfo structure as an argument. The structure should contain information to execute the C function to
* be as fast as possible. The argument is received in EAX from a gsharedvt trampoline. So the real
* call sequence looks like this:
* caller -> gsharedvt trampoline -> gsharevt in trampoline -> start_gsharedvt_call
* FIXME: Optimize this.
*/
cfa_offset = sizeof (target_mgreg_t);
mono_add_unwind_op_def_cfa (unwind_ops, code, buf, X86_ESP, cfa_offset);
mono_add_unwind_op_offset (unwind_ops, code, buf, X86_NREG, -cfa_offset);
x86_push_reg (code, X86_EBP);
cfa_offset += sizeof (target_mgreg_t);
mono_add_unwind_op_def_cfa_offset (unwind_ops, code, buf, cfa_offset);
mono_add_unwind_op_offset (unwind_ops, code, buf, X86_EBP, - cfa_offset);
x86_mov_reg_reg (code, X86_EBP, X86_ESP);
mono_add_unwind_op_def_cfa_reg (unwind_ops, code, buf, X86_EBP);
/* Alloc stack frame/align stack */
x86_alu_reg_imm (code, X86_SUB, X86_ESP, 8);
info_offset = -4;
mrgctx_offset = - 8;
/* The info struct is put into EAX by the gsharedvt trampoline */
/* Save info struct addr */
x86_mov_membase_reg (code, X86_EBP, info_offset, X86_EAX, 4);
/* Save rgctx */
x86_mov_membase_reg (code, X86_EBP, mrgctx_offset, MONO_ARCH_RGCTX_REG, 4);
/* Allocate stack area used to pass arguments to the method */
x86_mov_reg_membase (code, X86_EAX, X86_EAX, MONO_STRUCT_OFFSET (GSharedVtCallInfo, stack_usage), sizeof (target_mgreg_t));
x86_alu_reg_reg (code, X86_SUB, X86_ESP, X86_EAX);
#if 0
/* Stack alignment check */
x86_mov_reg_reg (code, X86_ECX, X86_ESP);
x86_alu_reg_imm (code, X86_AND, X86_ECX, MONO_ARCH_FRAME_ALIGNMENT - 1);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, 0);
x86_branch_disp (code, X86_CC_EQ, 3, FALSE);
x86_breakpoint (code);
#endif
/* ecx = caller argument area */
x86_mov_reg_reg (code, X86_ECX, X86_EBP);
x86_alu_reg_imm (code, X86_ADD, X86_ECX, 8);
/* eax = callee argument area */
x86_mov_reg_reg (code, X86_EAX, X86_ESP);
/* Call start_gsharedvt_call */
/* Arg 4 */
x86_push_membase (code, X86_EBP, mrgctx_offset);
/* Arg3 */
x86_push_reg (code, X86_EAX);
/* Arg2 */
x86_push_reg (code, X86_ECX);
/* Arg1 */
x86_push_membase (code, X86_EBP, info_offset);
if (aot) {
code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, GUINT_TO_POINTER (MONO_JIT_ICALL_mono_x86_start_gsharedvt_call));
x86_call_reg (code, X86_EAX);
} else {
x86_call_code (code, mono_x86_start_gsharedvt_call);
}
x86_alu_reg_imm (code, X86_ADD, X86_ESP, 4 * 4);
/* The address to call is in eax */
/* The stack is now setup for the real call */
/* Load info struct */
x86_mov_reg_membase (code, X86_ECX, X86_EBP, info_offset, 4);
/* Load rgctx */
x86_mov_reg_membase (code, MONO_ARCH_RGCTX_REG, X86_EBP, mrgctx_offset, sizeof (target_mgreg_t));
/* Make the call */
x86_call_reg (code, X86_EAX);
/* The return value is either in registers, or stored to an area beginning at sp [info->vret_slot] */
/* EAX/EDX might contain the return value, only ECX is free */
/* Load info struct */
x86_mov_reg_membase (code, X86_ECX, X86_EBP, info_offset, 4);
/* Branch to the in/out handling code */
x86_alu_membase_imm (code, X86_CMP, X86_ECX, MONO_STRUCT_OFFSET (GSharedVtCallInfo, gsharedvt_in), 1);
br_out = code;
x86_branch32 (code, X86_CC_NE, 0, TRUE);
/*
* IN CASE
*/
/* Load ret marshal type */
x86_mov_reg_membase (code, X86_ECX, X86_ECX, MONO_STRUCT_OFFSET (GSharedVtCallInfo, ret_marshal), 4);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_NONE);
br [0] = code;
x86_branch8 (code, X86_CC_NE, 0, TRUE);
/* Normal return, no marshalling required */
x86_leave (code);
x86_ret (code);
/* Return value marshalling */
x86_patch (br [0], code);
/* Load info struct */
x86_mov_reg_membase (code, X86_EAX, X86_EBP, info_offset, 4);
/* Load 'vret_slot' */
x86_mov_reg_membase (code, X86_EAX, X86_EAX, MONO_STRUCT_OFFSET (GSharedVtCallInfo, vret_slot), 4);
/* Compute ret area address */
x86_shift_reg_imm (code, X86_SHL, X86_EAX, 2);
x86_alu_reg_reg (code, X86_ADD, X86_EAX, X86_ESP);
/* The callee does a ret $4, so sp is off by 4 */
x86_alu_reg_imm (code, X86_SUB, X86_EAX, sizeof (target_mgreg_t));
/* Branch to specific marshalling code */
// FIXME: Move the I4 case to the top */
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_DOUBLE_FPSTACK);
br [1] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_FLOAT_FPSTACK);
br [2] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_STACK_POP);
br [3] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_I1);
br [4] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_U1);
br [5] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_I2);
br [6] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_U2);
br [7] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
/* IREGS case */
/* Load both eax and edx for simplicity */
x86_mov_reg_membase (code, X86_EDX, X86_EAX, sizeof (target_mgreg_t), sizeof (target_mgreg_t));
x86_mov_reg_membase (code, X86_EAX, X86_EAX, 0, sizeof (target_mgreg_t));
x86_leave (code);
x86_ret (code);
/* DOUBLE_FPSTACK case */
x86_patch (br [1], code);
x86_fld_membase (code, X86_EAX, 0, TRUE);
x86_jump8 (code, 0);
x86_leave (code);
x86_ret (code);
/* FLOAT_FPSTACK case */
x86_patch (br [2], code);
x86_fld_membase (code, X86_EAX, 0, FALSE);
x86_leave (code);
x86_ret (code);
/* STACK_POP case */
x86_patch (br [3], code);
x86_leave (code);
x86_ret_imm (code, 4);
/* I1 case */
x86_patch (br [4], code);
x86_widen_membase (code, X86_EAX, X86_EAX, 0, TRUE, FALSE);
x86_leave (code);
x86_ret (code);
/* U1 case */
x86_patch (br [5], code);
x86_widen_membase (code, X86_EAX, X86_EAX, 0, FALSE, FALSE);
x86_leave (code);
x86_ret (code);
/* I2 case */
x86_patch (br [6], code);
x86_widen_membase (code, X86_EAX, X86_EAX, 0, TRUE, TRUE);
x86_leave (code);
x86_ret (code);
/* U2 case */
x86_patch (br [7], code);
x86_widen_membase (code, X86_EAX, X86_EAX, 0, FALSE, TRUE);
x86_leave (code);
x86_ret (code);
/*
* OUT CASE
*/
x86_patch (br_out, code);
/* Load ret marshal type into ECX */
x86_mov_reg_membase (code, X86_ECX, X86_ECX, MONO_STRUCT_OFFSET (GSharedVtCallInfo, ret_marshal), 4);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_NONE);
br [0] = code;
x86_branch8 (code, X86_CC_NE, 0, TRUE);
/* Normal return, no marshalling required */
x86_leave (code);
x86_ret (code);
/* Return value marshalling */
x86_patch (br [0], code);
/* EAX might contain the return value */
// FIXME: Use moves
x86_push_reg (code, X86_EAX);
/* Load info struct */
x86_mov_reg_membase (code, X86_EAX, X86_EBP, info_offset, 4);
/* Load 'vret_arg_slot' */
x86_mov_reg_membase (code, X86_EAX, X86_EAX, MONO_STRUCT_OFFSET (GSharedVtCallInfo, vret_arg_slot), 4);
/* Compute ret area address in the caller frame in EAX */
x86_shift_reg_imm (code, X86_SHL, X86_EAX, 2);
x86_alu_reg_reg (code, X86_ADD, X86_EAX, X86_EBP);
x86_alu_reg_imm (code, X86_ADD, X86_EAX, 8);
x86_mov_reg_membase (code, X86_EAX, X86_EAX, 0, sizeof (target_mgreg_t));
/* Branch to specific marshalling code */
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_DOUBLE_FPSTACK);
br [1] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_FLOAT_FPSTACK);
br [2] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_STACK_POP);
br [3] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
x86_alu_reg_imm (code, X86_CMP, X86_ECX, GSHAREDVT_RET_IREGS);
br [4] = code;
x86_branch8 (code, X86_CC_E, 0, TRUE);
/* IREG case */
x86_mov_reg_reg (code, X86_ECX, X86_EAX);
x86_pop_reg (code, X86_EAX);
x86_mov_membase_reg (code, X86_ECX, 0, X86_EAX, sizeof (target_mgreg_t));
x86_leave (code);
x86_ret_imm (code, 4);
/* IREGS case */
x86_patch (br [4], code);
x86_mov_reg_reg (code, X86_ECX, X86_EAX);
x86_pop_reg (code, X86_EAX);
x86_mov_membase_reg (code, X86_ECX, sizeof (target_mgreg_t), X86_EDX, sizeof (target_mgreg_t));
x86_mov_membase_reg (code, X86_ECX, 0, X86_EAX, sizeof (target_mgreg_t));
x86_leave (code);
x86_ret_imm (code, 4);
/* DOUBLE_FPSTACK case */
x86_alu_reg_imm (code, X86_ADD, X86_ESP, 4);
x86_patch (br [1], code);
x86_fst_membase (code, X86_EAX, 0, TRUE, TRUE);
x86_jump8 (code, 0);
x86_leave (code);
x86_ret_imm (code, 4);
/* FLOAT_FPSTACK case */
x86_alu_reg_imm (code, X86_ADD, X86_ESP, 4);
x86_patch (br [2], code);
x86_fst_membase (code, X86_EAX, 0, FALSE, TRUE);
x86_leave (code);
x86_ret_imm (code, 4);
/* STACK_POP case */
x86_patch (br [3], code);
x86_leave (code);
x86_ret_imm (code, 4);
g_assertf (code - buf <= buf_len, "%d %d", (int)(code - buf), buf_len);
if (info)
*info = mono_tramp_info_create ("gsharedvt_trampoline", buf, code - buf, ji, unwind_ops);
mono_arch_flush_icache (buf, code - buf);
return buf;
}
#endif /* MONO_ARCH_GSHAREDVT_SUPPORTED */
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./docs/design/coreclr/jit/ryujit-overview.md | JIT Compiler Structure
===
# Introduction
RyuJIT is the code name for the Just-In-Time Compiler (aka "JIT") for the .NET runtime. It was
evolved from the JIT used for x86 (jit32) on .NET Framework, and ported to support all other architecture and
platform targets supported by .NET Core.
The primary design considerations for RyuJIT are to:
* Maintain a high compatibility bar with previous JITs, especially those for x86 (jit32) and x64 (jit64).
* Support and enable good runtime performance through code optimizations, register allocation, and code generation.
* Ensure good throughput via largely linear-order optimizations and transformations, along with limitations on tracked variables for analyses (such as dataflow) that are inherently super-linear.
* Ensure that the JIT architecture is designed to support a range of targets and scenarios.
The first objective was the primary motivation for evolving the existing code base, rather than starting from scratch
or departing more drastically from the existing IR and architecture.
# Execution Environment and External Interface
RyuJIT provides both just-in-time and ahead-of-time compilation service for the .NET runtime. The runtime itself is
variously called the EE (execution engine), the VM (virtual machine), or simply the CLR (common language runtime).
Depending upon the configuration, the EE and JIT may reside in the same or different executable files. RyuJIT
implements the JIT side of the JIT/EE interfaces:
* `ICorJitCompiler` – this is the interface that the JIT compiler implements. This interface is defined in
[src/inc/corjit.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/inc/corjit.h)
and its implementation is in
[src/jit/ee_il_dll.cpp](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/ee_il_dll.cpp).
The following are the key methods on this interface:
* `compileMethod` is the main entry point for the JIT. The EE passes it a `ICorJitInfo` object,
and the "info" containing the IL, the method header, and various other useful tidbits.
It returns a pointer to the code, its size, and additional GC, EH and (optionally) debug info.
* `getVersionIdentifier` is the mechanism by which the JIT/EE interface is versioned.
There is a single GUID (manually generated) which the JIT and EE must agree on.
* `getMaxIntrinsicSIMDVectorLength` communicates to the EE the largest SIMD vector length that the JIT can support.
* `ICorJitInfo` – this is the interface that the EE implements. It has many methods defined on it that allow the JIT to
look up metadata tokens, traverse type signatures, compute field and vtable offsets, find method entry points,
construct string literals, etc. This bulk of this interface is inherited from `ICorDynamicInfo` which is defined in
[src/inc/corinfo.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/inc/corinfo.h). The implementation
is defined in
[src/vm/jitinterface.cpp](https://github.com/dotnet/runtime/blob/main/src/coreclr/vm/jitinterface.cpp).
# Internal Representation (IR)
## `Compiler` object
The `Compiler` object is the primary data structure of the JIT. While it is not part of the JIT's IR per se, it
serves as the root from which the data structures that implement the IR are accessible. For example, the `Compiler`
object points to the head of the function's `BasicBlock` list with the `fgFirstBB` field, as well as having
additional pointers to the end of the list, and other distinguished locations. `ICorJitCompiler::compileMethod()` is
invoked for each method, and creates a new `Compiler` object. Thus, the JIT need not worry about thread
synchronization while accessing `Compiler` state. The EE has the necessary synchronization to ensure there is a
single JIT compiled copy of a method when two or more threads try to trigger JIT compilation of the same method.
## Overview of the IR
RyuJIT represents a function as a doubly-linked list of `BasicBlock` values. Each `BasicBlock` has explicit edges to
its successors that define the function's non-exceptional control flow. Exceptional control flow is implicit, with
protected regions and handlers described in a table of `EHblkDsc` values. At the beginning of a compilation, each
`BasicBlock` contains nodes in a high-level, statement- and tree-oriented form (HIR: "high-level intermediate
representation"); this form persists throughout the JIT's front end. During the first phase of the back end--the
rationalization phase--the HIR for each block is lowered to a linearly-ordered, node-oriented form (LIR: "low-level
intermediate representation"). The fundamental distinction between HIR and LIR is in ordering semantics, though there
are also some restrictions on the types of nodes that may appear in an HIR or LIR block.
Both HIR and LIR blocks are composed of `GenTree` nodes that define the operations performed by the block. A
`GenTree` node may consume some number of operands and may produce a singly-defined, at-most-singly-used value as a
result. These values are referred to interchangably as *SDSU* (single def, single use) temps or *tree* temps.
Definitions (aka, defs) of SDSU temps are represented by `GenTree` nodes themselves, and uses are represented by
edges from the using node to the defining node. Furthermore, SDSU temps defined in one block may not be used in a
different block. In cases where a value must be multiply-defined, multiply-used, or defined in one block and used in
another, the IR provides another class of temporary: the local var (aka, local variable). Local vars are defined by
assignment nodes in HIR or store nodes in LIR, and are used by local var nodes in both forms.
An HIR block is composed of a doubly-linked list of statement nodes (`Statement`), each of which references a single
expression tree (`m_rootNode`). The `GenTree` nodes in this tree execute in "tree order", which is defined as the
order produced by a depth-first, left-to-right traversal of the tree, with two notable exceptions:
* Binary nodes marked with the `GTF_REVERSE_OPS` flag execute their right operand tree (`gtOp2`) before their left
operand tree (`gtOp1`)
* Dynamically-sized block copy nodes where `gtEvalSizeFirst` is `true` execute the `gtDynamicSize` tree
before executing their other operand trees.
In addition to tree order, HIR also requires that no SDSU temp is defined in one statement and used in another. In
situations where the requirements of tree and statement order prove onerous (e.g. when code must execute at a
particular point in a function), HIR provides `GT_COMMA` nodes as an escape valve: these nodes consume and discard
the results of their left-hand side while producing a copy of the value produced by their right-hand side. This
allows the compiler to insert code in the middle of a statement without requiring that the statement be split apart.
An LIR block is composed of a doubly-linked list of `GenTree` nodes, each of which describes a single operation in
the method. These nodes execute in the order given by the list; there is no relationship between the order in which a
node's operands appear and the order in which the operators that produced those operands execute. The only exception
to this rule occurs after the register allocator, which may introduce `GT_COPY` and `GT_RELOAD` nodes that execute in
"spill order". Spill order is defined as the order in which the register allocator visits a node's operands. For
correctness, the code generator must generate code for spills, reloads, and `GT_COPY`/`GT_RELOAD` nodes in this
order.
In addition to HIR and LIR `BasicBlock`s, a separate representation--`insGroup` and `instrDesc`--is used during the
actual instruction encoding.
(Note that this diagram is slightly out-of-date: GenTreeStmt no longer exists, and is replaced by `Statement`
nodes in the IR.)

## GenTree Nodes
Each operation is represented as a GenTree node, with an opcode (`GT_xxx`), zero or more child/operand `GenTree`
nodes, and additional fields as needed to represent the semantics of that node. Every node includes its type, value
number, assertions, register assignments, etc. when available.
`GenTree` nodes are doubly-linked in execution order, but the links are not necessarily valid during all phases of
the JIT. In HIR these links are primarily a convenience, as the order produced by a traversal of the links must match
the order produced by a "tree order" traversal (see above for details). In LIR these links define the execution order
of the nodes.
HIR statement nodes utilize the same `GenTree` base type as the operation nodes, though they are not truly related.
* The statement nodes are doubly-linked. The first statement node in a block points to the last node in the block via its `m_prev` link. Note that the last statement node does *not* point to the first; that is, the list is not fully circular.
* Each statement node contains two `GenTree` links – `m_rootNode` points to the top-level node in the statement (i.e. the root of the tree that represents the statement), while `m_treeList` points to the first node in execution order (again, this link is not always valid).
## Local var descriptors
A `LclVarDsc` represents a possibly-multiply-defined, possibly-multiply-used temporary. These temporaries may be used
to represent user local variables, arguments or JIT-created temps. Each lclVar has a `gtLclNum` which is the
identifier usually associated with the variable in the JIT and its dumps. The `LclVarDsc` contains the type, use
count, weighted use count, frame or register assignment, etc. A local var may be "tracked" (`lvTracked`), in which
case it participates in dataflow analysis, and has a secondary name (`lvVarIndex`) that allows for the use of dense
bit vectors.
### Example of Post-Import IR
For this snippet of code (extracted from
[src/tests/JIT/CodeGenBringUpTests/DblRoots.cs](https://github.com/dotnet/runtime/blob/main/src/tests/JIT/CodeGenBringUpTests/DblRoots.cs)), with `COMPlus_TieredCompilation=0` and using the DblRoots_ro.csproj project to compile it:
r1 = (-b + Math.Sqrt(b*b - 4*a*c))/(2*a);
A stripped-down dump of the `GenTree` nodes just after they are imported looks like this:
```
STMT00000 (IL 0x000...0x026)
▌ ASG double
├──▌ IND double
│ └──▌ LCL_VAR byref V03 arg3
└──▌ DIV double
├──▌ ADD double
│ ├──▌ NEG double
│ │ └──▌ LCL_VAR double V01 arg1
│ └──▌ INTRINSIC double sqrt
│ └──▌ SUB double
│ ├──▌ MUL double
│ │ ├──▌ LCL_VAR double V01 arg1
│ │ └──▌ LCL_VAR double V01 arg1
│ └──▌ MUL double
│ ├──▌ MUL double
│ │ ├──▌ CNS_DBL double 4.0000000000000000
│ │ └──▌ LCL_VAR double V00 arg0
│ └──▌ LCL_VAR double V02 arg2
└──▌ MUL double
├──▌ CNS_DBL double 2.0000000000000000
└──▌ LCL_VAR double V00 arg0
```
## Types
The JIT is primarily concerned with "primitive" types, i.e. integers, reference types, pointers, and floating point
types. It must also be concerned with the format of user-defined value types (i.e. struct types derived from
`System.ValueType`) – specifically, their size and the offset of any GC references they contain, so that they can be
correctly initialized and copied. The primitive types are represented in the JIT by the `var_types` enum, and any
additional information required for struct types is obtained from the JIT/EE interface by the use of an opaque
`CORINFO_CLASS_HANDLE`.
## Dataflow Information
In order to limit throughput impact, the JIT limits the number of lclVars for which liveness information is computed.
These are the tracked lclVars (`lvTracked` is true), and they are the only candidates for register allocation (i.e.
only these lclVars may be assigned registers over their entire lifetime). Defs and uses of untracked lclVars are
treated as stores and loads to/from the appropriate stack location, and the corresponding nodes act as normal
operators during register allocation.
The liveness analysis determines the set of defs, as well as the uses that are upward exposed, for each block. It
then propagates the liveness information. The result of the analysis is captured in the following:
* The live-in and live-out sets are captured in the `bbLiveIn` and `bbLiveOut` fields of the `BasicBlock`.
* The `GTF_VAR_DEF` flag is set on a lclVar node (all of which are of type `GenTreeLclVarCommon`) that is a definition.
* The `GTF_VAR_USEASG` flag is set (in addition to the `GTF_VAR_DEF` flag) on partial definitions of a local variable (i.e. `GT_LCL_FLD` nodes that do not define the entire variable).
## SSA
Static single assignment (SSA) form is constructed in a traditional manner [[1]](#[1]). The SSA names are recorded on
the lclVar references. While SSA form usually retains a pointer or link to the defining reference, RyuJIT currently
retains only the `BasicBlock` in which the definition of each SSA name resides.
## Value Numbering
Value numbering utilizes SSA for lclVar values, but also performs value numbering of expression trees. It takes
advantage of type safety by not invalidating the value number for field references with a heap write, unless the
write is to the same field. The IR nodes are annotated with the value numbers, which are indexes into a type-specific
value number store. Value numbering traverses the trees, performing symbolic evaluation of many operations.
# Phases of RyuJIT
The top-level function of interest is `Compiler::compCompile`. It invokes the following phases in order.
| **Phase** | **IR Transformations** |
| --- | --- |
| [Pre-import](#pre-import) | `Compiler->lvaTable` created and filled in for each user argument and variable. `BasicBlock` list initialized. |
| [Importation](#importation) | `GenTree` nodes created and linked in to `Statement` nodes, and Statements into BasicBlocks. Inlining candidates identified. |
| [Inlining](#inlining) | The IR for inlined methods is incorporated into the flowgraph. |
| [Struct Promotion](#struct-promotion) | New lclVars are created for each field of a promoted struct. |
| [Mark Address-Exposed Locals](#mark-addr-exposed) | lclVars with references occurring in an address-taken context are marked. This must be kept up-to-date. |
| [Morph Blocks](#morph-blocks) | Performs localized transformations, including mandatory normalization as well as simple optimizations. |
| [Eliminate Qmarks](#eliminate-qmarks) | All `GT_QMARK` nodes are eliminated, other than simple ones that do not require control flow. |
| [Flowgraph Analysis](#flowgraph-analysis) | `BasicBlock` predecessors are computed, and must be kept valid. Loops are identified, and normalized, cloned and/or unrolled. |
| [Normalize IR for Optimization](#normalize-ir) | lclVar references counts are set, and must be kept valid. Evaluation order of `GenTree` nodes (`gtNext`/`gtPrev`) is determined, and must be kept valid. |
| [SSA and Value Numbering Optimizations](#ssa-vn) | Computes liveness (`bbLiveIn` and `bbLiveOut` on `BasicBlock`s), and dominators. Builds SSA for tracked lclVars. Computes value numbers. |
| [Loop Invariant Code Hoisting](#licm) | Hoists expressions out of loops. |
| [Copy Propagation](#copy-propagation) | Copy propagation based on value numbers. |
| [Common Subexpression Elimination (CSE)](#cse) | Elimination of redundant subexressions based on value numbers. |
| [Assertion Propagation](#assertion-propagation) | Utilizes value numbers to propagate and transform based on properties such as non-nullness. |
| [Range analysis](#range-analysis) | Eliminate array index range checks based on value numbers and assertions |
| [Rationalization](#rationalization) | Flowgraph order changes from `FGOrderTree` to `FGOrderLinear`. All `GT_COMMA`, `GT_ASG` and `GT_ADDR` nodes are transformed. |
| [Lowering](#lowering) | Register requirements are fully specified (`gtLsraInfo`). All control flow is explicit. |
| [Register allocation](#reg-alloc) | Registers are assigned (`gtRegNum` and/or `gtRsvdRegs`), and the number of spill temps calculated. |
| [Code Generation](#code-generation) | Determines frame layout. Generates code for each `BasicBlock`. Generates prolog & epilog code for the method. Emit EH, GC and Debug info. |
## <a name="pre-import"></a>Pre-import
Prior to reading in the IL for the method, the JIT initializes the local variable table, and scans the IL to find
branch targets and form BasicBlocks.
## <a name="importation"></a>Importation
Importation is the phase that creates the IR for the method, reading in one IL instruction at a time, and building up
the statements. During this process, it may need to generate IR with multiple, nested expressions. This is the
purpose of the non-expression-like IR nodes:
* It may need to evaluate part of the expression into a temp, in which case it will use a comma (`GT_COMMA`) node to ensure that the temp is evaluated in the proper execution order – i.e. `GT_COMMA(GT_ASG(temp, exp), temp)` is inserted into the tree where "exp" would go.
* It may need to create conditional expressions, but adding control flow at this point would be quite messy. In this case it generates question mark/colon (?: or `GT_QMARK`/`GT_COLON`) trees that may be nested within an expression.
During importation, tail call candidates (either explicitly marked or opportunistically identified) are identified
and flagged. They are further validated, and possibly unmarked, during morphing.
## Morphing
The `fgMorph` phase includes a number of transformations:
### <a name="inlining"></a>Inlining
The `fgInline` phase determines whether each call site is a candidate for inlining. The initial determination is made
via a state machine that runs over the candidate method's IL. It estimates the native code size corresponding to the
inline method, and uses a set of heuristics, including the estimated size of the current method, to determine if
inlining would be profitable. If so, a separate `Compiler` object is created, and the importation phase is called to
create the tree for the candidate inline method. Inlining may be aborted prior to completion, if any conditions are
encountered that indicate that it may be unprofitable (or otherwise incorrect). If inlining is successful, the
inlinee compiler's trees are incorporated into the inliner compiler (the "parent"), with arguments and return values
appropriately transformed.
### <a name="struct-promotion"></a>Struct Promotion
Struct promotion (`fgPromoteStructs()`) analyzes the local variables and temps, and determines if their fields are
candidates for tracking (and possibly enregistering) separately. It first determines whether it is possible to
promote, which takes into account whether the layout may have holes or overlapping fields, whether its fields
(flattening any contained structs) will fit in registers, etc.
Next, it determines whether it is likely to be profitable, based on the number of fields, and whether the fields are
individually referenced.
When a lclVar is promoted, there are now N+1 lclVars for the struct, where N is the number of fields. The original
struct lclVar is not considered to be tracked, but its fields may be.
### <a name="mark-addr-exposed"></a>Mark Address-Exposed Locals
This phase traverses the expression trees, propagating the context (e.g. taking the address, indirecting) to
determine which lclVars have their address taken, and which therefore will not be register candidates. If a struct
lclVar has been promoted, and is then found to be address-taken, it will be considered "dependently promoted", which
is an odd way of saying that the fields will still be separately tracked, but they will not be register candidates.
### <a name="morph-blocks"></a>Morph Blocks
What is often thought of as "morph" involves localized transformations to the trees. In addition to performing simple
optimizing transformations, it performs some normalization that is required, such as converting field and array
accesses into pointer arithmetic. It can (and must) be called by subsequent phases on newly added or modified trees.
During the main Morph phase, the boolean `fgGlobalMorph` is set on the `Compiler` argument, which governs which
transformations are permissible.
### <a name="eliminate-qmarks"></a>Eliminate Qmarks
This expands most `GT_QMARK`/`GT_COLON` trees into blocks, except for the case that is instantiating a condition.
## <a name="flowgraph-analysis"></a>Flowgraph Analysis
At this point, a number of analyses and transformations are done on the flowgraph:
* Computing the predecessors of each block
* Computing edge weights, if profile information is available
* Computing reachability and dominators
* Identifying and normalizing loops (transforming while loops to "do while")
* Cloning and unrolling of loops
## <a name="normalize-ir"></a>Normalize IR for Optimization
At this point, a number of properties are computed on the IR, and must remain valid for the remaining phases. We will
call this "normalization"
* `lvaMarkLocalVars` – if this jit is optimizing, set the reference counts (raw and weighted) for lclVars, sort them,
and determine which will be tracked (currently up to 512). If not optimizing, all locals are given an implicit
reference count of one. Reference counts are not incrementally maintained. They can be recomputed if accurate
counts are needed.
* `optOptimizeBools` – this optimizes Boolean expressions, and may change the flowgraph (why is it not done prior to reachability and dominators?)
* Link the trees in evaluation order (setting `gtNext` and `gtPrev` fields): and `fgFindOperOrder()` and `fgSetBlockOrder()`.
## <a name="ssa-vn"></a>SSA and Value Numbering Optimizations
The next set of optimizations are built on top of SSA and value numbering. First, the SSA representation is built
(during which dataflow analysis, aka liveness, is computed on the lclVars), then value numbering is done using SSA.
### <a name="licm"></a>Loop Invariant Code Hoisting
This phase traverses all the loop nests, in outer-to-inner order (thus hoisting expressions outside the largest loop
in which they are invariant). It traverses all of the statements in the blocks in the loop that are always executed.
If the statement is:
* A valid CSE candidate
* Has no side-effects
* Does not raise an exception OR occurs in the loop prior to any side-effects
* Has a valid value number, and it is a lclVar defined outside the loop, or its children (the value numbers from which it was computed) are invariant.
### <a name="copy-propagation"></a>Copy Propagation
This phase walks each block in the graph (in dominator-first order, maintaining context between dominator and child)
keeping track of every live definition. When it encounters a variable that shares the VN with a live definition, it
is replaced with the variable in the live definition.
The JIT currently requires that the IR be maintained in conventional SSA form, as there is no "out of SSA"
translation (see the comments on `optVnCopyProp()` for more information).
### <a name="cse"></a>Common Subexpression Elimination (CSE)
Utilizes value numbers to identify redundant computations, which are then evaluated to a new temp lclVar, and then
reused.
### <a name="assertion-propagation"></a>Assertion Propagation
Utilizes value numbers to propagate and transform based on properties such as non-nullness.
### <a name="range-analysis"></a>Range analysis
Optimize array index range checks based on value numbers and assertions.
## <a name="rationalization"></a>Rationalization
As the JIT has evolved, changes have been made to improve the ability to reason over the tree in both "tree order"
and "linear order". These changes have been termed the "rationalization" of the IR. In the spirit of reuse and
evolution, some of the changes have been made only in the later ("backend") components of the JIT. The corresponding
transformations are made to the IR by a "Rationalizer" component. It is expected that over time some of these changes
will migrate to an earlier place in the JIT phase order:
* Elimination of assignment nodes (`GT_ASG`). The assignment node was problematic because the semantics of its destination (left hand side of the assignment) could not be determined without context. For example, a `GT_LCL_VAR` on the left-hand side of an assignment is a definition of the local variable, but on the right-hand side it is a use. Furthermore, since the execution order requires that the children be executed before the parent, it is unnatural that the left-hand side of the assignment appears in execution order before the assignment operator.
* During rationalization, all assignments are replaced by stores, which either represent their destination on the store node itself (e.g. `GT_LCL_VAR`), or by the use of a child address node (e.g. `GT_STORE_IND`).
* Elimination of address nodes (`GT_ADDR`). These are problematic because of the need for parent context to analyze the child.
* Elimination of "comma" nodes (`GT_COMMA`). These nodes are introduced for convenience during importation, during which a single tree is constructed at a time, and not incorporated into the statement list until it is completed. When it is necessary, for example, to store a partially-constructed tree into a temporary variable, a `GT_COMMA` node is used to link it into the tree. However, in later phases, these comma nodes are an impediment to analysis, and thus are eliminated.
* In some cases, it is not possible to fully extract the tree into a separate statement, due to execution order dependencies. In these cases, an "embedded" statement is created. While these are conceptually very similar to the `GT_COMMA` nodes, they do not masquerade as expressions.
* Elimination of "QMark" (`GT_QMARK`/`GT_COLON`) nodes is actually done at the end of morphing, long before the current rationalization phase. The presence of these nodes made analyses (especially dataflow) overly complex.
* Elimination of statements. Without statements, the execution order of a basic block's contents is fully defined by the `gtNext`/`gtPrev` links between `GenTree` nodes.
For our earlier example (Example of Post-Import IR), here is what the simplified dump looks like just prior to
Rationalization (the $ annotations are value numbers). Note that some common subexpressions have been computed into
new temporary lclVars, and that computation has been inserted as a `GT_COMMA` (comma) node in the IR:
```
STMT (IL 0x000...0x026)
▌ ASG double $VN.Void
├──▌ IND double $146
│ └──▌ LCL_VAR byref V03 arg3 u:1 (last use) $c0
└──▌ DIV double $146
├──▌ ADD double $144
│ ├──▌ COMMA double $83
│ │ ├──▌ ASG double $VN.Void
│ │ │ ├──▌ LCL_VAR double V06 cse0 d:1 $83
│ │ │ └──▌ INTRINSIC double sqrt $83
│ │ │ └──▌ SUB double $143
│ │ │ ├──▌ MUL double $140
│ │ │ │ ├──▌ LCL_VAR double V01 arg1 u:1 $81
│ │ │ │ └──▌ LCL_VAR double V01 arg1 u:1 $81
│ │ │ └──▌ MUL double $142
│ │ │ ├──▌ MUL double $141
│ │ │ │ ├──▌ LCL_VAR double V00 arg0 u:1 $80
│ │ │ │ └──▌ CNS_DBL double 4.0000000000000000 $180
│ │ │ └──▌ LCL_VAR double V02 arg2 u:1 $82
│ │ └──▌ LCL_VAR double V06 cse0 u:1 $83
│ └──▌ COMMA double $84
│ ├──▌ ASG double $VN.Void
│ │ ├──▌ LCL_VAR double V08 cse2 d:1 $84
│ │ └──▌ NEG double $84
│ │ └──▌ LCL_VAR double V01 arg1 u:1 $81
│ └──▌ LCL_VAR double V08 cse2 u:1 $84
└──▌ COMMA double $145
├──▌ ASG double $VN.Void
│ ├──▌ LCL_VAR double V07 cse1 d:1 $145
│ └──▌ MUL double $145
│ ├──▌ LCL_VAR double V00 arg0 u:1 $80
│ └──▌ CNS_DBL double 2.0000000000000000 $181
└──▌ LCL_VAR double V07 cse1 u:1 $145
```
After Rationalize, the nodes are presented in execution order, and the `GT_COMMA` (comma), `GT_ASG` (=), and
`Statement` nodes have been eliminated:
```
IL_OFFSET void IL offset: 0x0
t3 = LCL_VAR double V01 arg1 u:1 $81
t4 = LCL_VAR double V01 arg1 u:1 $81
┌──▌ t3 double
├──▌ t4 double
t5 = ▌ MUL double $140
t7 = LCL_VAR double V00 arg0 u:1 $80
t6 = CNS_DBL double 4.0000000000000000 $180
┌──▌ t7 double
├──▌ t6 double
t8 = ▌ MUL double $141
t9 = LCL_VAR double V02 arg2 u:1 $82
┌──▌ t8 double
├──▌ t9 double
10 = ▌ MUL double $142
┌──▌ t5 double
├──▌ t10 double
11 = ▌ SUB double $143
┌──▌ t11 double
12 = ▌ INTRINSIC double sqrt $83
┌──▌ t12 double
▌ STORE_LCL_VAR double V06 cse0 d:1
43 = LCL_VAR double V06 cse0 u:1 $83
t1 = LCL_VAR double V01 arg1 u:1 $81
┌──▌ t1 double
t2 = ▌ NEG double $84
┌──▌ t2 double
▌ STORE_LCL_VAR double V08 cse2 d:1
53 = LCL_VAR double V08 cse2 u:1 $84
┌──▌ t43 double
├──▌ t53 double
13 = ▌ ADD double $144
15 = LCL_VAR double V00 arg0 u:1 $80
14 = CNS_DBL double 2.0000000000000000 $181
┌──▌ t15 double
├──▌ t14 double
16 = ▌ MUL double $145
┌──▌ t16 double
▌ STORE_LCL_VAR double V07 cse1 d:1
48 = LCL_VAR double V07 cse1 u:1 $145
┌──▌ t13 double
├──▌ t48 double
17 = ▌ DIV double $146
t0 = LCL_VAR byref V03 arg3 u:1 (last use) $c0
┌──▌ t0 byref
├──▌ t17 double
▌ STOREIND double
IL_OFFSET void IL offset: 0x27
55 = LCL_VAR double V08 cse2 u:1 $84
45 = LCL_VAR double V06 cse0 u:1 $83
┌──▌ t55 double
├──▌ t45 double
33 = ▌ SUB double $147
50 = LCL_VAR double V07 cse1 u:1 $145
┌──▌ t33 double
├──▌ t50 double
37 = ▌ DIV double $148
20 = LCL_VAR byref V04 arg4 u:1 (last use) $c1
┌──▌ t20 byref
├──▌ t37 double
▌ STOREIND double
IL_OFFSET void IL offset: 0x4f
RETURN void $200
```
## <a name="lowering"></a>Lowering
Lowering is responsible for transforming the IR in such a way that the control flow, and any register requirements,
are fully exposed.
It does an execution-order traversal that performs context-dependent transformations such as
* expanding switch statements (using a switch table or a series of conditional branches)
* constructing addressing modes (`GT_LEA` nodes)
* determining the code generation strategy for block assignments (e.g. `GT_STORE_BLK`) which may become helper calls, unrolled loops, or an instruction like `rep stos`
* generating machine specific instructions (e.g. generating the `BT` x86/64 instruction)
* mark "contained" nodes - such a node does not generate any code and relies on its user to include the node's operation in its own codegen (e.g. memory operands, immediate operands)
* mark "reg optional" nodes - despite the name, such a node may produce a value in a register but its user does not require a register and can consume the value directly from a memory location
For example, this:
```
t47 = LCL_VAR ref V00 arg0
t48 = LCL_VAR int V01 arg1
┌──▌ t48 int
t51 = ▌ CAST long <- int
t52 = CNS_INT long 2
┌──▌ t51 long
├──▌ t52 long
t53 = ▌ LSH long
t54 = CNS_INT long 16 Fseq[#FirstElem]
┌──▌ t53 long
├──▌ t54 long
t55 = ▌ ADD long
┌──▌ t47 ref
├──▌ t55 long
t56 = ▌ ADD byref
┌──▌ t56 byref
t44 = ▌ IND int
```
Is transformed into this, in which the addressing mode is explicit:
```
t47 = LCL_VAR ref V00 arg0
t48 = LCL_VAR int V01 arg1
┌──▌ t48 int
t51 = ▌ CAST long <- int
┌──▌ t47 ref
├──▌ t51 long
t79 = ▌ LEA(b+(i*4)+16) byref
┌──▌ t79 byref
t44 = ▌ IND int
```
Sometimes `Lowering` will insert nodes into the execution order before the node that it is currently handling.
In such cases, it must ensure that they themselves are properly lowered. This includes:
* Generating only legal `LIR` nodes that do not themselves require lowering.
* Performing any needed containment analysis (e.g. `ContainCheckRange()`) on the newly added node(s).
After all nodes are lowered, liveness is run in preparation for register allocation.
## <a name="reg-alloc"></a>Register allocation
The RyuJIT register allocator uses a Linear Scan algorithm, with an approach similar to [[2]](#[2]). In discussion it
is referred to as either `LinearScan` (the name of the implementing class), or LSRA (Linear Scan Register
Allocation). In brief, it operates on two main data structures:
* `Intervals` (representing live ranges of variables or tree expressions) and `RegRecords` (representing physical registers), both of which derive from `Referenceable`.
* `RefPositions`, which represent uses or defs (or variants thereof, such as ExposedUses) of either `Intervals` or physical registers.
`LinearScan::buildIntervals()` traverses the entire method building RefPositions and Intervals as required. For example, for the `STORE_BLK` node in this snippet:
```
t67 = CNS_INT(h) long 0x2b5acef2c50 static Fseq[s1]
┌──▌ t67 long
t0 = ▌ IND ref
t1 = CNS_INT long 8 Fseq[#FirstElem]
┌──▌ t0 ref
├──▌ t1 long
t2 = ▌ ADD byref
┌──▌ t2 byref
t3 = ▌ IND struct
t31 = LCL_VAR_ADDR byref V08 tmp1
┌──▌ t31 byref
├──▌ t3 struct
▌ STORE_BLK(40) struct (copy) (Unroll)
```
the following RefPositions are generated:
```
N027 (???,???) [000085] -A-XG------- ▌ STORE_BLK(40) struct (copy) (Unroll) REG NA
Interval 16: int RefPositions {} physReg:NA Preferences=[allInt]
<RefPosition #40 @27 RefTypeDef <Ivl:16 internal> STORE_BLK BB01 regmask=[allInt] minReg=1>
Interval 17: float RefPositions {} physReg:NA Preferences=[allFloat]
<RefPosition #41 @27 RefTypeDef <Ivl:17 internal> STORE_BLK BB01 regmask=[allFloat] minReg=1>
<RefPosition #42 @27 RefTypeUse <Ivl:15> BB01 regmask=[allInt] minReg=1 last>
<RefPosition #43 @27 RefTypeUse <Ivl:16 internal> STORE_BLK BB01 regmask=[allInt] minReg=1 last>
<RefPosition #44 @27 RefTypeUse <Ivl:17 internal> STORE_BLK BB01 regmask=[allFloat] minReg=1 last>
```
The "@ 27" is the location number of the node. "internal" indicates a register that is internal to the node (in this case 2 internal registers are needed, one float (XMM on XARCH) and one int, as temporaries for copying). "regmask" indicates the register constraints for the `RefPosition`.
### Notable features of RyuJIT LinearScan
Unlike most register allocators, LSRA performs register allocation on an IR (Intermediate Representation) that is not
a direct representation of the target instructions. A given IR node may map to 0, 1 or multiple target instructions.
Nodes that are "contained" are handled by code generation as part of their parent node and thus may map to 0
instructions. A simple node will have a 1-to-1 mapping to a target instruction, and a more complex node (e.g.
`GT_STORE_BLK`) may map to multiple instructions.
### Pre-conditions:
It is the job of the `Lowering` phase to transform the IR such that:
* The nodes are in `LIR` form (i.e. all expression trees have been linearized, and the execution order of the nodes within a BasicBlock is specified by the `gtNext` and `gtPrev` links)
* All contained nodes are identified (`gtFlags` has the `GTF_CONTAINED` bit set)
* All nodes for which a register is optional are identified (`RefPosition::regOptional` is `true`)
* This is used for x86 and x64 on operands that can be directly consumed from memory if no register is allocated.
* All unused values (nodes that produce a result that is not consumed) are identified (`gtLIRFlags` has the `LIR::Flags::UnusedValue` bit set)
* Since tree temps (the values produced by nodes and consumed by their parent) are expected to be single-def, single-use (SDSU), normally the live range can be determined to end at the use. If there is no use, the register allocator doesn't know where the live range ends.
* Code can be generated without any context from the parent (consumer) of each node.
After `Lowering` has completed, liveness analysis is performed:
* It identifies which `lclVar`s should have their liveness computed.
* The reason this is done after `Lowering` is that it can introduce new `lclVar`s.
* It then does liveness analysis on those `lclVar`s, updating the `bbLiveIn` and `bbLiveOut` sets for each `BasicBlock`.
* This tells the register allocator which `lclVars` are live at block boundaries.
* Note that "tree temps" cannot be live at block boundaries.
### Allocation Overview
Allocation proceeds in 4 phases:
* Prepration:
* Determine the order in which the `BasicBlocks` will be allocated, and which predecessor of each block will be used to determine the starting location for variables live-in to the `BasicBlock`.
* Construct an `Interval` for each `lclVar` that may be enregistered.
* Construct a `RegRecord` for each physical register.
* Walk the `BasicBlocks` in the determined order building `RefPositions` for each register use, def, or kill.
* Just prior to building `RefPosition`s for the node, the `TreeNodeInfoInit()` method is called to determine its register requirements.
* Allocate the registers by traversing the `RefPositions`.
* Write back the register assignments, and perform any necessary moves at block boundaries where the allocations don't match.
Post-conditions:
* The `gtRegNum` property of all `GenTree` nodes that require a register has been set to a valid register number.
* For reg-optional nodes, the `GTF_NOREG_AT_USE` bit is set in `gtFlags` if a register was not allocated.
* The `gtRsvdRegs` field (a set/mask of registers) has the requested number of registers specified for internal use.
* All spilled values (lclVar or expression) are marked with `GTF_SPILL` at their definition. For lclVars, they are also marked with `GTF_SPILLED` at any use at which the value must be reloaded.
* For all lclVars that are register candidates:
* `lvRegNum` = initial register location (or `REG_STK`)
* `lvRegister` flag set if it always lives in the same register
* `lvSpilled` flag is set if it is ever spilled
* The maximum number of simultaneously-live spill locations of each type (used for spilling expression trees) has been communicated via calls to `compiler->tmpPreAllocateTemps(type)`.
## <a name="code-generation"></a>Code Generation
The process of code generation is relatively straightforward, as Lowering has done some of the work already. Code
generation proceeds roughly as follows:
* Determine the frame layout – allocating space on the frame for any lclVars that are not fully enregistered, as well as any spill temps required for spilling non-lclVar expressions.
* For each `BasicBlock`, in layout order, and each `GenTree` node in the block, in execution order:
* If the node is "contained" (i.e. its operation is subsumed by a parent node), do nothing.
* Otherwise, "consume" all the register operands of the node.
* This updates the liveness information (i.e. marking a lclVar as dead if this is the last use), and performs any needed copies.
* This must be done in "spill order" so that any spill/restore code inserted by the register allocator to resolve register conflicts is generated in the correct order. "
* Track the live variables in registers, as well as the live stack variables that contain GC refs.
* Produce the `instrDesc(s)` for the operation, with the current live GC references.
* Update the scope information (debug info) at block boundaries.
* Generate the prolog and epilog code.
* Write the final instruction bytes. It does this by invoking the emitter, which holds all the `instrDescs`.
# Phase-dependent Properties and Invariants of the IR
There are several properties of the IR that are valid only during (or after) specific phases of the JIT. This section describes the phase transitions, and how the IR properties are affected.
## Phase Transitions
* Flowgraph analysis
* Sets the predecessors of each block, which must be kept valid after this phase.
* Computes reachability and dominators. These may be invalidated by changes to the flowgraph.
* Computes edge weights, if profile information is available.
* Identifies and normalizes loops. These may be invalidated, but must be marked as such.
* Normalization
* The lclVar reference counts are set by `lvaMarkLocalVars()`.
* Statement ordering is determined by `fgSetBlockOrder()`. Execution order is a depth-first preorder traversal of the nodes, with the operands usually executed in order. The exceptions are:
* Binary operators, which can have the `GTF_REVERSE_OPS` flag set to indicate that the RHS (`gtOp2`) should be evaluated before the LHS (`gtOp1`).
* Dynamically-sized block copy nodes, which can have `gtEvalSizeFirst` set to `true` to indicate that their `gtDynamicSize` tree should be evaluated before executing their other operands.
* Rationalization
* All `GT_ASG` trees are transformed into `GT_STORE` variants (e.g. `GT_STORE_LCL_VAR`).
* All `GT_ADDR` nodes are eliminated (e.g. with `GT_LCL_VAR_ADDR`).
* All `GT_COMMA` and `Statement` nodes are removed and their constituent nodes linked into execution order.
* Lowering
* `GenTree` nodes are split or transformed as needed to expose all of their register requirements and any necessary `flowgraph` changes (e.g., for switch statements).
## GenTree phase-dependent properties
Ordering:
* For `Statement` nodes, the `m_next` and `m_prev` fields must always be consistent. The last statement in the `BasicBlock` must have `m_next` equal to `nullptr`. By convention, the `m_prev` of the first statement in the `BasicBlock` must be the last statement of the `BasicBlock`.
* In all phases, `m_rootNode` points to the top-level node of the expression.
* For 'GenTree' nodes, the `gtNext` and `gtPrev` fields are either `nullptr`, prior to ordering, or they are consistent (i.e. `A->gtPrev->gtNext = A`, and `A->gtNext->gtPrev == A`, if they are non-`nullptr`).
* After normalization the `m_treeList` of the containing statement points to the first node to be executed.
* Prior to normalization, the `gtNext` and `gtPrev` pointers on the expression `GenTree` nodes are invalid. The expression nodes are only traversed via the links from parent to child (e.g. `node->gtGetOp1()`, or `node->gtOp.gtOp1`). The `gtNext/gtPrev` links are set by `fgSetBlockOrder()`.
* After normalization, and prior to rationalization, the parent/child links remain the primary traversal mechanism. The evaluation order of any nested expression-statements (usually assignments) is enforced by the `GT_COMMA` in which they are contained.
* After rationalization, all `GT_COMMA` nodes are eliminated, statements are flattened, and the primary traversal mechanism becomes the `gtNext/gtPrev` links which define the execution order.
* In tree ordering:
* The `gtPrev` of the first node (`m_treeList`) is always `nullptr`.
* The `gtNext` of the last node (`m_rootNode`) is always `nullptr`.
## LclVar phase-dependent properties
LclVar ref counts track the number of uses and weighted used of a local in the jit IR. There are two sequences of
phases over which ref counts are valid, tracked via `lvaRefCountState`: an early sequence (state `RCS_EARLY`) and the
normal sequence (state `RCS_NORMAL`). Requests for ref counts via `lvRefCnt` and `lvRefCntWtd` must be aware of the
ref count state.
Before struct promotion the ref counts are invalid. Struct promotion enables `RCS_EARLY` and it and subsequent phases
through morph compute and uses ref counts on some locals to guide some struct optimizations. After morph the counts
go back to longer being valid.
The `RCS_NORMAL` sequence begins at normalization. Ref counts are computed and generally available via for the rest
of the compilation phases. The counts are not incrementally maintained and may go stale as the IR is optimized or
transformed, or maybe very approximate if the jit is not optimizing. They can be recomputed via `lvaComputeRefCounts`
at points where accurate counts are valuable. Currently this happens before and after lower.
# Supporting technologies and components
## Instruction encoding
Instruction encoding is performed by the emitter
([emit.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/emit.h)), using the
`insGroup`/`instrDesc` representation. The code generator calls methods on the emitter to construct `instrDescs`. The
encodings information is captured in the following:
* The "instruction" enumeration itemizes the different instructions available on each target, and is used as an index into the various encoding tables (e.g. `instInfo[]`, `emitInsModeFmtTab[]`) generated from the `instrs{tgt}.h` (e.g., [instrsxarch.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/instrsxarch.h)).
* The skeleton encodings are contained in the tables, and then there are methods on the emitter that handle the special encoding constraints for the various instructions, addressing modes, register types, etc.
## GC Info
Reporting of live GC references is done in two ways:
* For stack locations that are not tracked (these could be spill locations or lclVars – local variables or temps – that are not register candidates), they are initialized to `nullptr` in the prolog, and reported as live for the entire method.
* For lclVars with tracked lifetimes, or for expression involving GC references, we report the range over which the reference is live. This is done by the emitter, which adds this information to the instruction group, and which terminates instruction groups when the GC info changes.
The tracking of GC reference lifetimes is done via the `GCInfo` class in the JIT. It is declared in
[src/jit/jitgcinfo.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/jitgcinfo.h) (to
differentiate it from
[src/inc/gcinfo.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/inc/gcinfo.h)), and implemented in
[src/jit/gcinfo.cpp](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/gcinfo.cpp).
In a JitDump, the generated GC info can be seen following the "In gcInfoBlockHdrSave()" line.
## Debugger info
Debug info consists primarily of two types of information in the JIT:
* Mapping of IL offsets to native code offsets. This is accomplished via:
* the `m_ILOffsetX` on the statement nodes (`Statement`)
* the `gtLclILoffs` on lclVar references (`GenTreeLclVar`)
* The IL offsets are captured during CodeGen by calling `CodeGen::genIPmappingAdd()`, and then written to debug tables by `CodeGen::genIPmappingGen()`.
* Mapping of user locals to location (register or stack). This is accomplished via:
* Struct `siVarLoc` (in [compiler.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/compiler.h)) captures the location
* `VarScopeDsc` ([compiler.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/compiler.h)) captures the live range of a local variable in a given location.
## Exception handling
Exception handling information is captured in an `EHblkDsc` for each exception handling region. Each region includes
the first and last blocks of the try and handler regions, exception type, enclosing region, among other things. Look
at [jiteh.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/jiteh.h) and
[jiteh.cpp](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/jiteh.cpp), especially, for details.
Look at `Compiler::fgVerifyHandlerTab()` to see how the exception table constraints are verified.
# Reading a JitDump
One of the best ways of learning about the JIT compiler is examining a compilation dump in detail. The dump shows you
all the really important details of the basic data structures without all the implementation detail of the code.
Debugging a JIT bug almost always begins with a JitDump. Only after the problem is isolated by the dump does it make
sense to start debugging the JIT code itself.
Dumps are also useful because they give you good places to place breakpoints. If you want to see what is happening at
some point in the dump, simply search for the dump text in the source code. This gives you a great place to put a
conditional breakpoint.
There is not a strong convention about what or how the information is dumped, but generally you can find
phase-specific information by searching for the phase name. Some useful points follow.
## How to create a JitDump
You can enable dumps by setting the `COMPlus_JitDump` environment variable to a space-separated list of the method(s)
you want to dump. For example:
```cmd
:: Print out lots of useful info when
:: compiling methods named Main/GetEnumerator
set "COMPlus_JitDump=Main GetEnumerator"
```
See [Setting configuration variables](viewing-jit-dumps.md#setting-configuration-variables) for more
details on this.
Full instructions for dumping the compilation of some managed code can be found here:
[viewing-jit-dumps.md](viewing-jit-dumps.md)
## Reading expression trees
Expression trees are displayed using a pre-order traversal, with the subtrees of a node being displayed under the
node in operand order (e.g. `gtOp1`, `gtOp2`). This is similar to the way trees are displayed in typical user
interfaces (e.g. folder trees). Note that the operand order may be different from the actual execution order,
determined by `GTF_REVERSE_OPS` or other means. The operand order usually follows the order in high level languages
so that the typical infix, left to right expression `a - b` becomes prefix, top to bottom tree:
```
▌ SUB double
├──▌ LCL_VAR double V03 a
└──▌ LCL_VAR double V02 b
```
Assignments are displayed like all other binary operators, with `dest = src` becoming:
```
▌ ASG double
├──▌ LCL_VAR double V03 dest
└──▌ LCL_VAR double V02 src
```
Calls initially display in source order - `Order(1, 2, 3, 4)` is:
```
[000004] --C-G------- * CALL void Program.Order
[000000] ------------ arg0 +--* CNS_INT int 1
[000001] ------------ arg1 +--* CNS_INT int 2
[000002] ------------ arg2 +--* CNS_INT int 3
[000003] ------------ arg3 \--* CNS_INT int 4
```
but call morphing may change the order depending on the ABI so the above may become:
```
[000004] --CXG+------ * CALL void Program.Order
[000002] -----+------ arg2 on STK +--* CNS_INT int 3
[000003] -----+------ arg3 on STK +--* CNS_INT int 4
[000000] -----+------ arg0 in ecx +--* CNS_INT int 1
[000001] -----+------ arg1 in edx \--* CNS_INT int 2
```
where the node labels (e.g. arg0) help identifying the call arguments after reordering.
Here is a full dump of an entire statement:
```
STMT00000 (IL 0x010... ???)
[000025] --C-G------- └──▌ RETURN double
[000023] --C-G------- └──▌ CALL double C.DblSqrt
[000022] ------------ arg0 └──▌ MUL double
[000018] ------------ ├──▌ MUL double
[000014] ------------ │ ├──▌ MUL double
[000010] ------------ │ │ ├──▌ LCL_VAR double V03 loc0
[000013] ------------ │ │ └──▌ SUB double
[000011] ------------ │ │ ├──▌ LCL_VAR double V03 loc0
[000012] ------------ │ │ └──▌ LCL_VAR double V00 arg0
[000017] ------------ │ └──▌ SUB double
[000015] ------------ │ ├──▌ LCL_VAR double V03 loc0
[000016] ------------ │ └──▌ LCL_VAR double V01 arg1
[000021] ------------ └──▌ SUB double
[000019] ------------ ├──▌ LCL_VAR double V03 loc0
[000020] ------------ └──▌ LCL_VAR double V02 arg2
```
Tree nodes are identified by their `gtTreeID`. This field only exists in DEBUG builds, but is quite useful for
debugging, since all tree nodes are created from the routine `gtNewNode` (in
[src/jit/gentree.cpp](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/gentree.cpp)). If you find a
bad tree and wish to understand how it got corrupted, you can place a conditional breakpoint at the end of
`gtNewNode` to see when it is created, and then a data breakpoint on the field that you believe is corrupted.
The trees are connected by line characters (either in ASCII, by default, or in slightly more readable Unicode when
`COMPlus_JitDumpASCII=0` is specified), to make it a bit easier to read.
## Variable naming
The dump uses the index into the local variable table as its name. The arguments to the function come first, then the
local variables, then any compiler generated temps. Thus in a function with 2 parameters (remember "this" is also a
parameter), and one local variable, the first argument would be variable 0, the second argument variable 1, and the
local variable would be variable 2. As described earlier, tracked variables are given a tracked variable index which
identifies the bit for that variable in the dataflow bit vectors. This can lead to confusion as to whether the
variable number is its index into the local variable table, or its tracked index. In the dumps when we refer to a
variable by its local variable table index we use the 'V' prefix, and when we print the tracked index we prefix it by
a 'T'.
## References
<a name="[1]"></a>
[1] P. Briggs, K. D. Cooper, T. J. Harvey, and L. T. Simpson, "Practical improvements to the construction and destruction of static single assignment form," Software --- Practice and Experience, vol. 28, no. 8, pp. 859---881, Jul. 1998.
<a name="[2]"></a>
[2] Wimmer, C. and Mössenböck, D. "Optimized Interval Splitting in a Linear Scan Register Allocator," ACM VEE 2005, pp. 132-141. [http://portal.acm.org/citation.cfm?id=1064998&dl=ACM&coll=ACM&CFID=105967773&CFTOKEN=80545349](http://portal.acm.org/citation.cfm?id=1064998&dl=ACM&coll=ACM&CFID=105967773&CFTOKEN=80545349)
| JIT Compiler Structure
===
# Introduction
RyuJIT is the code name for the Just-In-Time Compiler (aka "JIT") for the .NET runtime. It was
evolved from the JIT used for x86 (jit32) on .NET Framework, and ported to support all other architecture and
platform targets supported by .NET Core.
The primary design considerations for RyuJIT are to:
* Maintain a high compatibility bar with previous JITs, especially those for x86 (jit32) and x64 (jit64).
* Support and enable good runtime performance through code optimizations, register allocation, and code generation.
* Ensure good throughput via largely linear-order optimizations and transformations, along with limitations on tracked variables for analyses (such as dataflow) that are inherently super-linear.
* Ensure that the JIT architecture is designed to support a range of targets and scenarios.
The first objective was the primary motivation for evolving the existing code base, rather than starting from scratch
or departing more drastically from the existing IR and architecture.
# Execution Environment and External Interface
RyuJIT provides both just-in-time and ahead-of-time compilation service for the .NET runtime. The runtime itself is
variously called the EE (execution engine), the VM (virtual machine), or simply the CLR (common language runtime).
Depending upon the configuration, the EE and JIT may reside in the same or different executable files. RyuJIT
implements the JIT side of the JIT/EE interfaces:
* `ICorJitCompiler` – this is the interface that the JIT compiler implements. This interface is defined in
[src/inc/corjit.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/inc/corjit.h)
and its implementation is in
[src/jit/ee_il_dll.cpp](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/ee_il_dll.cpp).
The following are the key methods on this interface:
* `compileMethod` is the main entry point for the JIT. The EE passes it a `ICorJitInfo` object,
and the "info" containing the IL, the method header, and various other useful tidbits.
It returns a pointer to the code, its size, and additional GC, EH and (optionally) debug info.
* `getVersionIdentifier` is the mechanism by which the JIT/EE interface is versioned.
There is a single GUID (manually generated) which the JIT and EE must agree on.
* `getMaxIntrinsicSIMDVectorLength` communicates to the EE the largest SIMD vector length that the JIT can support.
* `ICorJitInfo` – this is the interface that the EE implements. It has many methods defined on it that allow the JIT to
look up metadata tokens, traverse type signatures, compute field and vtable offsets, find method entry points,
construct string literals, etc. This bulk of this interface is inherited from `ICorDynamicInfo` which is defined in
[src/inc/corinfo.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/inc/corinfo.h). The implementation
is defined in
[src/vm/jitinterface.cpp](https://github.com/dotnet/runtime/blob/main/src/coreclr/vm/jitinterface.cpp).
# Internal Representation (IR)
## `Compiler` object
The `Compiler` object is the primary data structure of the JIT. While it is not part of the JIT's IR per se, it
serves as the root from which the data structures that implement the IR are accessible. For example, the `Compiler`
object points to the head of the function's `BasicBlock` list with the `fgFirstBB` field, as well as having
additional pointers to the end of the list, and other distinguished locations. `ICorJitCompiler::compileMethod()` is
invoked for each method, and creates a new `Compiler` object. Thus, the JIT need not worry about thread
synchronization while accessing `Compiler` state. The EE has the necessary synchronization to ensure there is a
single JIT compiled copy of a method when two or more threads try to trigger JIT compilation of the same method.
## Overview of the IR
RyuJIT represents a function as a doubly-linked list of `BasicBlock` values. Each `BasicBlock` has explicit edges to
its successors that define the function's non-exceptional control flow. Exceptional control flow is implicit, with
protected regions and handlers described in a table of `EHblkDsc` values. At the beginning of a compilation, each
`BasicBlock` contains nodes in a high-level, statement- and tree-oriented form (HIR: "high-level intermediate
representation"); this form persists throughout the JIT's front end. During the first phase of the back end--the
rationalization phase--the HIR for each block is lowered to a linearly-ordered, node-oriented form (LIR: "low-level
intermediate representation"). The fundamental distinction between HIR and LIR is in ordering semantics, though there
are also some restrictions on the types of nodes that may appear in an HIR or LIR block.
Both HIR and LIR blocks are composed of `GenTree` nodes that define the operations performed by the block. A
`GenTree` node may consume some number of operands and may produce a singly-defined, at-most-singly-used value as a
result. These values are referred to interchangably as *SDSU* (single def, single use) temps or *tree* temps.
Definitions (aka, defs) of SDSU temps are represented by `GenTree` nodes themselves, and uses are represented by
edges from the using node to the defining node. Furthermore, SDSU temps defined in one block may not be used in a
different block. In cases where a value must be multiply-defined, multiply-used, or defined in one block and used in
another, the IR provides another class of temporary: the local var (aka, local variable). Local vars are defined by
assignment nodes in HIR or store nodes in LIR, and are used by local var nodes in both forms.
An HIR block is composed of a doubly-linked list of statement nodes (`Statement`), each of which references a single
expression tree (`m_rootNode`). The `GenTree` nodes in this tree execute in "tree order", which is defined as the
order produced by a depth-first, left-to-right traversal of the tree, with two notable exceptions:
* Binary nodes marked with the `GTF_REVERSE_OPS` flag execute their right operand tree (`gtOp2`) before their left
operand tree (`gtOp1`)
* Dynamically-sized block copy nodes where `gtEvalSizeFirst` is `true` execute the `gtDynamicSize` tree
before executing their other operand trees.
In addition to tree order, HIR also requires that no SDSU temp is defined in one statement and used in another. In
situations where the requirements of tree and statement order prove onerous (e.g. when code must execute at a
particular point in a function), HIR provides `GT_COMMA` nodes as an escape valve: these nodes consume and discard
the results of their left-hand side while producing a copy of the value produced by their right-hand side. This
allows the compiler to insert code in the middle of a statement without requiring that the statement be split apart.
An LIR block is composed of a doubly-linked list of `GenTree` nodes, each of which describes a single operation in
the method. These nodes execute in the order given by the list; there is no relationship between the order in which a
node's operands appear and the order in which the operators that produced those operands execute. The only exception
to this rule occurs after the register allocator, which may introduce `GT_COPY` and `GT_RELOAD` nodes that execute in
"spill order". Spill order is defined as the order in which the register allocator visits a node's operands. For
correctness, the code generator must generate code for spills, reloads, and `GT_COPY`/`GT_RELOAD` nodes in this
order.
In addition to HIR and LIR `BasicBlock`s, a separate representation--`insGroup` and `instrDesc`--is used during the
actual instruction encoding.
(Note that this diagram is slightly out-of-date: GenTreeStmt no longer exists, and is replaced by `Statement`
nodes in the IR.)

## GenTree Nodes
Each operation is represented as a GenTree node, with an opcode (`GT_xxx`), zero or more child/operand `GenTree`
nodes, and additional fields as needed to represent the semantics of that node. Every node includes its type, value
number, assertions, register assignments, etc. when available.
`GenTree` nodes are doubly-linked in execution order, but the links are not necessarily valid during all phases of
the JIT. In HIR these links are primarily a convenience, as the order produced by a traversal of the links must match
the order produced by a "tree order" traversal (see above for details). In LIR these links define the execution order
of the nodes.
HIR statement nodes utilize the same `GenTree` base type as the operation nodes, though they are not truly related.
* The statement nodes are doubly-linked. The first statement node in a block points to the last node in the block via its `m_prev` link. Note that the last statement node does *not* point to the first; that is, the list is not fully circular.
* Each statement node contains two `GenTree` links – `m_rootNode` points to the top-level node in the statement (i.e. the root of the tree that represents the statement), while `m_treeList` points to the first node in execution order (again, this link is not always valid).
## Local var descriptors
A `LclVarDsc` represents a possibly-multiply-defined, possibly-multiply-used temporary. These temporaries may be used
to represent user local variables, arguments or JIT-created temps. Each lclVar has a `gtLclNum` which is the
identifier usually associated with the variable in the JIT and its dumps. The `LclVarDsc` contains the type, use
count, weighted use count, frame or register assignment, etc. A local var may be "tracked" (`lvTracked`), in which
case it participates in dataflow analysis, and has a secondary name (`lvVarIndex`) that allows for the use of dense
bit vectors.
### Example of Post-Import IR
For this snippet of code (extracted from
[src/tests/JIT/CodeGenBringUpTests/DblRoots.cs](https://github.com/dotnet/runtime/blob/main/src/tests/JIT/CodeGenBringUpTests/DblRoots.cs)), with `COMPlus_TieredCompilation=0` and using the DblRoots_ro.csproj project to compile it:
r1 = (-b + Math.Sqrt(b*b - 4*a*c))/(2*a);
A stripped-down dump of the `GenTree` nodes just after they are imported looks like this:
```
STMT00000 (IL 0x000...0x026)
▌ ASG double
├──▌ IND double
│ └──▌ LCL_VAR byref V03 arg3
└──▌ DIV double
├──▌ ADD double
│ ├──▌ NEG double
│ │ └──▌ LCL_VAR double V01 arg1
│ └──▌ INTRINSIC double sqrt
│ └──▌ SUB double
│ ├──▌ MUL double
│ │ ├──▌ LCL_VAR double V01 arg1
│ │ └──▌ LCL_VAR double V01 arg1
│ └──▌ MUL double
│ ├──▌ MUL double
│ │ ├──▌ CNS_DBL double 4.0000000000000000
│ │ └──▌ LCL_VAR double V00 arg0
│ └──▌ LCL_VAR double V02 arg2
└──▌ MUL double
├──▌ CNS_DBL double 2.0000000000000000
└──▌ LCL_VAR double V00 arg0
```
## Types
The JIT is primarily concerned with "primitive" types, i.e. integers, reference types, pointers, and floating point
types. It must also be concerned with the format of user-defined value types (i.e. struct types derived from
`System.ValueType`) – specifically, their size and the offset of any GC references they contain, so that they can be
correctly initialized and copied. The primitive types are represented in the JIT by the `var_types` enum, and any
additional information required for struct types is obtained from the JIT/EE interface by the use of an opaque
`CORINFO_CLASS_HANDLE`.
## Dataflow Information
In order to limit throughput impact, the JIT limits the number of lclVars for which liveness information is computed.
These are the tracked lclVars (`lvTracked` is true), and they are the only candidates for register allocation (i.e.
only these lclVars may be assigned registers over their entire lifetime). Defs and uses of untracked lclVars are
treated as stores and loads to/from the appropriate stack location, and the corresponding nodes act as normal
operators during register allocation.
The liveness analysis determines the set of defs, as well as the uses that are upward exposed, for each block. It
then propagates the liveness information. The result of the analysis is captured in the following:
* The live-in and live-out sets are captured in the `bbLiveIn` and `bbLiveOut` fields of the `BasicBlock`.
* The `GTF_VAR_DEF` flag is set on a lclVar node (all of which are of type `GenTreeLclVarCommon`) that is a definition.
* The `GTF_VAR_USEASG` flag is set (in addition to the `GTF_VAR_DEF` flag) on partial definitions of a local variable (i.e. `GT_LCL_FLD` nodes that do not define the entire variable).
## SSA
Static single assignment (SSA) form is constructed in a traditional manner [[1]](#[1]). The SSA names are recorded on
the lclVar references. While SSA form usually retains a pointer or link to the defining reference, RyuJIT currently
retains only the `BasicBlock` in which the definition of each SSA name resides.
## Value Numbering
Value numbering utilizes SSA for lclVar values, but also performs value numbering of expression trees. It takes
advantage of type safety by not invalidating the value number for field references with a heap write, unless the
write is to the same field. The IR nodes are annotated with the value numbers, which are indexes into a type-specific
value number store. Value numbering traverses the trees, performing symbolic evaluation of many operations.
# Phases of RyuJIT
The top-level function of interest is `Compiler::compCompile`. It invokes the following phases in order.
| **Phase** | **IR Transformations** |
| --- | --- |
| [Pre-import](#pre-import) | `Compiler->lvaTable` created and filled in for each user argument and variable. `BasicBlock` list initialized. |
| [Importation](#importation) | `GenTree` nodes created and linked in to `Statement` nodes, and Statements into BasicBlocks. Inlining candidates identified. |
| [Inlining](#inlining) | The IR for inlined methods is incorporated into the flowgraph. |
| [Struct Promotion](#struct-promotion) | New lclVars are created for each field of a promoted struct. |
| [Mark Address-Exposed Locals](#mark-addr-exposed) | lclVars with references occurring in an address-taken context are marked. This must be kept up-to-date. |
| [Morph Blocks](#morph-blocks) | Performs localized transformations, including mandatory normalization as well as simple optimizations. |
| [Eliminate Qmarks](#eliminate-qmarks) | All `GT_QMARK` nodes are eliminated, other than simple ones that do not require control flow. |
| [Flowgraph Analysis](#flowgraph-analysis) | `BasicBlock` predecessors are computed, and must be kept valid. Loops are identified, and normalized, cloned and/or unrolled. |
| [Normalize IR for Optimization](#normalize-ir) | lclVar references counts are set, and must be kept valid. Evaluation order of `GenTree` nodes (`gtNext`/`gtPrev`) is determined, and must be kept valid. |
| [SSA and Value Numbering Optimizations](#ssa-vn) | Computes liveness (`bbLiveIn` and `bbLiveOut` on `BasicBlock`s), and dominators. Builds SSA for tracked lclVars. Computes value numbers. |
| [Loop Invariant Code Hoisting](#licm) | Hoists expressions out of loops. |
| [Copy Propagation](#copy-propagation) | Copy propagation based on value numbers. |
| [Common Subexpression Elimination (CSE)](#cse) | Elimination of redundant subexressions based on value numbers. |
| [Assertion Propagation](#assertion-propagation) | Utilizes value numbers to propagate and transform based on properties such as non-nullness. |
| [Range analysis](#range-analysis) | Eliminate array index range checks based on value numbers and assertions |
| [Rationalization](#rationalization) | Flowgraph order changes from `FGOrderTree` to `FGOrderLinear`. All `GT_COMMA`, `GT_ASG` and `GT_ADDR` nodes are transformed. |
| [Lowering](#lowering) | Register requirements are fully specified (`gtLsraInfo`). All control flow is explicit. |
| [Register allocation](#reg-alloc) | Registers are assigned (`gtRegNum` and/or `gtRsvdRegs`), and the number of spill temps calculated. |
| [Code Generation](#code-generation) | Determines frame layout. Generates code for each `BasicBlock`. Generates prolog & epilog code for the method. Emit EH, GC and Debug info. |
## <a name="pre-import"></a>Pre-import
Prior to reading in the IL for the method, the JIT initializes the local variable table, and scans the IL to find
branch targets and form BasicBlocks.
## <a name="importation"></a>Importation
Importation is the phase that creates the IR for the method, reading in one IL instruction at a time, and building up
the statements. During this process, it may need to generate IR with multiple, nested expressions. This is the
purpose of the non-expression-like IR nodes:
* It may need to evaluate part of the expression into a temp, in which case it will use a comma (`GT_COMMA`) node to ensure that the temp is evaluated in the proper execution order – i.e. `GT_COMMA(GT_ASG(temp, exp), temp)` is inserted into the tree where "exp" would go.
* It may need to create conditional expressions, but adding control flow at this point would be quite messy. In this case it generates question mark/colon (?: or `GT_QMARK`/`GT_COLON`) trees that may be nested within an expression.
During importation, tail call candidates (either explicitly marked or opportunistically identified) are identified
and flagged. They are further validated, and possibly unmarked, during morphing.
## Morphing
The `fgMorph` phase includes a number of transformations:
### <a name="inlining"></a>Inlining
The `fgInline` phase determines whether each call site is a candidate for inlining. The initial determination is made
via a state machine that runs over the candidate method's IL. It estimates the native code size corresponding to the
inline method, and uses a set of heuristics, including the estimated size of the current method, to determine if
inlining would be profitable. If so, a separate `Compiler` object is created, and the importation phase is called to
create the tree for the candidate inline method. Inlining may be aborted prior to completion, if any conditions are
encountered that indicate that it may be unprofitable (or otherwise incorrect). If inlining is successful, the
inlinee compiler's trees are incorporated into the inliner compiler (the "parent"), with arguments and return values
appropriately transformed.
### <a name="struct-promotion"></a>Struct Promotion
Struct promotion (`fgPromoteStructs()`) analyzes the local variables and temps, and determines if their fields are
candidates for tracking (and possibly enregistering) separately. It first determines whether it is possible to
promote, which takes into account whether the layout may have holes or overlapping fields, whether its fields
(flattening any contained structs) will fit in registers, etc.
Next, it determines whether it is likely to be profitable, based on the number of fields, and whether the fields are
individually referenced.
When a lclVar is promoted, there are now N+1 lclVars for the struct, where N is the number of fields. The original
struct lclVar is not considered to be tracked, but its fields may be.
### <a name="mark-addr-exposed"></a>Mark Address-Exposed Locals
This phase traverses the expression trees, propagating the context (e.g. taking the address, indirecting) to
determine which lclVars have their address taken, and which therefore will not be register candidates. If a struct
lclVar has been promoted, and is then found to be address-taken, it will be considered "dependently promoted", which
is an odd way of saying that the fields will still be separately tracked, but they will not be register candidates.
### <a name="morph-blocks"></a>Morph Blocks
What is often thought of as "morph" involves localized transformations to the trees. In addition to performing simple
optimizing transformations, it performs some normalization that is required, such as converting field and array
accesses into pointer arithmetic. It can (and must) be called by subsequent phases on newly added or modified trees.
During the main Morph phase, the boolean `fgGlobalMorph` is set on the `Compiler` argument, which governs which
transformations are permissible.
### <a name="eliminate-qmarks"></a>Eliminate Qmarks
This expands most `GT_QMARK`/`GT_COLON` trees into blocks, except for the case that is instantiating a condition.
## <a name="flowgraph-analysis"></a>Flowgraph Analysis
At this point, a number of analyses and transformations are done on the flowgraph:
* Computing the predecessors of each block
* Computing edge weights, if profile information is available
* Computing reachability and dominators
* Identifying and normalizing loops (transforming while loops to "do while")
* Cloning and unrolling of loops
## <a name="normalize-ir"></a>Normalize IR for Optimization
At this point, a number of properties are computed on the IR, and must remain valid for the remaining phases. We will
call this "normalization"
* `lvaMarkLocalVars` – if this jit is optimizing, set the reference counts (raw and weighted) for lclVars, sort them,
and determine which will be tracked (currently up to 512). If not optimizing, all locals are given an implicit
reference count of one. Reference counts are not incrementally maintained. They can be recomputed if accurate
counts are needed.
* `optOptimizeBools` – this optimizes Boolean expressions, and may change the flowgraph (why is it not done prior to reachability and dominators?)
* Link the trees in evaluation order (setting `gtNext` and `gtPrev` fields): and `fgFindOperOrder()` and `fgSetBlockOrder()`.
## <a name="ssa-vn"></a>SSA and Value Numbering Optimizations
The next set of optimizations are built on top of SSA and value numbering. First, the SSA representation is built
(during which dataflow analysis, aka liveness, is computed on the lclVars), then value numbering is done using SSA.
### <a name="licm"></a>Loop Invariant Code Hoisting
This phase traverses all the loop nests, in outer-to-inner order (thus hoisting expressions outside the largest loop
in which they are invariant). It traverses all of the statements in the blocks in the loop that are always executed.
If the statement is:
* A valid CSE candidate
* Has no side-effects
* Does not raise an exception OR occurs in the loop prior to any side-effects
* Has a valid value number, and it is a lclVar defined outside the loop, or its children (the value numbers from which it was computed) are invariant.
### <a name="copy-propagation"></a>Copy Propagation
This phase walks each block in the graph (in dominator-first order, maintaining context between dominator and child)
keeping track of every live definition. When it encounters a variable that shares the VN with a live definition, it
is replaced with the variable in the live definition.
The JIT currently requires that the IR be maintained in conventional SSA form, as there is no "out of SSA"
translation (see the comments on `optVnCopyProp()` for more information).
### <a name="cse"></a>Common Subexpression Elimination (CSE)
Utilizes value numbers to identify redundant computations, which are then evaluated to a new temp lclVar, and then
reused.
### <a name="assertion-propagation"></a>Assertion Propagation
Utilizes value numbers to propagate and transform based on properties such as non-nullness.
### <a name="range-analysis"></a>Range analysis
Optimize array index range checks based on value numbers and assertions.
## <a name="rationalization"></a>Rationalization
As the JIT has evolved, changes have been made to improve the ability to reason over the tree in both "tree order"
and "linear order". These changes have been termed the "rationalization" of the IR. In the spirit of reuse and
evolution, some of the changes have been made only in the later ("backend") components of the JIT. The corresponding
transformations are made to the IR by a "Rationalizer" component. It is expected that over time some of these changes
will migrate to an earlier place in the JIT phase order:
* Elimination of assignment nodes (`GT_ASG`). The assignment node was problematic because the semantics of its destination (left hand side of the assignment) could not be determined without context. For example, a `GT_LCL_VAR` on the left-hand side of an assignment is a definition of the local variable, but on the right-hand side it is a use. Furthermore, since the execution order requires that the children be executed before the parent, it is unnatural that the left-hand side of the assignment appears in execution order before the assignment operator.
* During rationalization, all assignments are replaced by stores, which either represent their destination on the store node itself (e.g. `GT_LCL_VAR`), or by the use of a child address node (e.g. `GT_STORE_IND`).
* Elimination of address nodes (`GT_ADDR`). These are problematic because of the need for parent context to analyze the child.
* Elimination of "comma" nodes (`GT_COMMA`). These nodes are introduced for convenience during importation, during which a single tree is constructed at a time, and not incorporated into the statement list until it is completed. When it is necessary, for example, to store a partially-constructed tree into a temporary variable, a `GT_COMMA` node is used to link it into the tree. However, in later phases, these comma nodes are an impediment to analysis, and thus are eliminated.
* In some cases, it is not possible to fully extract the tree into a separate statement, due to execution order dependencies. In these cases, an "embedded" statement is created. While these are conceptually very similar to the `GT_COMMA` nodes, they do not masquerade as expressions.
* Elimination of "QMark" (`GT_QMARK`/`GT_COLON`) nodes is actually done at the end of morphing, long before the current rationalization phase. The presence of these nodes made analyses (especially dataflow) overly complex.
* Elimination of statements. Without statements, the execution order of a basic block's contents is fully defined by the `gtNext`/`gtPrev` links between `GenTree` nodes.
For our earlier example (Example of Post-Import IR), here is what the simplified dump looks like just prior to
Rationalization (the $ annotations are value numbers). Note that some common subexpressions have been computed into
new temporary lclVars, and that computation has been inserted as a `GT_COMMA` (comma) node in the IR:
```
STMT (IL 0x000...0x026)
▌ ASG double $VN.Void
├──▌ IND double $146
│ └──▌ LCL_VAR byref V03 arg3 u:1 (last use) $c0
└──▌ DIV double $146
├──▌ ADD double $144
│ ├──▌ COMMA double $83
│ │ ├──▌ ASG double $VN.Void
│ │ │ ├──▌ LCL_VAR double V06 cse0 d:1 $83
│ │ │ └──▌ INTRINSIC double sqrt $83
│ │ │ └──▌ SUB double $143
│ │ │ ├──▌ MUL double $140
│ │ │ │ ├──▌ LCL_VAR double V01 arg1 u:1 $81
│ │ │ │ └──▌ LCL_VAR double V01 arg1 u:1 $81
│ │ │ └──▌ MUL double $142
│ │ │ ├──▌ MUL double $141
│ │ │ │ ├──▌ LCL_VAR double V00 arg0 u:1 $80
│ │ │ │ └──▌ CNS_DBL double 4.0000000000000000 $180
│ │ │ └──▌ LCL_VAR double V02 arg2 u:1 $82
│ │ └──▌ LCL_VAR double V06 cse0 u:1 $83
│ └──▌ COMMA double $84
│ ├──▌ ASG double $VN.Void
│ │ ├──▌ LCL_VAR double V08 cse2 d:1 $84
│ │ └──▌ NEG double $84
│ │ └──▌ LCL_VAR double V01 arg1 u:1 $81
│ └──▌ LCL_VAR double V08 cse2 u:1 $84
└──▌ COMMA double $145
├──▌ ASG double $VN.Void
│ ├──▌ LCL_VAR double V07 cse1 d:1 $145
│ └──▌ MUL double $145
│ ├──▌ LCL_VAR double V00 arg0 u:1 $80
│ └──▌ CNS_DBL double 2.0000000000000000 $181
└──▌ LCL_VAR double V07 cse1 u:1 $145
```
After Rationalize, the nodes are presented in execution order, and the `GT_COMMA` (comma), `GT_ASG` (=), and
`Statement` nodes have been eliminated:
```
IL_OFFSET void IL offset: 0x0
t3 = LCL_VAR double V01 arg1 u:1 $81
t4 = LCL_VAR double V01 arg1 u:1 $81
┌──▌ t3 double
├──▌ t4 double
t5 = ▌ MUL double $140
t7 = LCL_VAR double V00 arg0 u:1 $80
t6 = CNS_DBL double 4.0000000000000000 $180
┌──▌ t7 double
├──▌ t6 double
t8 = ▌ MUL double $141
t9 = LCL_VAR double V02 arg2 u:1 $82
┌──▌ t8 double
├──▌ t9 double
10 = ▌ MUL double $142
┌──▌ t5 double
├──▌ t10 double
11 = ▌ SUB double $143
┌──▌ t11 double
12 = ▌ INTRINSIC double sqrt $83
┌──▌ t12 double
▌ STORE_LCL_VAR double V06 cse0 d:1
43 = LCL_VAR double V06 cse0 u:1 $83
t1 = LCL_VAR double V01 arg1 u:1 $81
┌──▌ t1 double
t2 = ▌ NEG double $84
┌──▌ t2 double
▌ STORE_LCL_VAR double V08 cse2 d:1
53 = LCL_VAR double V08 cse2 u:1 $84
┌──▌ t43 double
├──▌ t53 double
13 = ▌ ADD double $144
15 = LCL_VAR double V00 arg0 u:1 $80
14 = CNS_DBL double 2.0000000000000000 $181
┌──▌ t15 double
├──▌ t14 double
16 = ▌ MUL double $145
┌──▌ t16 double
▌ STORE_LCL_VAR double V07 cse1 d:1
48 = LCL_VAR double V07 cse1 u:1 $145
┌──▌ t13 double
├──▌ t48 double
17 = ▌ DIV double $146
t0 = LCL_VAR byref V03 arg3 u:1 (last use) $c0
┌──▌ t0 byref
├──▌ t17 double
▌ STOREIND double
IL_OFFSET void IL offset: 0x27
55 = LCL_VAR double V08 cse2 u:1 $84
45 = LCL_VAR double V06 cse0 u:1 $83
┌──▌ t55 double
├──▌ t45 double
33 = ▌ SUB double $147
50 = LCL_VAR double V07 cse1 u:1 $145
┌──▌ t33 double
├──▌ t50 double
37 = ▌ DIV double $148
20 = LCL_VAR byref V04 arg4 u:1 (last use) $c1
┌──▌ t20 byref
├──▌ t37 double
▌ STOREIND double
IL_OFFSET void IL offset: 0x4f
RETURN void $200
```
## <a name="lowering"></a>Lowering
Lowering is responsible for transforming the IR in such a way that the control flow, and any register requirements,
are fully exposed.
It does an execution-order traversal that performs context-dependent transformations such as
* expanding switch statements (using a switch table or a series of conditional branches)
* constructing addressing modes (`GT_LEA` nodes)
* determining the code generation strategy for block assignments (e.g. `GT_STORE_BLK`) which may become helper calls, unrolled loops, or an instruction like `rep stos`
* generating machine specific instructions (e.g. generating the `BT` x86/64 instruction)
* mark "contained" nodes - such a node does not generate any code and relies on its user to include the node's operation in its own codegen (e.g. memory operands, immediate operands)
* mark "reg optional" nodes - despite the name, such a node may produce a value in a register but its user does not require a register and can consume the value directly from a memory location
For example, this:
```
t47 = LCL_VAR ref V00 arg0
t48 = LCL_VAR int V01 arg1
┌──▌ t48 int
t51 = ▌ CAST long <- int
t52 = CNS_INT long 2
┌──▌ t51 long
├──▌ t52 long
t53 = ▌ LSH long
t54 = CNS_INT long 16 Fseq[#FirstElem]
┌──▌ t53 long
├──▌ t54 long
t55 = ▌ ADD long
┌──▌ t47 ref
├──▌ t55 long
t56 = ▌ ADD byref
┌──▌ t56 byref
t44 = ▌ IND int
```
Is transformed into this, in which the addressing mode is explicit:
```
t47 = LCL_VAR ref V00 arg0
t48 = LCL_VAR int V01 arg1
┌──▌ t48 int
t51 = ▌ CAST long <- int
┌──▌ t47 ref
├──▌ t51 long
t79 = ▌ LEA(b+(i*4)+16) byref
┌──▌ t79 byref
t44 = ▌ IND int
```
Sometimes `Lowering` will insert nodes into the execution order before the node that it is currently handling.
In such cases, it must ensure that they themselves are properly lowered. This includes:
* Generating only legal `LIR` nodes that do not themselves require lowering.
* Performing any needed containment analysis (e.g. `ContainCheckRange()`) on the newly added node(s).
After all nodes are lowered, liveness is run in preparation for register allocation.
## <a name="reg-alloc"></a>Register allocation
The RyuJIT register allocator uses a Linear Scan algorithm, with an approach similar to [[2]](#[2]). In discussion it
is referred to as either `LinearScan` (the name of the implementing class), or LSRA (Linear Scan Register
Allocation). In brief, it operates on two main data structures:
* `Intervals` (representing live ranges of variables or tree expressions) and `RegRecords` (representing physical registers), both of which derive from `Referenceable`.
* `RefPositions`, which represent uses or defs (or variants thereof, such as ExposedUses) of either `Intervals` or physical registers.
`LinearScan::buildIntervals()` traverses the entire method building RefPositions and Intervals as required. For example, for the `STORE_BLK` node in this snippet:
```
t67 = CNS_INT(h) long 0x2b5acef2c50 static Fseq[s1]
┌──▌ t67 long
t0 = ▌ IND ref
t1 = CNS_INT long 8 Fseq[#FirstElem]
┌──▌ t0 ref
├──▌ t1 long
t2 = ▌ ADD byref
┌──▌ t2 byref
t3 = ▌ IND struct
t31 = LCL_VAR_ADDR byref V08 tmp1
┌──▌ t31 byref
├──▌ t3 struct
▌ STORE_BLK(40) struct (copy) (Unroll)
```
the following RefPositions are generated:
```
N027 (???,???) [000085] -A-XG------- ▌ STORE_BLK(40) struct (copy) (Unroll) REG NA
Interval 16: int RefPositions {} physReg:NA Preferences=[allInt]
<RefPosition #40 @27 RefTypeDef <Ivl:16 internal> STORE_BLK BB01 regmask=[allInt] minReg=1>
Interval 17: float RefPositions {} physReg:NA Preferences=[allFloat]
<RefPosition #41 @27 RefTypeDef <Ivl:17 internal> STORE_BLK BB01 regmask=[allFloat] minReg=1>
<RefPosition #42 @27 RefTypeUse <Ivl:15> BB01 regmask=[allInt] minReg=1 last>
<RefPosition #43 @27 RefTypeUse <Ivl:16 internal> STORE_BLK BB01 regmask=[allInt] minReg=1 last>
<RefPosition #44 @27 RefTypeUse <Ivl:17 internal> STORE_BLK BB01 regmask=[allFloat] minReg=1 last>
```
The "@ 27" is the location number of the node. "internal" indicates a register that is internal to the node (in this case 2 internal registers are needed, one float (XMM on XARCH) and one int, as temporaries for copying). "regmask" indicates the register constraints for the `RefPosition`.
### Notable features of RyuJIT LinearScan
Unlike most register allocators, LSRA performs register allocation on an IR (Intermediate Representation) that is not
a direct representation of the target instructions. A given IR node may map to 0, 1 or multiple target instructions.
Nodes that are "contained" are handled by code generation as part of their parent node and thus may map to 0
instructions. A simple node will have a 1-to-1 mapping to a target instruction, and a more complex node (e.g.
`GT_STORE_BLK`) may map to multiple instructions.
### Pre-conditions:
It is the job of the `Lowering` phase to transform the IR such that:
* The nodes are in `LIR` form (i.e. all expression trees have been linearized, and the execution order of the nodes within a BasicBlock is specified by the `gtNext` and `gtPrev` links)
* All contained nodes are identified (`gtFlags` has the `GTF_CONTAINED` bit set)
* All nodes for which a register is optional are identified (`RefPosition::regOptional` is `true`)
* This is used for x86 and x64 on operands that can be directly consumed from memory if no register is allocated.
* All unused values (nodes that produce a result that is not consumed) are identified (`gtLIRFlags` has the `LIR::Flags::UnusedValue` bit set)
* Since tree temps (the values produced by nodes and consumed by their parent) are expected to be single-def, single-use (SDSU), normally the live range can be determined to end at the use. If there is no use, the register allocator doesn't know where the live range ends.
* Code can be generated without any context from the parent (consumer) of each node.
After `Lowering` has completed, liveness analysis is performed:
* It identifies which `lclVar`s should have their liveness computed.
* The reason this is done after `Lowering` is that it can introduce new `lclVar`s.
* It then does liveness analysis on those `lclVar`s, updating the `bbLiveIn` and `bbLiveOut` sets for each `BasicBlock`.
* This tells the register allocator which `lclVars` are live at block boundaries.
* Note that "tree temps" cannot be live at block boundaries.
### Allocation Overview
Allocation proceeds in 4 phases:
* Prepration:
* Determine the order in which the `BasicBlocks` will be allocated, and which predecessor of each block will be used to determine the starting location for variables live-in to the `BasicBlock`.
* Construct an `Interval` for each `lclVar` that may be enregistered.
* Construct a `RegRecord` for each physical register.
* Walk the `BasicBlocks` in the determined order building `RefPositions` for each register use, def, or kill.
* Just prior to building `RefPosition`s for the node, the `TreeNodeInfoInit()` method is called to determine its register requirements.
* Allocate the registers by traversing the `RefPositions`.
* Write back the register assignments, and perform any necessary moves at block boundaries where the allocations don't match.
Post-conditions:
* The `gtRegNum` property of all `GenTree` nodes that require a register has been set to a valid register number.
* For reg-optional nodes, the `GTF_NOREG_AT_USE` bit is set in `gtFlags` if a register was not allocated.
* The `gtRsvdRegs` field (a set/mask of registers) has the requested number of registers specified for internal use.
* All spilled values (lclVar or expression) are marked with `GTF_SPILL` at their definition. For lclVars, they are also marked with `GTF_SPILLED` at any use at which the value must be reloaded.
* For all lclVars that are register candidates:
* `lvRegNum` = initial register location (or `REG_STK`)
* `lvRegister` flag set if it always lives in the same register
* `lvSpilled` flag is set if it is ever spilled
* The maximum number of simultaneously-live spill locations of each type (used for spilling expression trees) has been communicated via calls to `compiler->tmpPreAllocateTemps(type)`.
## <a name="code-generation"></a>Code Generation
The process of code generation is relatively straightforward, as Lowering has done some of the work already. Code
generation proceeds roughly as follows:
* Determine the frame layout – allocating space on the frame for any lclVars that are not fully enregistered, as well as any spill temps required for spilling non-lclVar expressions.
* For each `BasicBlock`, in layout order, and each `GenTree` node in the block, in execution order:
* If the node is "contained" (i.e. its operation is subsumed by a parent node), do nothing.
* Otherwise, "consume" all the register operands of the node.
* This updates the liveness information (i.e. marking a lclVar as dead if this is the last use), and performs any needed copies.
* This must be done in "spill order" so that any spill/restore code inserted by the register allocator to resolve register conflicts is generated in the correct order. "
* Track the live variables in registers, as well as the live stack variables that contain GC refs.
* Produce the `instrDesc(s)` for the operation, with the current live GC references.
* Update the scope information (debug info) at block boundaries.
* Generate the prolog and epilog code.
* Write the final instruction bytes. It does this by invoking the emitter, which holds all the `instrDescs`.
# Phase-dependent Properties and Invariants of the IR
There are several properties of the IR that are valid only during (or after) specific phases of the JIT. This section describes the phase transitions, and how the IR properties are affected.
## Phase Transitions
* Flowgraph analysis
* Sets the predecessors of each block, which must be kept valid after this phase.
* Computes reachability and dominators. These may be invalidated by changes to the flowgraph.
* Computes edge weights, if profile information is available.
* Identifies and normalizes loops. These may be invalidated, but must be marked as such.
* Normalization
* The lclVar reference counts are set by `lvaMarkLocalVars()`.
* Statement ordering is determined by `fgSetBlockOrder()`. Execution order is a depth-first preorder traversal of the nodes, with the operands usually executed in order. The exceptions are:
* Binary operators, which can have the `GTF_REVERSE_OPS` flag set to indicate that the RHS (`gtOp2`) should be evaluated before the LHS (`gtOp1`).
* Dynamically-sized block copy nodes, which can have `gtEvalSizeFirst` set to `true` to indicate that their `gtDynamicSize` tree should be evaluated before executing their other operands.
* Rationalization
* All `GT_ASG` trees are transformed into `GT_STORE` variants (e.g. `GT_STORE_LCL_VAR`).
* All `GT_ADDR` nodes are eliminated (e.g. with `GT_LCL_VAR_ADDR`).
* All `GT_COMMA` and `Statement` nodes are removed and their constituent nodes linked into execution order.
* Lowering
* `GenTree` nodes are split or transformed as needed to expose all of their register requirements and any necessary `flowgraph` changes (e.g., for switch statements).
## GenTree phase-dependent properties
Ordering:
* For `Statement` nodes, the `m_next` and `m_prev` fields must always be consistent. The last statement in the `BasicBlock` must have `m_next` equal to `nullptr`. By convention, the `m_prev` of the first statement in the `BasicBlock` must be the last statement of the `BasicBlock`.
* In all phases, `m_rootNode` points to the top-level node of the expression.
* For 'GenTree' nodes, the `gtNext` and `gtPrev` fields are either `nullptr`, prior to ordering, or they are consistent (i.e. `A->gtPrev->gtNext = A`, and `A->gtNext->gtPrev == A`, if they are non-`nullptr`).
* After normalization the `m_treeList` of the containing statement points to the first node to be executed.
* Prior to normalization, the `gtNext` and `gtPrev` pointers on the expression `GenTree` nodes are invalid. The expression nodes are only traversed via the links from parent to child (e.g. `node->gtGetOp1()`, or `node->gtOp.gtOp1`). The `gtNext/gtPrev` links are set by `fgSetBlockOrder()`.
* After normalization, and prior to rationalization, the parent/child links remain the primary traversal mechanism. The evaluation order of any nested expression-statements (usually assignments) is enforced by the `GT_COMMA` in which they are contained.
* After rationalization, all `GT_COMMA` nodes are eliminated, statements are flattened, and the primary traversal mechanism becomes the `gtNext/gtPrev` links which define the execution order.
* In tree ordering:
* The `gtPrev` of the first node (`m_treeList`) is always `nullptr`.
* The `gtNext` of the last node (`m_rootNode`) is always `nullptr`.
## LclVar phase-dependent properties
LclVar ref counts track the number of uses and weighted used of a local in the jit IR. There are two sequences of
phases over which ref counts are valid, tracked via `lvaRefCountState`: an early sequence (state `RCS_EARLY`) and the
normal sequence (state `RCS_NORMAL`). Requests for ref counts via `lvRefCnt` and `lvRefCntWtd` must be aware of the
ref count state.
Before struct promotion the ref counts are invalid. Struct promotion enables `RCS_EARLY` and it and subsequent phases
through morph compute and uses ref counts on some locals to guide some struct optimizations. After morph the counts
go back to longer being valid.
The `RCS_NORMAL` sequence begins at normalization. Ref counts are computed and generally available via for the rest
of the compilation phases. The counts are not incrementally maintained and may go stale as the IR is optimized or
transformed, or maybe very approximate if the jit is not optimizing. They can be recomputed via `lvaComputeRefCounts`
at points where accurate counts are valuable. Currently this happens before and after lower.
# Supporting technologies and components
## Instruction encoding
Instruction encoding is performed by the emitter
([emit.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/emit.h)), using the
`insGroup`/`instrDesc` representation. The code generator calls methods on the emitter to construct `instrDescs`. The
encodings information is captured in the following:
* The "instruction" enumeration itemizes the different instructions available on each target, and is used as an index into the various encoding tables (e.g. `instInfo[]`, `emitInsModeFmtTab[]`) generated from the `instrs{tgt}.h` (e.g., [instrsxarch.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/instrsxarch.h)).
* The skeleton encodings are contained in the tables, and then there are methods on the emitter that handle the special encoding constraints for the various instructions, addressing modes, register types, etc.
## GC Info
Reporting of live GC references is done in two ways:
* For stack locations that are not tracked (these could be spill locations or lclVars – local variables or temps – that are not register candidates), they are initialized to `nullptr` in the prolog, and reported as live for the entire method.
* For lclVars with tracked lifetimes, or for expression involving GC references, we report the range over which the reference is live. This is done by the emitter, which adds this information to the instruction group, and which terminates instruction groups when the GC info changes.
The tracking of GC reference lifetimes is done via the `GCInfo` class in the JIT. It is declared in
[src/jit/jitgcinfo.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/jitgcinfo.h) (to
differentiate it from
[src/inc/gcinfo.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/inc/gcinfo.h)), and implemented in
[src/jit/gcinfo.cpp](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/gcinfo.cpp).
In a JitDump, the generated GC info can be seen following the "In gcInfoBlockHdrSave()" line.
## Debugger info
Debug info consists primarily of two types of information in the JIT:
* Mapping of IL offsets to native code offsets. This is accomplished via:
* the `m_ILOffsetX` on the statement nodes (`Statement`)
* the `gtLclILoffs` on lclVar references (`GenTreeLclVar`)
* The IL offsets are captured during CodeGen by calling `CodeGen::genIPmappingAdd()`, and then written to debug tables by `CodeGen::genIPmappingGen()`.
* Mapping of user locals to location (register or stack). This is accomplished via:
* Struct `siVarLoc` (in [compiler.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/compiler.h)) captures the location
* `VarScopeDsc` ([compiler.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/compiler.h)) captures the live range of a local variable in a given location.
## Exception handling
Exception handling information is captured in an `EHblkDsc` for each exception handling region. Each region includes
the first and last blocks of the try and handler regions, exception type, enclosing region, among other things. Look
at [jiteh.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/jiteh.h) and
[jiteh.cpp](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/jiteh.cpp), especially, for details.
Look at `Compiler::fgVerifyHandlerTab()` to see how the exception table constraints are verified.
# Reading a JitDump
One of the best ways of learning about the JIT compiler is examining a compilation dump in detail. The dump shows you
all the really important details of the basic data structures without all the implementation detail of the code.
Debugging a JIT bug almost always begins with a JitDump. Only after the problem is isolated by the dump does it make
sense to start debugging the JIT code itself.
Dumps are also useful because they give you good places to place breakpoints. If you want to see what is happening at
some point in the dump, simply search for the dump text in the source code. This gives you a great place to put a
conditional breakpoint.
There is not a strong convention about what or how the information is dumped, but generally you can find
phase-specific information by searching for the phase name. Some useful points follow.
## How to create a JitDump
You can enable dumps by setting the `COMPlus_JitDump` environment variable to a space-separated list of the method(s)
you want to dump. For example:
```cmd
:: Print out lots of useful info when
:: compiling methods named Main/GetEnumerator
set "COMPlus_JitDump=Main GetEnumerator"
```
See [Setting configuration variables](viewing-jit-dumps.md#setting-configuration-variables) for more
details on this.
Full instructions for dumping the compilation of some managed code can be found here:
[viewing-jit-dumps.md](viewing-jit-dumps.md)
## Reading expression trees
Expression trees are displayed using a pre-order traversal, with the subtrees of a node being displayed under the
node in operand order (e.g. `gtOp1`, `gtOp2`). This is similar to the way trees are displayed in typical user
interfaces (e.g. folder trees). Note that the operand order may be different from the actual execution order,
determined by `GTF_REVERSE_OPS` or other means. The operand order usually follows the order in high level languages
so that the typical infix, left to right expression `a - b` becomes prefix, top to bottom tree:
```
▌ SUB double
├──▌ LCL_VAR double V03 a
└──▌ LCL_VAR double V02 b
```
Assignments are displayed like all other binary operators, with `dest = src` becoming:
```
▌ ASG double
├──▌ LCL_VAR double V03 dest
└──▌ LCL_VAR double V02 src
```
Calls initially display in source order - `Order(1, 2, 3, 4)` is:
```
[000004] --C-G------- * CALL void Program.Order
[000000] ------------ arg0 +--* CNS_INT int 1
[000001] ------------ arg1 +--* CNS_INT int 2
[000002] ------------ arg2 +--* CNS_INT int 3
[000003] ------------ arg3 \--* CNS_INT int 4
```
but call morphing may change the order depending on the ABI so the above may become:
```
[000004] --CXG+------ * CALL void Program.Order
[000002] -----+------ arg2 on STK +--* CNS_INT int 3
[000003] -----+------ arg3 on STK +--* CNS_INT int 4
[000000] -----+------ arg0 in ecx +--* CNS_INT int 1
[000001] -----+------ arg1 in edx \--* CNS_INT int 2
```
where the node labels (e.g. arg0) help identifying the call arguments after reordering.
Here is a full dump of an entire statement:
```
STMT00000 (IL 0x010... ???)
[000025] --C-G------- └──▌ RETURN double
[000023] --C-G------- └──▌ CALL double C.DblSqrt
[000022] ------------ arg0 └──▌ MUL double
[000018] ------------ ├──▌ MUL double
[000014] ------------ │ ├──▌ MUL double
[000010] ------------ │ │ ├──▌ LCL_VAR double V03 loc0
[000013] ------------ │ │ └──▌ SUB double
[000011] ------------ │ │ ├──▌ LCL_VAR double V03 loc0
[000012] ------------ │ │ └──▌ LCL_VAR double V00 arg0
[000017] ------------ │ └──▌ SUB double
[000015] ------------ │ ├──▌ LCL_VAR double V03 loc0
[000016] ------------ │ └──▌ LCL_VAR double V01 arg1
[000021] ------------ └──▌ SUB double
[000019] ------------ ├──▌ LCL_VAR double V03 loc0
[000020] ------------ └──▌ LCL_VAR double V02 arg2
```
Tree nodes are identified by their `gtTreeID`. This field only exists in DEBUG builds, but is quite useful for
debugging, since all tree nodes are created from the routine `gtNewNode` (in
[src/jit/gentree.cpp](https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/gentree.cpp)). If you find a
bad tree and wish to understand how it got corrupted, you can place a conditional breakpoint at the end of
`gtNewNode` to see when it is created, and then a data breakpoint on the field that you believe is corrupted.
The trees are connected by line characters (either in ASCII, by default, or in slightly more readable Unicode when
`COMPlus_JitDumpASCII=0` is specified), to make it a bit easier to read.
## Variable naming
The dump uses the index into the local variable table as its name. The arguments to the function come first, then the
local variables, then any compiler generated temps. Thus in a function with 2 parameters (remember "this" is also a
parameter), and one local variable, the first argument would be variable 0, the second argument variable 1, and the
local variable would be variable 2. As described earlier, tracked variables are given a tracked variable index which
identifies the bit for that variable in the dataflow bit vectors. This can lead to confusion as to whether the
variable number is its index into the local variable table, or its tracked index. In the dumps when we refer to a
variable by its local variable table index we use the 'V' prefix, and when we print the tracked index we prefix it by
a 'T'.
## References
<a name="[1]"></a>
[1] P. Briggs, K. D. Cooper, T. J. Harvey, and L. T. Simpson, "Practical improvements to the construction and destruction of static single assignment form," Software --- Practice and Experience, vol. 28, no. 8, pp. 859---881, Jul. 1998.
<a name="[2]"></a>
[2] Wimmer, C. and Mössenböck, D. "Optimized Interval Splitting in a Linear Scan Register Allocator," ACM VEE 2005, pp. 132-141. [http://portal.acm.org/citation.cfm?id=1064998&dl=ACM&coll=ACM&CFID=105967773&CFTOKEN=80545349](http://portal.acm.org/citation.cfm?id=1064998&dl=ACM&coll=ACM&CFID=105967773&CFTOKEN=80545349)
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/coredump/_UCD_access_mem.c | /* libunwind - a platform-independent unwind library
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "_UCD_lib.h"
#include "_UCD_internal.h"
int
_UCD_access_mem(unw_addr_space_t as, unw_word_t addr, unw_word_t *val,
int write, void *arg)
{
if (write)
{
Debug(0, "write is not supported\n");
return -UNW_EINVAL;
}
struct UCD_info *ui = arg;
unw_word_t addr_last = addr + sizeof(*val)-1;
coredump_phdr_t *phdr;
unsigned i;
for (i = 0; i < ui->phdrs_count; i++)
{
phdr = &ui->phdrs[i];
if (phdr->p_vaddr <= addr && addr_last < phdr->p_vaddr + phdr->p_memsz)
{
goto found;
}
}
Debug(1, "addr 0x%llx is unmapped\n", (unsigned long long)addr);
return -UNW_EINVAL;
found: ;
const char *filename UNUSED;
off_t fileofs;
int fd;
if (addr_last >= phdr->p_vaddr + phdr->p_filesz)
{
/* This part of mapped address space is not present in coredump file */
/* Do we have it in the backup file? */
if (phdr->backing_fd < 0)
{
Debug(1, "access to not-present data in phdr[%d]: addr:0x%llx\n",
i, (unsigned long long)addr
);
return -UNW_EINVAL;
}
filename = phdr->backing_filename;
fileofs = addr - phdr->p_vaddr;
fd = phdr->backing_fd;
goto read;
}
filename = ui->coredump_filename;
fileofs = phdr->p_offset + (addr - phdr->p_vaddr);
fd = ui->coredump_fd;
read:
if (lseek(fd, fileofs, SEEK_SET) != fileofs)
goto read_error;
if (read(fd, val, sizeof(*val)) != sizeof(*val))
goto read_error;
Debug(1, "0x%llx <- [addr:0x%llx fileofs:0x%llx]\n",
(unsigned long long)(*val),
(unsigned long long)addr,
(unsigned long long)fileofs
);
return 0;
read_error:
Debug(1, "access out of file: addr:0x%llx fileofs:%llx file:'%s'\n",
(unsigned long long)addr,
(unsigned long long)fileofs,
filename
);
return -UNW_EINVAL;
}
| /* libunwind - a platform-independent unwind library
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "_UCD_lib.h"
#include "_UCD_internal.h"
int
_UCD_access_mem(unw_addr_space_t as, unw_word_t addr, unw_word_t *val,
int write, void *arg)
{
if (write)
{
Debug(0, "write is not supported\n");
return -UNW_EINVAL;
}
struct UCD_info *ui = arg;
unw_word_t addr_last = addr + sizeof(*val)-1;
coredump_phdr_t *phdr;
unsigned i;
for (i = 0; i < ui->phdrs_count; i++)
{
phdr = &ui->phdrs[i];
if (phdr->p_vaddr <= addr && addr_last < phdr->p_vaddr + phdr->p_memsz)
{
goto found;
}
}
Debug(1, "addr 0x%llx is unmapped\n", (unsigned long long)addr);
return -UNW_EINVAL;
found: ;
const char *filename UNUSED;
off_t fileofs;
int fd;
if (addr_last >= phdr->p_vaddr + phdr->p_filesz)
{
/* This part of mapped address space is not present in coredump file */
/* Do we have it in the backup file? */
if (phdr->backing_fd < 0)
{
Debug(1, "access to not-present data in phdr[%d]: addr:0x%llx\n",
i, (unsigned long long)addr
);
return -UNW_EINVAL;
}
filename = phdr->backing_filename;
fileofs = addr - phdr->p_vaddr;
fd = phdr->backing_fd;
goto read;
}
filename = ui->coredump_filename;
fileofs = phdr->p_offset + (addr - phdr->p_vaddr);
fd = ui->coredump_fd;
read:
if (lseek(fd, fileofs, SEEK_SET) != fileofs)
goto read_error;
if (read(fd, val, sizeof(*val)) != sizeof(*val))
goto read_error;
Debug(1, "0x%llx <- [addr:0x%llx fileofs:0x%llx]\n",
(unsigned long long)(*val),
(unsigned long long)addr,
(unsigned long long)fileofs
);
return 0;
read_error:
Debug(1, "access out of file: addr:0x%llx fileofs:%llx file:'%s'\n",
(unsigned long long)addr,
(unsigned long long)fileofs,
filename
);
return -UNW_EINVAL;
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/tilegx/Gresume.c | /* libunwind - a platform-independent unwind library
Copyright (C) 2008 CodeSourcery
Copyright (C) 2014 Tilera Corp.
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
#include "offsets.h"
#include <ucontext.h>
#ifndef UNW_REMOTE_ONLY
HIDDEN inline int
tilegx_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg)
{
int i;
struct cursor *c = (struct cursor *) cursor;
ucontext_t *uc = c->dwarf.as_arg;
Debug (1, "(cursor=%p\n", c);
return setcontext(uc);
}
#endif /* !UNW_REMOTE_ONLY */
static inline void
establish_machine_state (struct cursor *c)
{
unw_addr_space_t as = c->dwarf.as;
void *arg = c->dwarf.as_arg;
unw_fpreg_t fpval;
unw_word_t val;
int reg;
Debug (8, "copying out cursor state\n");
for (reg = 0; reg <= UNW_REG_LAST; ++reg)
{
Debug (16, "copying %s %d\n", unw_regname (reg), reg);
if (unw_is_fpreg (reg))
{
Debug (1, "no fp!");
abort ();
}
else
{
if (tdep_access_reg (c, reg, &val, 0) >= 0)
as->acc.access_reg (as, reg, &val, 1, arg);
}
}
}
int
unw_resume (unw_cursor_t *cursor)
{
struct cursor *c = (struct cursor *) cursor;
Debug (1, "(cursor=%p) ip=0x%lx\n", c, c->dwarf.ip);
if (!c->dwarf.ip)
{
/* This can happen easily when the frame-chain gets truncated
due to bad or missing unwind-info. */
Debug (1, "refusing to resume execution at address 0\n");
return -UNW_EINVAL;
}
establish_machine_state (c);
return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c,
c->dwarf.as_arg);
}
| /* libunwind - a platform-independent unwind library
Copyright (C) 2008 CodeSourcery
Copyright (C) 2014 Tilera Corp.
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
#include "offsets.h"
#include <ucontext.h>
#ifndef UNW_REMOTE_ONLY
HIDDEN inline int
tilegx_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg)
{
int i;
struct cursor *c = (struct cursor *) cursor;
ucontext_t *uc = c->dwarf.as_arg;
Debug (1, "(cursor=%p\n", c);
return setcontext(uc);
}
#endif /* !UNW_REMOTE_ONLY */
static inline void
establish_machine_state (struct cursor *c)
{
unw_addr_space_t as = c->dwarf.as;
void *arg = c->dwarf.as_arg;
unw_fpreg_t fpval;
unw_word_t val;
int reg;
Debug (8, "copying out cursor state\n");
for (reg = 0; reg <= UNW_REG_LAST; ++reg)
{
Debug (16, "copying %s %d\n", unw_regname (reg), reg);
if (unw_is_fpreg (reg))
{
Debug (1, "no fp!");
abort ();
}
else
{
if (tdep_access_reg (c, reg, &val, 0) >= 0)
as->acc.access_reg (as, reg, &val, 1, arg);
}
}
}
int
unw_resume (unw_cursor_t *cursor)
{
struct cursor *c = (struct cursor *) cursor;
Debug (1, "(cursor=%p) ip=0x%lx\n", c, c->dwarf.ip);
if (!c->dwarf.ip)
{
/* This can happen easily when the frame-chain gets truncated
due to bad or missing unwind-info. */
Debug (1, "refusing to resume execution at address 0\n");
return -UNW_EINVAL;
}
establish_machine_state (c);
return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c,
c->dwarf.as_arg);
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/metadata/lock-tracer.c | /**
* \file
* Runtime simple lock tracer
*
* Authors:
* Rodrigo Kumpera ([email protected])
*
*/
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#endif
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-threads.h>
#include "lock-tracer.h"
/*
* This is a very simple lock trace implementation. It can be used to verify that the runtime is
* correctly following all locking rules.
*
* To log more kind of locks just do the following:
* - add an entry into the RuntimeLocks enum
* - change mono_os_mutex_lock(mutex) to mono_locks_os_acquire (mutex, LockName)
* - change mono_os_mutex_unlock(mutex) to mono_locks_os_release (mutex, LockName)
* - change mono_coop_mutex_lock(mutex) to mono_locks_coop_acquire (mutex, LockName)
* - change mono_coop_mutex_unlock(mutex) to mono_locks_coop_release (mutex, LockName)
* - change the decoder to understand the new lock kind.
*
* TODO:
* - Use unbuffered IO without fsync
* - Switch to a binary log format
* - Enable tracing of more runtime locks
* - Add lock check assertions (must_not_hold_any_lock_but, must_hold_lock, etc)
* This should be used to verify methods that expect that a given lock is held at entrypoint, for example.
*
* To use the trace, define LOCK_TRACER in lock-trace.h and when running mono define MONO_ENABLE_LOCK_TRACER.
* This will produce a locks.ZZZ where ZZZ is the pid of the mono process.
* Use the decoder to verify the result.
*/
#ifdef LOCK_TRACER
#ifdef TARGET_OSX
#include <dlfcn.h>
#endif
static FILE *trace_file;
static mono_mutex_t tracer_lock;
static size_t base_address;
typedef enum {
RECORD_MUST_NOT_HOLD_ANY,
RECORD_MUST_NOT_HOLD_ONE,
RECORD_MUST_HOLD_ONE,
RECORD_LOCK_ACQUIRED,
RECORD_LOCK_RELEASED
} RecordType;
void
mono_locks_tracer_init (void)
{
Dl_info info;
int res;
char *name;
mono_os_mutex_init_recursive (&tracer_lock);
if (!g_hasenv ("MONO_ENABLE_LOCK_TRACER"))
return;
name = g_strdup_printf ("locks.%d", getpid ());
trace_file = fopen (name, "w+");
g_free (name);
#ifdef TARGET_OSX
res = dladdr ((void*)&mono_locks_tracer_init, &info);
/* The 0x1000 offset was found by empirically trying it. */
if (res)
base_address = (size_t)info.dli_fbase - 0x1000;
#endif
}
#ifdef HAVE_EXECINFO_H
static int
mono_backtrace (gpointer array[], int traces)
{
return backtrace (array, traces);
}
#else
static int
mono_backtrace (gpointer array[], int traces)
{
return 0;
}
#endif
static void
add_record (RecordType record_kind, RuntimeLocks kind, gpointer lock)
{
int i = 0;
const int no_frames = 6;
gpointer frames[no_frames];
char *msg;
if (!trace_file)
return;
memset (frames, 0, sizeof (gpointer) * no_frames);
mono_backtrace (frames, no_frames);
for (i = 0; i < no_frames; ++i)
frames [i] = (gpointer)((size_t)frames[i] - base_address);
/*We only dump 5 frames, which should be more than enough to most analysis.*/
msg = g_strdup_printf ("%x,%d,%d,%p,%p,%p,%p,%p,%p\n", (guint32)mono_native_thread_id_get (), record_kind, kind, lock, frames [1], frames [2], frames [3], frames [4], frames [5]);
fwrite (msg, strlen (msg), 1, trace_file);
fflush (trace_file);
g_free (msg);
}
void
mono_locks_lock_acquired (RuntimeLocks kind, gpointer lock)
{
add_record (RECORD_LOCK_ACQUIRED, kind, lock);
}
void
mono_locks_lock_released (RuntimeLocks kind, gpointer lock)
{
add_record (RECORD_LOCK_RELEASED, kind, lock);
}
#else
MONO_EMPTY_SOURCE_FILE (lock_tracer);
#endif /* LOCK_TRACER */
| /**
* \file
* Runtime simple lock tracer
*
* Authors:
* Rodrigo Kumpera ([email protected])
*
*/
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#endif
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-threads.h>
#include "lock-tracer.h"
/*
* This is a very simple lock trace implementation. It can be used to verify that the runtime is
* correctly following all locking rules.
*
* To log more kind of locks just do the following:
* - add an entry into the RuntimeLocks enum
* - change mono_os_mutex_lock(mutex) to mono_locks_os_acquire (mutex, LockName)
* - change mono_os_mutex_unlock(mutex) to mono_locks_os_release (mutex, LockName)
* - change mono_coop_mutex_lock(mutex) to mono_locks_coop_acquire (mutex, LockName)
* - change mono_coop_mutex_unlock(mutex) to mono_locks_coop_release (mutex, LockName)
* - change the decoder to understand the new lock kind.
*
* TODO:
* - Use unbuffered IO without fsync
* - Switch to a binary log format
* - Enable tracing of more runtime locks
* - Add lock check assertions (must_not_hold_any_lock_but, must_hold_lock, etc)
* This should be used to verify methods that expect that a given lock is held at entrypoint, for example.
*
* To use the trace, define LOCK_TRACER in lock-trace.h and when running mono define MONO_ENABLE_LOCK_TRACER.
* This will produce a locks.ZZZ where ZZZ is the pid of the mono process.
* Use the decoder to verify the result.
*/
#ifdef LOCK_TRACER
#ifdef TARGET_OSX
#include <dlfcn.h>
#endif
static FILE *trace_file;
static mono_mutex_t tracer_lock;
static size_t base_address;
typedef enum {
RECORD_MUST_NOT_HOLD_ANY,
RECORD_MUST_NOT_HOLD_ONE,
RECORD_MUST_HOLD_ONE,
RECORD_LOCK_ACQUIRED,
RECORD_LOCK_RELEASED
} RecordType;
void
mono_locks_tracer_init (void)
{
Dl_info info;
int res;
char *name;
mono_os_mutex_init_recursive (&tracer_lock);
if (!g_hasenv ("MONO_ENABLE_LOCK_TRACER"))
return;
name = g_strdup_printf ("locks.%d", getpid ());
trace_file = fopen (name, "w+");
g_free (name);
#ifdef TARGET_OSX
res = dladdr ((void*)&mono_locks_tracer_init, &info);
/* The 0x1000 offset was found by empirically trying it. */
if (res)
base_address = (size_t)info.dli_fbase - 0x1000;
#endif
}
#ifdef HAVE_EXECINFO_H
static int
mono_backtrace (gpointer array[], int traces)
{
return backtrace (array, traces);
}
#else
static int
mono_backtrace (gpointer array[], int traces)
{
return 0;
}
#endif
static void
add_record (RecordType record_kind, RuntimeLocks kind, gpointer lock)
{
int i = 0;
const int no_frames = 6;
gpointer frames[no_frames];
char *msg;
if (!trace_file)
return;
memset (frames, 0, sizeof (gpointer) * no_frames);
mono_backtrace (frames, no_frames);
for (i = 0; i < no_frames; ++i)
frames [i] = (gpointer)((size_t)frames[i] - base_address);
/*We only dump 5 frames, which should be more than enough to most analysis.*/
msg = g_strdup_printf ("%x,%d,%d,%p,%p,%p,%p,%p,%p\n", (guint32)mono_native_thread_id_get (), record_kind, kind, lock, frames [1], frames [2], frames [3], frames [4], frames [5]);
fwrite (msg, strlen (msg), 1, trace_file);
fflush (trace_file);
g_free (msg);
}
void
mono_locks_lock_acquired (RuntimeLocks kind, gpointer lock)
{
add_record (RECORD_LOCK_ACQUIRED, kind, lock);
}
void
mono_locks_lock_released (RuntimeLocks kind, gpointer lock)
{
add_record (RECORD_LOCK_RELEASED, kind, lock);
}
#else
MONO_EMPTY_SOURCE_FILE (lock_tracer);
#endif /* LOCK_TRACER */
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/utils/options.c | /**
* \file Runtime options
*
* Copyright 2020 Microsoft
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <stdio.h>
#include "options.h"
#include "mono/utils/mono-error-internals.h"
typedef enum {
MONO_OPTION_BOOL,
MONO_OPTION_BOOL_READONLY,
MONO_OPTION_INT,
MONO_OPTION_STRING
} MonoOptionType;
/* Define flags */
#define DEFINE_OPTION_FULL(option_type, ctype, c_name, cmd_name, def_value, comment) \
ctype mono_opt_##c_name = def_value;
#define DEFINE_OPTION_READONLY(option_type, ctype, c_name, cmd_name, def_value, comment)
#include "options-def.h"
/* Flag metadata */
typedef struct {
MonoOptionType option_type;
gpointer addr;
const char *cmd_name;
int cmd_name_len;
} OptionData;
static OptionData option_meta[] = {
#define DEFINE_OPTION_FULL(option_type, ctype, c_name, cmd_name, def_value, comment) \
{ option_type, &mono_opt_##c_name, cmd_name, sizeof (cmd_name) - 1 },
#define DEFINE_OPTION_READONLY(option_type, ctype, c_name, cmd_name, def_value, comment) \
{ option_type, NULL, cmd_name, sizeof (cmd_name) - 1 },
#include "options-def.h"
};
static const char*
option_type_to_str (MonoOptionType type)
{
switch (type) {
case MONO_OPTION_BOOL:
return "bool";
case MONO_OPTION_BOOL_READONLY:
return "bool (read-only)";
case MONO_OPTION_INT:
return "int";
case MONO_OPTION_STRING:
return "string";
default:
g_assert_not_reached ();
return NULL;
}
}
static char *
option_value_to_str (MonoOptionType type, gconstpointer addr)
{
switch (type) {
case MONO_OPTION_BOOL:
case MONO_OPTION_BOOL_READONLY:
return *(gboolean*)addr ? g_strdup ("true") : g_strdup ("false");
case MONO_OPTION_INT:
return g_strdup_printf ("%d", *(int*)addr);
case MONO_OPTION_STRING:
return *(char**)addr ? g_strdup_printf ("%s", *(char**)addr) : g_strdup ("\"\"");
default:
g_assert_not_reached ();
return NULL;
}
}
void
mono_options_print_usage (void)
{
#define DEFINE_OPTION_FULL(option_type, ctype, c_name, cmd_name, def_value, comment) do { \
char *val = option_value_to_str (option_type, &mono_opt_##c_name); \
g_printf (" --%s (%s)\n\ttype: %s default: %s\n", cmd_name, comment, option_type_to_str (option_type), val); \
g_free (val); \
} while (0);
#include "options-def.h"
}
/*
* mono_optiond_parse_options:
*
* Set options based on the command line arguments in ARGV/ARGC.
* Remove processed arguments from ARGV and set *OUT_ARGC to the
* number of remaining arguments.
*
* NOTE: This only sets the variables, the caller might need to do
* additional processing based on the new values of the variables.
*/
void
mono_options_parse_options (const char **argv, int argc, int *out_argc, MonoError *error)
{
int aindex = 0;
int i;
GHashTable *option_hash = NULL;
while (aindex < argc) {
const char *arg = argv [aindex];
if (!(arg [0] == '-' && arg [1] == '-')) {
aindex ++;
continue;
}
arg = arg + 2;
if (option_hash == NULL) {
/* Compute a hash to avoid n^2 behavior */
option_hash = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < G_N_ELEMENTS (option_meta); ++i) {
g_hash_table_insert (option_hash, (gpointer)option_meta [i].cmd_name, &option_meta [i]);
}
}
/* Compute flag name */
char *arg_copy = g_strdup (arg);
char *optname = arg_copy;
int len = strlen (arg);
int equals_sign_index = -1;
/* Handle no- prefix */
if (optname [0] == 'n' && optname [1] == 'o' && optname [2] == '-') {
optname += 3;
} else {
/* Handle option=value */
for (int i = 0; i < len; ++i) {
if (optname [i] == '=') {
equals_sign_index = i;
optname [i] = '\0';
break;
}
}
}
OptionData *option = (OptionData*)g_hash_table_lookup (option_hash, optname);
g_free (arg_copy);
if (!option) {
aindex ++;
continue;
}
switch (option->option_type) {
case MONO_OPTION_BOOL:
case MONO_OPTION_BOOL_READONLY: {
gboolean negate = FALSE;
if (len == option->cmd_name_len) {
} else if (arg [0] == 'n' && arg [1] == 'o' && arg [2] == '-' && len == option->cmd_name_len + 3) {
negate = TRUE;
} else {
break;
}
if (option->option_type == MONO_OPTION_BOOL_READONLY) {
mono_error_set_error (error, 1, "Unable to set option '%s' as it's read-only.\n", arg);
break;
}
*(gboolean*)option->addr = negate ? FALSE : TRUE;
argv [aindex] = NULL;
break;
}
case MONO_OPTION_INT:
case MONO_OPTION_STRING: {
const char *value = NULL;
if (len == option->cmd_name_len) {
// --option value
if (aindex + 1 == argc) {
mono_error_set_error (error, 1, "Missing value for option '%s'.\n", option->cmd_name);
break;
}
value = argv [aindex + 1];
argv [aindex] = NULL;
argv [aindex + 1] = NULL;
aindex ++;
} else if (equals_sign_index != -1) {
// option=value
value = arg + equals_sign_index + 1;
argv [aindex] = NULL;
} else {
g_assert_not_reached ();
}
if (option->option_type == MONO_OPTION_STRING) {
*(char**)option->addr = g_strdup (value);
} else {
char *endp;
long v = strtol (value, &endp, 10);
if (!value [0] || *endp) {
mono_error_set_error (error, 1, "Invalid value for option '%s': '%s'.\n", option->cmd_name, value);
break;
}
*(int*)option->addr = (int)v;
}
break;
}
default:
g_assert_not_reached ();
break;
}
if (!is_ok (error))
break;
aindex ++;
}
if (option_hash)
g_hash_table_destroy (option_hash);
if (!is_ok (error))
return;
/* Remove processed arguments */
aindex = 0;
for (i = 0; i < argc; ++i) {
if (argv [i])
argv [aindex ++] = argv [i];
}
*out_argc = aindex;
}
| /**
* \file Runtime options
*
* Copyright 2020 Microsoft
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <stdio.h>
#include "options.h"
#include "mono/utils/mono-error-internals.h"
typedef enum {
MONO_OPTION_BOOL,
MONO_OPTION_BOOL_READONLY,
MONO_OPTION_INT,
MONO_OPTION_STRING
} MonoOptionType;
/* Define flags */
#define DEFINE_OPTION_FULL(option_type, ctype, c_name, cmd_name, def_value, comment) \
ctype mono_opt_##c_name = def_value;
#define DEFINE_OPTION_READONLY(option_type, ctype, c_name, cmd_name, def_value, comment)
#include "options-def.h"
/* Flag metadata */
typedef struct {
MonoOptionType option_type;
gpointer addr;
const char *cmd_name;
int cmd_name_len;
} OptionData;
static OptionData option_meta[] = {
#define DEFINE_OPTION_FULL(option_type, ctype, c_name, cmd_name, def_value, comment) \
{ option_type, &mono_opt_##c_name, cmd_name, sizeof (cmd_name) - 1 },
#define DEFINE_OPTION_READONLY(option_type, ctype, c_name, cmd_name, def_value, comment) \
{ option_type, NULL, cmd_name, sizeof (cmd_name) - 1 },
#include "options-def.h"
};
static const char*
option_type_to_str (MonoOptionType type)
{
switch (type) {
case MONO_OPTION_BOOL:
return "bool";
case MONO_OPTION_BOOL_READONLY:
return "bool (read-only)";
case MONO_OPTION_INT:
return "int";
case MONO_OPTION_STRING:
return "string";
default:
g_assert_not_reached ();
return NULL;
}
}
static char *
option_value_to_str (MonoOptionType type, gconstpointer addr)
{
switch (type) {
case MONO_OPTION_BOOL:
case MONO_OPTION_BOOL_READONLY:
return *(gboolean*)addr ? g_strdup ("true") : g_strdup ("false");
case MONO_OPTION_INT:
return g_strdup_printf ("%d", *(int*)addr);
case MONO_OPTION_STRING:
return *(char**)addr ? g_strdup_printf ("%s", *(char**)addr) : g_strdup ("\"\"");
default:
g_assert_not_reached ();
return NULL;
}
}
void
mono_options_print_usage (void)
{
#define DEFINE_OPTION_FULL(option_type, ctype, c_name, cmd_name, def_value, comment) do { \
char *val = option_value_to_str (option_type, &mono_opt_##c_name); \
g_printf (" --%s (%s)\n\ttype: %s default: %s\n", cmd_name, comment, option_type_to_str (option_type), val); \
g_free (val); \
} while (0);
#include "options-def.h"
}
/*
* mono_optiond_parse_options:
*
* Set options based on the command line arguments in ARGV/ARGC.
* Remove processed arguments from ARGV and set *OUT_ARGC to the
* number of remaining arguments.
*
* NOTE: This only sets the variables, the caller might need to do
* additional processing based on the new values of the variables.
*/
void
mono_options_parse_options (const char **argv, int argc, int *out_argc, MonoError *error)
{
int aindex = 0;
int i;
GHashTable *option_hash = NULL;
while (aindex < argc) {
const char *arg = argv [aindex];
if (!(arg [0] == '-' && arg [1] == '-')) {
aindex ++;
continue;
}
arg = arg + 2;
if (option_hash == NULL) {
/* Compute a hash to avoid n^2 behavior */
option_hash = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < G_N_ELEMENTS (option_meta); ++i) {
g_hash_table_insert (option_hash, (gpointer)option_meta [i].cmd_name, &option_meta [i]);
}
}
/* Compute flag name */
char *arg_copy = g_strdup (arg);
char *optname = arg_copy;
int len = strlen (arg);
int equals_sign_index = -1;
/* Handle no- prefix */
if (optname [0] == 'n' && optname [1] == 'o' && optname [2] == '-') {
optname += 3;
} else {
/* Handle option=value */
for (int i = 0; i < len; ++i) {
if (optname [i] == '=') {
equals_sign_index = i;
optname [i] = '\0';
break;
}
}
}
OptionData *option = (OptionData*)g_hash_table_lookup (option_hash, optname);
g_free (arg_copy);
if (!option) {
aindex ++;
continue;
}
switch (option->option_type) {
case MONO_OPTION_BOOL:
case MONO_OPTION_BOOL_READONLY: {
gboolean negate = FALSE;
if (len == option->cmd_name_len) {
} else if (arg [0] == 'n' && arg [1] == 'o' && arg [2] == '-' && len == option->cmd_name_len + 3) {
negate = TRUE;
} else {
break;
}
if (option->option_type == MONO_OPTION_BOOL_READONLY) {
mono_error_set_error (error, 1, "Unable to set option '%s' as it's read-only.\n", arg);
break;
}
*(gboolean*)option->addr = negate ? FALSE : TRUE;
argv [aindex] = NULL;
break;
}
case MONO_OPTION_INT:
case MONO_OPTION_STRING: {
const char *value = NULL;
if (len == option->cmd_name_len) {
// --option value
if (aindex + 1 == argc) {
mono_error_set_error (error, 1, "Missing value for option '%s'.\n", option->cmd_name);
break;
}
value = argv [aindex + 1];
argv [aindex] = NULL;
argv [aindex + 1] = NULL;
aindex ++;
} else if (equals_sign_index != -1) {
// option=value
value = arg + equals_sign_index + 1;
argv [aindex] = NULL;
} else {
g_assert_not_reached ();
}
if (option->option_type == MONO_OPTION_STRING) {
*(char**)option->addr = g_strdup (value);
} else {
char *endp;
long v = strtol (value, &endp, 10);
if (!value [0] || *endp) {
mono_error_set_error (error, 1, "Invalid value for option '%s': '%s'.\n", option->cmd_name, value);
break;
}
*(int*)option->addr = (int)v;
}
break;
}
default:
g_assert_not_reached ();
break;
}
if (!is_ok (error))
break;
aindex ++;
}
if (option_hash)
g_hash_table_destroy (option_hash);
if (!is_ok (error))
return;
/* Remove processed arguments */
aindex = 0;
for (i = 0; i < argc; ++i) {
if (argv [i])
argv [aindex ++] = argv [i];
}
*out_argc = aindex;
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/utils/json.c | /**
* \file
* JSON writer
*
* Author:
* Joao Matos ([email protected])
*
* Copyright 2015 Xamarin Inc (http://www.xamarin.com)
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <mono/utils/json.h>
void mono_json_writer_init (JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
writer->text = g_string_new ("");
writer->indent = 0;
}
void mono_json_writer_destroy (JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
g_string_free (writer->text, /*free_segment=*/TRUE);
}
void mono_json_writer_indent_push(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
writer->indent += JSON_INDENT_VALUE;
}
void mono_json_writer_indent_pop(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
writer->indent -= JSON_INDENT_VALUE;
}
void mono_json_writer_indent(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
int i = 0;
for (i = 0; i < writer->indent; ++i)
g_string_append_c (writer->text, ' ');
}
void mono_json_writer_vprintf(JsonWriter* writer, const gchar *format, va_list args)
{
g_assert (writer && "Expected a valid JSON writer instance");
g_string_append_vprintf (writer->text, format, args);
}
void mono_json_writer_printf(JsonWriter* writer, const gchar *format, ...)
{
g_assert (writer && "Expected a valid JSON writer instance");
va_list args;
va_start (args, format);
g_string_append_vprintf (writer->text, format, args);
va_end (args);
}
void mono_json_writer_array_begin(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
g_string_append_printf (writer->text, "[\n");
writer->indent += JSON_INDENT_VALUE;
}
void mono_json_writer_array_end(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
g_string_append_printf (writer->text, "]");
writer->indent -= JSON_INDENT_VALUE;
}
void mono_json_writer_object_begin(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
mono_json_writer_printf (writer, "{\n");
writer->indent += JSON_INDENT_VALUE;
}
void mono_json_writer_object_end(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
mono_json_writer_printf (writer, "}");
}
void mono_json_writer_object_key(JsonWriter* writer, const gchar* format, ...)
{
g_assert (writer && "Expected a valid JSON writer instance");
va_list args;
va_start (args, format);
g_string_append_printf (writer->text, "\"");
mono_json_writer_vprintf (writer, format, args);
g_string_append_printf (writer->text, "\" : ");
va_end (args);
}
| /**
* \file
* JSON writer
*
* Author:
* Joao Matos ([email protected])
*
* Copyright 2015 Xamarin Inc (http://www.xamarin.com)
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <mono/utils/json.h>
void mono_json_writer_init (JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
writer->text = g_string_new ("");
writer->indent = 0;
}
void mono_json_writer_destroy (JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
g_string_free (writer->text, /*free_segment=*/TRUE);
}
void mono_json_writer_indent_push(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
writer->indent += JSON_INDENT_VALUE;
}
void mono_json_writer_indent_pop(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
writer->indent -= JSON_INDENT_VALUE;
}
void mono_json_writer_indent(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
int i = 0;
for (i = 0; i < writer->indent; ++i)
g_string_append_c (writer->text, ' ');
}
void mono_json_writer_vprintf(JsonWriter* writer, const gchar *format, va_list args)
{
g_assert (writer && "Expected a valid JSON writer instance");
g_string_append_vprintf (writer->text, format, args);
}
void mono_json_writer_printf(JsonWriter* writer, const gchar *format, ...)
{
g_assert (writer && "Expected a valid JSON writer instance");
va_list args;
va_start (args, format);
g_string_append_vprintf (writer->text, format, args);
va_end (args);
}
void mono_json_writer_array_begin(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
g_string_append_printf (writer->text, "[\n");
writer->indent += JSON_INDENT_VALUE;
}
void mono_json_writer_array_end(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
g_string_append_printf (writer->text, "]");
writer->indent -= JSON_INDENT_VALUE;
}
void mono_json_writer_object_begin(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
mono_json_writer_printf (writer, "{\n");
writer->indent += JSON_INDENT_VALUE;
}
void mono_json_writer_object_end(JsonWriter* writer)
{
g_assert (writer && "Expected a valid JSON writer instance");
mono_json_writer_printf (writer, "}");
}
void mono_json_writer_object_key(JsonWriter* writer, const gchar* format, ...)
{
g_assert (writer && "Expected a valid JSON writer instance");
va_list args;
va_start (args, format);
g_string_append_printf (writer->text, "\"");
mono_json_writer_vprintf (writer, format, args);
g_string_append_printf (writer->text, "\" : ");
va_end (args);
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/native/eventpipe/ds-server.c | #include "ds-rt-config.h"
#ifdef ENABLE_PERFTRACING
#if !defined(DS_INCLUDE_SOURCE_FILES) || defined(DS_FORCE_INCLUDE_SOURCE_FILES)
#define DS_IMPL_SERVER_GETTER_SETTER
#include "ds-server.h"
#include "ds-ipc.h"
#include "ds-protocol.h"
#include "ds-process-protocol.h"
#include "ds-eventpipe-protocol.h"
#include "ds-dump-protocol.h"
#include "ds-profiler-protocol.h"
#include "ds-rt.h"
/*
* Globals and volatile access functions.
*/
static volatile uint32_t _server_shutting_down_state = 0;
static ep_rt_wait_event_handle_t _server_resume_runtime_startup_event = { 0 };
static bool _server_disabled = false;
static volatile bool _is_paused_for_startup = false;
static
inline
bool
server_volatile_load_shutting_down_state (void)
{
return (ep_rt_volatile_load_uint32_t (&_server_shutting_down_state) != 0) ? true : false;
}
static
inline
void
server_volatile_store_shutting_down_state (bool state)
{
ep_rt_volatile_store_uint32_t (&_server_shutting_down_state, state ? 1 : 0);
}
/*
* Forward declares of all static functions.
*/
static
void
server_error_callback_create (
const ep_char8_t *message,
uint32_t code);
static
void
server_error_callback_close (
const ep_char8_t *message,
uint32_t code);
static
void
server_warning_callback (
const ep_char8_t *message,
uint32_t code);
static
bool
server_protocol_helper_unknown_command (
DiagnosticsIpcMessage *message,
DiagnosticsIpcStream *stream);
/*
* DiagnosticServer.
*/
static
void
server_error_callback_create (
const ep_char8_t *message,
uint32_t code)
{
EP_ASSERT (message != NULL);
DS_LOG_ERROR_2 ("Failed to create diagnostic IPC: error (%d): %s.", code, message);
}
static
void
server_error_callback_close (
const ep_char8_t *message,
uint32_t code)
{
EP_ASSERT (message != NULL);
DS_LOG_ERROR_2 ("Failed to close diagnostic IPC: error (%d): %s.", code, message);
}
static
bool
server_protocol_helper_unknown_command (
DiagnosticsIpcMessage *message,
DiagnosticsIpcStream *stream)
{
DS_LOG_WARNING_1 ("Received unknown request type (%d)", ds_ipc_header_get_commandset (ds_ipc_message_get_header_ref (message)));
ds_ipc_message_send_error (stream, DS_IPC_E_UNKNOWN_COMMAND);
ds_ipc_stream_free (stream);
return true;
}
static
void
server_warning_callback (
const ep_char8_t *message,
uint32_t code)
{
EP_ASSERT (message != NULL);
DS_LOG_WARNING_2 ("warning (%d): %s.", code, message);
}
EP_RT_DEFINE_THREAD_FUNC (server_thread)
{
EP_ASSERT (server_volatile_load_shutting_down_state () || ds_ipc_stream_factory_has_active_ports ());
if (!ds_ipc_stream_factory_has_active_ports ()) {
#ifndef DS_IPC_DISABLE_LISTEN_PORTS
DS_LOG_ERROR_0 ("Diagnostics IPC listener was undefined");
#endif
return 1;
}
while (!server_volatile_load_shutting_down_state ()) {
DiagnosticsIpcStream *stream = ds_ipc_stream_factory_get_next_available_stream (server_warning_callback);
if (!stream)
continue;
ds_rt_auto_trace_signal ();
DiagnosticsIpcMessage message;
if (!ds_ipc_message_init (&message))
continue;
if (!ds_ipc_message_initialize_stream (&message, stream)) {
ds_ipc_message_send_error (stream, DS_IPC_E_BAD_ENCODING);
ds_ipc_stream_free (stream);
ds_ipc_message_fini (&message);
continue;
}
if (ep_rt_utf8_string_compare (
(const ep_char8_t *)ds_ipc_header_get_magic_ref (ds_ipc_message_get_header_ref (&message)),
(const ep_char8_t *)DOTNET_IPC_V1_MAGIC) != 0) {
ds_ipc_message_send_error (stream, DS_IPC_E_UNKNOWN_MAGIC);
ds_ipc_stream_free (stream);
ds_ipc_message_fini (&message);
continue;
}
DS_LOG_INFO_2 ("DiagnosticServer - received IPC message with command set (%d) and command id (%d)", ds_ipc_header_get_commandset (ds_ipc_message_get_header_ref (&message)), ds_ipc_header_get_commandid (ds_ipc_message_get_header_ref (&message)));
switch ((DiagnosticsServerCommandSet)ds_ipc_header_get_commandset (ds_ipc_message_get_header_ref (&message))) {
case DS_SERVER_COMMANDSET_EVENTPIPE:
ds_eventpipe_protocol_helper_handle_ipc_message (&message, stream);
break;
case DS_SERVER_COMMANDSET_DUMP:
ds_dump_protocol_helper_handle_ipc_message (&message, stream);
break;
case DS_SERVER_COMMANDSET_PROCESS:
ds_process_protocol_helper_handle_ipc_message (&message, stream);
break;
case DS_SERVER_COMMANDSET_PROFILER:
ds_profiler_protocol_helper_handle_ipc_message (&message, stream);
break;
default:
server_protocol_helper_unknown_command (&message, stream);
break;
}
ds_ipc_message_fini (&message);
}
return (ep_rt_thread_start_func_return_t)0;
}
void
ds_server_disable (void)
{
_server_disabled = true;
}
bool
ds_server_init (void)
{
if (!ds_ipc_stream_factory_init ())
return false;
if (_server_disabled || !ds_rt_config_value_get_enable ())
return true;
bool result = false;
// Initialize PAL layer.
if (!ds_ipc_pal_init ()) {
DS_LOG_ERROR_1 ("Failed to initialize PAL layer (%d).", ep_rt_get_last_error ());
ep_raise_error ();
}
// Initialize the RuntimeIndentifier before use
ds_ipc_advertise_cookie_v1_init ();
// Ports can fail to be configured
if (!ds_ipc_stream_factory_configure (server_error_callback_create))
DS_LOG_ERROR_0 ("At least one Diagnostic Port failed to be configured.");
if (ds_ipc_stream_factory_any_suspended_ports ()) {
ep_rt_wait_event_alloc (&_server_resume_runtime_startup_event, true, false);
ep_raise_error_if_nok (ep_rt_wait_event_is_valid (&_server_resume_runtime_startup_event));
}
if (ds_ipc_stream_factory_has_active_ports ()) {
ds_rt_auto_trace_init ();
ds_rt_auto_trace_launch ();
ep_rt_thread_id_t thread_id = ep_rt_uint64_t_to_thread_id_t (0);
if (!ep_rt_thread_create ((void *)server_thread, NULL, EP_THREAD_TYPE_SERVER, (void *)&thread_id)) {
// Failed to create IPC thread.
ds_ipc_stream_factory_close_ports (NULL);
DS_LOG_ERROR_1 ("Failed to create diagnostic server thread (%d).", ep_rt_get_last_error ());
ep_raise_error ();
} else {
ds_rt_auto_trace_wait ();
}
}
result = true;
ep_on_exit:
return result;
ep_on_error:
EP_ASSERT (!result);
ep_exit_error_handler ();
}
bool
ds_server_shutdown (void)
{
server_volatile_store_shutting_down_state (true);
if (ds_ipc_stream_factory_has_active_ports ())
ds_ipc_stream_factory_shutdown (server_error_callback_close);
ds_ipc_stream_factory_fini ();
ds_ipc_pal_shutdown ();
return true;
}
// This method will block runtime bring-up IFF DOTNET_DefaultDiagnosticPortSuspend != NULL and DOTNET_DiagnosticPorts != 0 (it's default state)
// The _ds_resume_runtime_startup_event event will be signaled when the Diagnostics Monitor uses the ResumeRuntime Diagnostics IPC Command
void
ds_server_pause_for_diagnostics_monitor (void)
{
_is_paused_for_startup = true;
if (ds_ipc_stream_factory_any_suspended_ports ()) {
EP_ASSERT (ep_rt_wait_event_is_valid (&_server_resume_runtime_startup_event));
DS_LOG_ALWAYS_0 ("The runtime has been configured to pause during startup and is awaiting a Diagnostics IPC ResumeStartup command.");
if (ep_rt_wait_event_wait (&_server_resume_runtime_startup_event, 5000, false) != 0) {
ds_rt_server_log_pause_message ();
DS_LOG_ALWAYS_0 ("The runtime has been configured to pause during startup and is awaiting a Diagnostics IPC ResumeStartup command and has waited 5 seconds.");
ep_rt_wait_event_wait (&_server_resume_runtime_startup_event, EP_INFINITE_WAIT, false);
}
}
// allow wait failures to fall through and the runtime to continue coming up
}
void
ds_server_resume_runtime_startup (void)
{
ds_ipc_stream_factory_resume_current_port ();
if (!ds_ipc_stream_factory_any_suspended_ports () && ep_rt_wait_event_is_valid (&_server_resume_runtime_startup_event)) {
ep_rt_wait_event_set (&_server_resume_runtime_startup_event);
_is_paused_for_startup = false;
}
}
bool
ds_server_is_paused_in_startup (void)
{
return _is_paused_for_startup;
}
#endif /* !defined(DS_INCLUDE_SOURCE_FILES) || defined(DS_FORCE_INCLUDE_SOURCE_FILES) */
#endif /* ENABLE_PERFTRACING */
#ifndef DS_INCLUDE_SOURCE_FILES
extern const char quiet_linker_empty_file_warning_diagnostics_server;
const char quiet_linker_empty_file_warning_diagnostics_server = 0;
#endif
| #include "ds-rt-config.h"
#ifdef ENABLE_PERFTRACING
#if !defined(DS_INCLUDE_SOURCE_FILES) || defined(DS_FORCE_INCLUDE_SOURCE_FILES)
#define DS_IMPL_SERVER_GETTER_SETTER
#include "ds-server.h"
#include "ds-ipc.h"
#include "ds-protocol.h"
#include "ds-process-protocol.h"
#include "ds-eventpipe-protocol.h"
#include "ds-dump-protocol.h"
#include "ds-profiler-protocol.h"
#include "ds-rt.h"
/*
* Globals and volatile access functions.
*/
static volatile uint32_t _server_shutting_down_state = 0;
static ep_rt_wait_event_handle_t _server_resume_runtime_startup_event = { 0 };
static bool _server_disabled = false;
static volatile bool _is_paused_for_startup = false;
static
inline
bool
server_volatile_load_shutting_down_state (void)
{
return (ep_rt_volatile_load_uint32_t (&_server_shutting_down_state) != 0) ? true : false;
}
static
inline
void
server_volatile_store_shutting_down_state (bool state)
{
ep_rt_volatile_store_uint32_t (&_server_shutting_down_state, state ? 1 : 0);
}
/*
* Forward declares of all static functions.
*/
static
void
server_error_callback_create (
const ep_char8_t *message,
uint32_t code);
static
void
server_error_callback_close (
const ep_char8_t *message,
uint32_t code);
static
void
server_warning_callback (
const ep_char8_t *message,
uint32_t code);
static
bool
server_protocol_helper_unknown_command (
DiagnosticsIpcMessage *message,
DiagnosticsIpcStream *stream);
/*
* DiagnosticServer.
*/
static
void
server_error_callback_create (
const ep_char8_t *message,
uint32_t code)
{
EP_ASSERT (message != NULL);
DS_LOG_ERROR_2 ("Failed to create diagnostic IPC: error (%d): %s.", code, message);
}
static
void
server_error_callback_close (
const ep_char8_t *message,
uint32_t code)
{
EP_ASSERT (message != NULL);
DS_LOG_ERROR_2 ("Failed to close diagnostic IPC: error (%d): %s.", code, message);
}
static
bool
server_protocol_helper_unknown_command (
DiagnosticsIpcMessage *message,
DiagnosticsIpcStream *stream)
{
DS_LOG_WARNING_1 ("Received unknown request type (%d)", ds_ipc_header_get_commandset (ds_ipc_message_get_header_ref (message)));
ds_ipc_message_send_error (stream, DS_IPC_E_UNKNOWN_COMMAND);
ds_ipc_stream_free (stream);
return true;
}
static
void
server_warning_callback (
const ep_char8_t *message,
uint32_t code)
{
EP_ASSERT (message != NULL);
DS_LOG_WARNING_2 ("warning (%d): %s.", code, message);
}
EP_RT_DEFINE_THREAD_FUNC (server_thread)
{
EP_ASSERT (server_volatile_load_shutting_down_state () || ds_ipc_stream_factory_has_active_ports ());
if (!ds_ipc_stream_factory_has_active_ports ()) {
#ifndef DS_IPC_DISABLE_LISTEN_PORTS
DS_LOG_ERROR_0 ("Diagnostics IPC listener was undefined");
#endif
return 1;
}
while (!server_volatile_load_shutting_down_state ()) {
DiagnosticsIpcStream *stream = ds_ipc_stream_factory_get_next_available_stream (server_warning_callback);
if (!stream)
continue;
ds_rt_auto_trace_signal ();
DiagnosticsIpcMessage message;
if (!ds_ipc_message_init (&message))
continue;
if (!ds_ipc_message_initialize_stream (&message, stream)) {
ds_ipc_message_send_error (stream, DS_IPC_E_BAD_ENCODING);
ds_ipc_stream_free (stream);
ds_ipc_message_fini (&message);
continue;
}
if (ep_rt_utf8_string_compare (
(const ep_char8_t *)ds_ipc_header_get_magic_ref (ds_ipc_message_get_header_ref (&message)),
(const ep_char8_t *)DOTNET_IPC_V1_MAGIC) != 0) {
ds_ipc_message_send_error (stream, DS_IPC_E_UNKNOWN_MAGIC);
ds_ipc_stream_free (stream);
ds_ipc_message_fini (&message);
continue;
}
DS_LOG_INFO_2 ("DiagnosticServer - received IPC message with command set (%d) and command id (%d)", ds_ipc_header_get_commandset (ds_ipc_message_get_header_ref (&message)), ds_ipc_header_get_commandid (ds_ipc_message_get_header_ref (&message)));
switch ((DiagnosticsServerCommandSet)ds_ipc_header_get_commandset (ds_ipc_message_get_header_ref (&message))) {
case DS_SERVER_COMMANDSET_EVENTPIPE:
ds_eventpipe_protocol_helper_handle_ipc_message (&message, stream);
break;
case DS_SERVER_COMMANDSET_DUMP:
ds_dump_protocol_helper_handle_ipc_message (&message, stream);
break;
case DS_SERVER_COMMANDSET_PROCESS:
ds_process_protocol_helper_handle_ipc_message (&message, stream);
break;
case DS_SERVER_COMMANDSET_PROFILER:
ds_profiler_protocol_helper_handle_ipc_message (&message, stream);
break;
default:
server_protocol_helper_unknown_command (&message, stream);
break;
}
ds_ipc_message_fini (&message);
}
return (ep_rt_thread_start_func_return_t)0;
}
void
ds_server_disable (void)
{
_server_disabled = true;
}
bool
ds_server_init (void)
{
if (!ds_ipc_stream_factory_init ())
return false;
if (_server_disabled || !ds_rt_config_value_get_enable ())
return true;
bool result = false;
// Initialize PAL layer.
if (!ds_ipc_pal_init ()) {
DS_LOG_ERROR_1 ("Failed to initialize PAL layer (%d).", ep_rt_get_last_error ());
ep_raise_error ();
}
// Initialize the RuntimeIndentifier before use
ds_ipc_advertise_cookie_v1_init ();
// Ports can fail to be configured
if (!ds_ipc_stream_factory_configure (server_error_callback_create))
DS_LOG_ERROR_0 ("At least one Diagnostic Port failed to be configured.");
if (ds_ipc_stream_factory_any_suspended_ports ()) {
ep_rt_wait_event_alloc (&_server_resume_runtime_startup_event, true, false);
ep_raise_error_if_nok (ep_rt_wait_event_is_valid (&_server_resume_runtime_startup_event));
}
if (ds_ipc_stream_factory_has_active_ports ()) {
ds_rt_auto_trace_init ();
ds_rt_auto_trace_launch ();
ep_rt_thread_id_t thread_id = ep_rt_uint64_t_to_thread_id_t (0);
if (!ep_rt_thread_create ((void *)server_thread, NULL, EP_THREAD_TYPE_SERVER, (void *)&thread_id)) {
// Failed to create IPC thread.
ds_ipc_stream_factory_close_ports (NULL);
DS_LOG_ERROR_1 ("Failed to create diagnostic server thread (%d).", ep_rt_get_last_error ());
ep_raise_error ();
} else {
ds_rt_auto_trace_wait ();
}
}
result = true;
ep_on_exit:
return result;
ep_on_error:
EP_ASSERT (!result);
ep_exit_error_handler ();
}
bool
ds_server_shutdown (void)
{
server_volatile_store_shutting_down_state (true);
if (ds_ipc_stream_factory_has_active_ports ())
ds_ipc_stream_factory_shutdown (server_error_callback_close);
ds_ipc_stream_factory_fini ();
ds_ipc_pal_shutdown ();
return true;
}
// This method will block runtime bring-up IFF DOTNET_DefaultDiagnosticPortSuspend != NULL and DOTNET_DiagnosticPorts != 0 (it's default state)
// The _ds_resume_runtime_startup_event event will be signaled when the Diagnostics Monitor uses the ResumeRuntime Diagnostics IPC Command
void
ds_server_pause_for_diagnostics_monitor (void)
{
_is_paused_for_startup = true;
if (ds_ipc_stream_factory_any_suspended_ports ()) {
EP_ASSERT (ep_rt_wait_event_is_valid (&_server_resume_runtime_startup_event));
DS_LOG_ALWAYS_0 ("The runtime has been configured to pause during startup and is awaiting a Diagnostics IPC ResumeStartup command.");
if (ep_rt_wait_event_wait (&_server_resume_runtime_startup_event, 5000, false) != 0) {
ds_rt_server_log_pause_message ();
DS_LOG_ALWAYS_0 ("The runtime has been configured to pause during startup and is awaiting a Diagnostics IPC ResumeStartup command and has waited 5 seconds.");
ep_rt_wait_event_wait (&_server_resume_runtime_startup_event, EP_INFINITE_WAIT, false);
}
}
// allow wait failures to fall through and the runtime to continue coming up
}
void
ds_server_resume_runtime_startup (void)
{
ds_ipc_stream_factory_resume_current_port ();
if (!ds_ipc_stream_factory_any_suspended_ports () && ep_rt_wait_event_is_valid (&_server_resume_runtime_startup_event)) {
ep_rt_wait_event_set (&_server_resume_runtime_startup_event);
_is_paused_for_startup = false;
}
}
bool
ds_server_is_paused_in_startup (void)
{
return _is_paused_for_startup;
}
#endif /* !defined(DS_INCLUDE_SOURCE_FILES) || defined(DS_FORCE_INCLUDE_SOURCE_FILES) */
#endif /* ENABLE_PERFTRACING */
#ifndef DS_INCLUDE_SOURCE_FILES
extern const char quiet_linker_empty_file_warning_diagnostics_server;
const char quiet_linker_empty_file_warning_diagnostics_server = 0;
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./docs/design/coreclr/jit/multi-reg-call-nodes.md | Support for multiple destination regs, GT_CALL and GT_RETURN nodes that return a value in multiple registers:
============================================================================================================
The following targets allow a GT_CALL/GT_RETURN node to return a value in more than one register:
x64 Unix:
Structs of size betwee 9-16 bytes will be returned in RAX/RDX and/or XMM0/XMM1.
Arm64:
HFA structs will be returned in 1-4 successive VFP registers s0-s3 or d0-d3.
Structs of size 16-bytes will be returned in two return registers.
Arm32:
Long type value is returned in two return registers r0 and r1.
HFA structs will be returned in 1-4 successive VFP registers s0-s3 or d0-d3
x86:
Long type value is returned in two return registers EDX and EAX.
Legacy backend used reg-pairs for representing long return value on 32-bit targets, which makes reg allocation and codegen complex. Also this approach doesn't scale well to types that are returned in more than 2 registers. Arm32 HFA support in Legacy backend requires that HFA return value of a call is always stored to local in memory and with the local marked as not promotable. Original implementation of multi-reg return of structs on x64 Unix was similar to Arm32 and further LSRA was not ware of multi-reg call nodes because of which Codegen made some assumptions (e.g. multi-reg return value of a call node is never spilled) that are not always guaranteed.
This doc proposes new IR forms and an implementation design to support multi-reg call nodes in RyuJIT that is scalable without the limitations/complexity that Legacy backend implementation had.
Post Importation IR Forms
-------------------------
In importer any call returning a (struct or long type) value in two or more registers is forced to a temp
and temp is used in place of call node subsequently in IR. Note that creation of 'tmp' is avoided if return value of call is getting assigned to a local in IL.
```
// tmp = GT_CALL, where tmp is of TYP_STRUCT or TYP_LONG
GT_ASG(TYP_STRUCT or TYP_LONG, tmp, GT_CALL node)
```
Similarly importer will force IR of GT_RETURN node returning a value in multiple return registers to be
of the following form if operand of GT_RETURN is anything but a lclVar.
```
GT_ASG(TYP_STRUCT or TYP_LONG, tmp, op1)
GT_RETURN(tmp)
```
Post struct promotion IR forms
------------------------------
Before global morph of basic blocks, struct promotion takes place. It will give rise to the following
three cases:
Case 1:
tmp is not struct promoted or Type Dependently Promoted (P-DEP).
Case 2:
tmp is Type Independently Promoted (P-INDEP) but its field layout doesn't match the layout of return registers or tmp is P-FULL promoted struct (e.g. SIMD type structs).
For example, tmp could be a struct of 4 integers. But on x64 unix, two fields of such a struct
will be returned in one 8-byte return register.
Case 3:
tmp is P-INDEP promoted and its field layout matches the layout of return registers. That is one promoted field will get mapped to a single, un-shared register in the ABI for returning values.
An example is a struct containing two fields of `{TYP_REF, TYP_DOUBLE} `on X64 Unix.
Post Global Morph, IR forms of tmp=GT_CALL where tmp is of TYP_STRUCT
---------------------------------------------------------------------
Case 3 is morphed into
`GT_STORE_MULTI_VAR(TYP_STRUCT, <FieldLcl1, FieldLcl2, FieldLcl3, FieldLcl4>, op1 = GT_CALL)`
Where FieldLcl[1..4] are lcl numbers of P-INDEP promoted fields of tmp. The limit of 2-4 locals
is statically dependent on target platform/architecture.
GT_STORE_MULTI_VAR is a new GenTree node to represent the store operation to 2-4 locals
using multi-reg/mem value of a call/lclvar respectively. It also will have additional fields
to store the registers into which FieldLcl[1..4] need to be stored and also a spill mask
to indicate which of the locals needs to be spilled.
During codegen, return value of call in multiple return registers need to be stored to the
corresponding registers of the locals by properly handling any circular dependencies.
Case 1 is morphed as
`GT_OBJ(&tmp) = GT_CALL`
Post rationalization this will get converted to GT_STORE_OBJ/BLK(&tmp, GT_CALL) and
block op codegen will special case for multi-reg call case. This case simpler because, although it is
consuming multiple registers from the call, it doesn't have the complication of multiple
destination registers.
Case 2 can be handled one of the following two ways
a) Force tmp to memory and morph it as in case 1 above
b) Create 2-4 temp locals matching the type of respective return registers of GT_CALL and
use them to create following IR
```
GT_STORE_MULTI_VAR(TYP_STRUCT, <tmpLcl1, tmpLcl2, tmpLcl3, tmpLcl4>, op1 = GT_CALL)
```
Example: say on x64 unix, return type is a struct with 3 fields: TYP_INT, TYP_INT and TYP_REF.
First two fields would be combined into a single local of TYP_LONG and third field would
would go into a single local of TYP_REF.
Additional IR nodes can be created to extract/assemble fields of tmp struct from individual tmpLcls.
Platform agnostic ReturnTypeDesc on a GT_CALL node
--------------------------------------------------
Every GT_CALL node will have a light-weight ReturnTypeDesc that provides a platform independent interface to query the following:
- Respective return types of a multi-reg return value
- Respective Return register numbers in which the value is returned.
ReturnTypeDesc is initialized during importation while creating GenTreeCall node.
GT_CALL node is augmented with the following additional state:
gtOtherRegs - an array of MAX_RET_REG_COUNT-1 reg numbers of multi-reg return. gtRegNum field
will always be the first return reg.
gtSpillFlags - an array to hold GTF_SPILL/GTF_SPILLED state of each reg. This allows us to
spill/reload individual return registers of a multi-reg call node work.
Post Global Morph, IR forms of GT_RETURN(tmp) where tmp is of TYP_STRUCT
------------------------------------------------------------------------
Case 3 is morphed into
```
GT_RETURN (TYP_STRUCT, op1 = GT_MULTI_VAR(TYP_STRUCT, <Fieldlcl1, FieldLcl2, FieldLcl3, FieldLcl4>))
```
Where FieldLcl[1..4] are lcl numbers of independently promoted fields of tmp and
GT_MULTI_VAR is a new node that represents 2-4 independent local vars.
Case 1 remains unchanged
`GT_RETURN(TYP_STRUCT, op1 = tmp)`
Case 2 is handled as follows:
a) Force tmp to memory and morph it as in case 1 above
b) Create 2-4 temp locals matching the type of respective return registers of GT_RETURN and
use them to extract individual fields from tmp and morph it as in case 3 above.
tmpLcl1 = GenTree Nodes to extract first 8-bytes from tmp
tmpLcl2 = GenTree Nodes to extract next 8-bytes from tmp and so on
```
GT_RETURN(TYP_STRUCT, op1 = GT_STORE_MULTI_VAR(TYP_STRUCT, <tmpLcl1, tmpLcl2, tmpLcl3, tmpLcl4>, tmp))
```
Post Lowering, IR forms of GT_CALL node returning TYP_LONG value
----------------------------------------------------------------
During Lowering, such call nodes are lowered into tmp=GT_CALL if the return value of call node is not already assigned to a local. Further tmp is decomposed into GT_LONG.
Post IR lowering, GT_CALL will be transformed into
```
GT_STORE_LCL_VAR(TYP_LONG, lcl Num of tmp, op1 = GT_CALL)
```
where tmp is decomposed into GT_LONG(GT_LCL_VAR(tmpHi), GT_LCL_VAR(tmpLo))
and finally GT_STORE_LCL_VAR is transformed into
```
GT_STORE_MULTI_VAR(TYP_LONG, <tmpHi, tmpLo>, op1=GT_CALL)
```
where tmpHi and tmpLo are promoted lcl fields of tmp.
Post Lowering, IR forms of GT_RETURN(tmp) where tmp is of TYP_LONG
------------------------------------------------------------------
LclVar tmp will be decomposed into two locals and the resulting IR would be GT_RETURN(GT_LONG)
Lowering Register specification
--------------------------------
DstCount of GT_CALL node returning multi-reg return value will be set to 2 or 3 or 4 depending on the number of return registers and its dstCandidates is set to the fixed mask of return registers.
SrcCount and DstCount of GT_STORE_MULTI_VAR will be set 2 or 3 or 4 depending on the number of locals to which a value is assigned. Note that those locals that do not require a value to be assigned are represented as BAD_VAR_NUM.
SrcCount of GT_RETURN returning a multi-reg value will be set to 2 or 3 or 4 depending on the number of return registers.
LSRA Considerations
-------------------
LSRA needs to add support for multi-reg destination GT_CALL, GT_MULTI_VAR and GT_STORE_MULTI_VAR nodes.
Codegen Considerations
----------------------
genProduceReg()/genConsumeReg() code paths need to support mullti-reg destination GT_CALL, GT_MULTI_VAR and GT_STORE_MULTI_VAR nodes.
GT_RETURN(tmp) where tmp is of TYP_STRUCT
- tmp would either be in memory GT_LCL_VAR or GT_MULTI_VAR of TYP_STRUCT
GT_RETURN(op1) where op1 is of TYP_LONG
- op1 should be always of the form GT_LONG(tmpLclHi, tmpLclLo)
Sub work items
--------------
The following are the sub work items and against each is indicated its current status:
1. (Done) Refactor code to abstract structDesc field of GenTreeCall node
ReturnTypeDesc would abstract away existing structDesc (x64 unix) and implement
an API and replace all uses of structDesc of call node with the API. This would be
a pure code refactoring with the addition of ReturnTypeDesc on a GenTreeCall node.
2. (Done) Get rid of structDesc and replace it with ReturnTypeDesc.
Note that on x64 Unix, we still query structDesc from VM and use it to initialize ReturnTypeDesc.
3. (Done) Phase 1 Implementation of multi-reg GT_CALL/GT_RETURN node support for x64 Unix
- Importer changes to force IR to be of the form tmp=call always for multi-reg call nodes
- Importer changes to force IR to be of the form GT_RETURN(tmp) always for multi-reg return
- tmp will always be an in memory lcl var.
- Till First class struct support for GT_OBJ/GT_STORE_OBJ comes on-line IR will be of the form
`GT_STORE_LCL_VAR(tmpLcl, op1 = GT_CALL)`
where tmpLcl will always be an in memory lcl var of TYP_STRUCT
- Lowering/LSRA/Codegen support to allocate multiple regs to GT_CALL nodes.
- GT_CALL nodes will be governed by a single spill flag i.e. all return registers are spilled together.
- GT_RETURN(tmp) - lowering will mark op1=tmp as contained and generate code as existing code does.
4. Phase 2 implementation of multi-reg GT_CALL/GT_RETURN node support for x64 unix
- Add new gentree nodes GT_MULTI_VAR and GT_STORE_MULTI_VAR and plumb through rest of JIT phases.
- Global morph code changes to support Case 3 (i.e P-DEP promoted structs)
- Lowering/LSRA/Codegen changes to support GT_MULTI_VAR and GT_STORE_MULTI_VAR
5. When First class structs support comes on-line, leverage GT_OBJ/GT_STORE_OBJ to store multi-reg
return value of a GT_CALL node to memory cleaning up the code in GT_STORE_LCL_VAR.
6. (Done) HFA and multi-reg struct return support for Arm64
7. (Done) x86 long return support
8. (Optimization) Phase 3 implementation of multi-reg GT_CALL/GT_RETURN node support for x64 unix
- Global morph code changes to support some of the important Case 2 efficiently
9. HFA struct and long return support for Arm32 RyuJIT - we should be able to leverage x86 long return and Arm64 HFA struct return work here.
| Support for multiple destination regs, GT_CALL and GT_RETURN nodes that return a value in multiple registers:
============================================================================================================
The following targets allow a GT_CALL/GT_RETURN node to return a value in more than one register:
x64 Unix:
Structs of size betwee 9-16 bytes will be returned in RAX/RDX and/or XMM0/XMM1.
Arm64:
HFA structs will be returned in 1-4 successive VFP registers s0-s3 or d0-d3.
Structs of size 16-bytes will be returned in two return registers.
Arm32:
Long type value is returned in two return registers r0 and r1.
HFA structs will be returned in 1-4 successive VFP registers s0-s3 or d0-d3
x86:
Long type value is returned in two return registers EDX and EAX.
Legacy backend used reg-pairs for representing long return value on 32-bit targets, which makes reg allocation and codegen complex. Also this approach doesn't scale well to types that are returned in more than 2 registers. Arm32 HFA support in Legacy backend requires that HFA return value of a call is always stored to local in memory and with the local marked as not promotable. Original implementation of multi-reg return of structs on x64 Unix was similar to Arm32 and further LSRA was not ware of multi-reg call nodes because of which Codegen made some assumptions (e.g. multi-reg return value of a call node is never spilled) that are not always guaranteed.
This doc proposes new IR forms and an implementation design to support multi-reg call nodes in RyuJIT that is scalable without the limitations/complexity that Legacy backend implementation had.
Post Importation IR Forms
-------------------------
In importer any call returning a (struct or long type) value in two or more registers is forced to a temp
and temp is used in place of call node subsequently in IR. Note that creation of 'tmp' is avoided if return value of call is getting assigned to a local in IL.
```
// tmp = GT_CALL, where tmp is of TYP_STRUCT or TYP_LONG
GT_ASG(TYP_STRUCT or TYP_LONG, tmp, GT_CALL node)
```
Similarly importer will force IR of GT_RETURN node returning a value in multiple return registers to be
of the following form if operand of GT_RETURN is anything but a lclVar.
```
GT_ASG(TYP_STRUCT or TYP_LONG, tmp, op1)
GT_RETURN(tmp)
```
Post struct promotion IR forms
------------------------------
Before global morph of basic blocks, struct promotion takes place. It will give rise to the following
three cases:
Case 1:
tmp is not struct promoted or Type Dependently Promoted (P-DEP).
Case 2:
tmp is Type Independently Promoted (P-INDEP) but its field layout doesn't match the layout of return registers or tmp is P-FULL promoted struct (e.g. SIMD type structs).
For example, tmp could be a struct of 4 integers. But on x64 unix, two fields of such a struct
will be returned in one 8-byte return register.
Case 3:
tmp is P-INDEP promoted and its field layout matches the layout of return registers. That is one promoted field will get mapped to a single, un-shared register in the ABI for returning values.
An example is a struct containing two fields of `{TYP_REF, TYP_DOUBLE} `on X64 Unix.
Post Global Morph, IR forms of tmp=GT_CALL where tmp is of TYP_STRUCT
---------------------------------------------------------------------
Case 3 is morphed into
`GT_STORE_MULTI_VAR(TYP_STRUCT, <FieldLcl1, FieldLcl2, FieldLcl3, FieldLcl4>, op1 = GT_CALL)`
Where FieldLcl[1..4] are lcl numbers of P-INDEP promoted fields of tmp. The limit of 2-4 locals
is statically dependent on target platform/architecture.
GT_STORE_MULTI_VAR is a new GenTree node to represent the store operation to 2-4 locals
using multi-reg/mem value of a call/lclvar respectively. It also will have additional fields
to store the registers into which FieldLcl[1..4] need to be stored and also a spill mask
to indicate which of the locals needs to be spilled.
During codegen, return value of call in multiple return registers need to be stored to the
corresponding registers of the locals by properly handling any circular dependencies.
Case 1 is morphed as
`GT_OBJ(&tmp) = GT_CALL`
Post rationalization this will get converted to GT_STORE_OBJ/BLK(&tmp, GT_CALL) and
block op codegen will special case for multi-reg call case. This case simpler because, although it is
consuming multiple registers from the call, it doesn't have the complication of multiple
destination registers.
Case 2 can be handled one of the following two ways
a) Force tmp to memory and morph it as in case 1 above
b) Create 2-4 temp locals matching the type of respective return registers of GT_CALL and
use them to create following IR
```
GT_STORE_MULTI_VAR(TYP_STRUCT, <tmpLcl1, tmpLcl2, tmpLcl3, tmpLcl4>, op1 = GT_CALL)
```
Example: say on x64 unix, return type is a struct with 3 fields: TYP_INT, TYP_INT and TYP_REF.
First two fields would be combined into a single local of TYP_LONG and third field would
would go into a single local of TYP_REF.
Additional IR nodes can be created to extract/assemble fields of tmp struct from individual tmpLcls.
Platform agnostic ReturnTypeDesc on a GT_CALL node
--------------------------------------------------
Every GT_CALL node will have a light-weight ReturnTypeDesc that provides a platform independent interface to query the following:
- Respective return types of a multi-reg return value
- Respective Return register numbers in which the value is returned.
ReturnTypeDesc is initialized during importation while creating GenTreeCall node.
GT_CALL node is augmented with the following additional state:
gtOtherRegs - an array of MAX_RET_REG_COUNT-1 reg numbers of multi-reg return. gtRegNum field
will always be the first return reg.
gtSpillFlags - an array to hold GTF_SPILL/GTF_SPILLED state of each reg. This allows us to
spill/reload individual return registers of a multi-reg call node work.
Post Global Morph, IR forms of GT_RETURN(tmp) where tmp is of TYP_STRUCT
------------------------------------------------------------------------
Case 3 is morphed into
```
GT_RETURN (TYP_STRUCT, op1 = GT_MULTI_VAR(TYP_STRUCT, <Fieldlcl1, FieldLcl2, FieldLcl3, FieldLcl4>))
```
Where FieldLcl[1..4] are lcl numbers of independently promoted fields of tmp and
GT_MULTI_VAR is a new node that represents 2-4 independent local vars.
Case 1 remains unchanged
`GT_RETURN(TYP_STRUCT, op1 = tmp)`
Case 2 is handled as follows:
a) Force tmp to memory and morph it as in case 1 above
b) Create 2-4 temp locals matching the type of respective return registers of GT_RETURN and
use them to extract individual fields from tmp and morph it as in case 3 above.
tmpLcl1 = GenTree Nodes to extract first 8-bytes from tmp
tmpLcl2 = GenTree Nodes to extract next 8-bytes from tmp and so on
```
GT_RETURN(TYP_STRUCT, op1 = GT_STORE_MULTI_VAR(TYP_STRUCT, <tmpLcl1, tmpLcl2, tmpLcl3, tmpLcl4>, tmp))
```
Post Lowering, IR forms of GT_CALL node returning TYP_LONG value
----------------------------------------------------------------
During Lowering, such call nodes are lowered into tmp=GT_CALL if the return value of call node is not already assigned to a local. Further tmp is decomposed into GT_LONG.
Post IR lowering, GT_CALL will be transformed into
```
GT_STORE_LCL_VAR(TYP_LONG, lcl Num of tmp, op1 = GT_CALL)
```
where tmp is decomposed into GT_LONG(GT_LCL_VAR(tmpHi), GT_LCL_VAR(tmpLo))
and finally GT_STORE_LCL_VAR is transformed into
```
GT_STORE_MULTI_VAR(TYP_LONG, <tmpHi, tmpLo>, op1=GT_CALL)
```
where tmpHi and tmpLo are promoted lcl fields of tmp.
Post Lowering, IR forms of GT_RETURN(tmp) where tmp is of TYP_LONG
------------------------------------------------------------------
LclVar tmp will be decomposed into two locals and the resulting IR would be GT_RETURN(GT_LONG)
Lowering Register specification
--------------------------------
DstCount of GT_CALL node returning multi-reg return value will be set to 2 or 3 or 4 depending on the number of return registers and its dstCandidates is set to the fixed mask of return registers.
SrcCount and DstCount of GT_STORE_MULTI_VAR will be set 2 or 3 or 4 depending on the number of locals to which a value is assigned. Note that those locals that do not require a value to be assigned are represented as BAD_VAR_NUM.
SrcCount of GT_RETURN returning a multi-reg value will be set to 2 or 3 or 4 depending on the number of return registers.
LSRA Considerations
-------------------
LSRA needs to add support for multi-reg destination GT_CALL, GT_MULTI_VAR and GT_STORE_MULTI_VAR nodes.
Codegen Considerations
----------------------
genProduceReg()/genConsumeReg() code paths need to support mullti-reg destination GT_CALL, GT_MULTI_VAR and GT_STORE_MULTI_VAR nodes.
GT_RETURN(tmp) where tmp is of TYP_STRUCT
- tmp would either be in memory GT_LCL_VAR or GT_MULTI_VAR of TYP_STRUCT
GT_RETURN(op1) where op1 is of TYP_LONG
- op1 should be always of the form GT_LONG(tmpLclHi, tmpLclLo)
Sub work items
--------------
The following are the sub work items and against each is indicated its current status:
1. (Done) Refactor code to abstract structDesc field of GenTreeCall node
ReturnTypeDesc would abstract away existing structDesc (x64 unix) and implement
an API and replace all uses of structDesc of call node with the API. This would be
a pure code refactoring with the addition of ReturnTypeDesc on a GenTreeCall node.
2. (Done) Get rid of structDesc and replace it with ReturnTypeDesc.
Note that on x64 Unix, we still query structDesc from VM and use it to initialize ReturnTypeDesc.
3. (Done) Phase 1 Implementation of multi-reg GT_CALL/GT_RETURN node support for x64 Unix
- Importer changes to force IR to be of the form tmp=call always for multi-reg call nodes
- Importer changes to force IR to be of the form GT_RETURN(tmp) always for multi-reg return
- tmp will always be an in memory lcl var.
- Till First class struct support for GT_OBJ/GT_STORE_OBJ comes on-line IR will be of the form
`GT_STORE_LCL_VAR(tmpLcl, op1 = GT_CALL)`
where tmpLcl will always be an in memory lcl var of TYP_STRUCT
- Lowering/LSRA/Codegen support to allocate multiple regs to GT_CALL nodes.
- GT_CALL nodes will be governed by a single spill flag i.e. all return registers are spilled together.
- GT_RETURN(tmp) - lowering will mark op1=tmp as contained and generate code as existing code does.
4. Phase 2 implementation of multi-reg GT_CALL/GT_RETURN node support for x64 unix
- Add new gentree nodes GT_MULTI_VAR and GT_STORE_MULTI_VAR and plumb through rest of JIT phases.
- Global morph code changes to support Case 3 (i.e P-DEP promoted structs)
- Lowering/LSRA/Codegen changes to support GT_MULTI_VAR and GT_STORE_MULTI_VAR
5. When First class structs support comes on-line, leverage GT_OBJ/GT_STORE_OBJ to store multi-reg
return value of a GT_CALL node to memory cleaning up the code in GT_STORE_LCL_VAR.
6. (Done) HFA and multi-reg struct return support for Arm64
7. (Done) x86 long return support
8. (Optimization) Phase 3 implementation of multi-reg GT_CALL/GT_RETURN node support for x64 unix
- Global morph code changes to support some of the important Case 2 efficiently
9. HFA struct and long return support for Arm32 RyuJIT - we should be able to leverage x86 long return and Arm64 HFA struct return work here.
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./.github/ISSUE_TEMPLATE/03_performance_issue.md | ---
name: Performance issue
about: Report a performance problem or regression
title: ''
labels: 'tenet-performance'
assignees: ''
---
<!--This is just a template - feel free to delete any and all of it and replace as appropriate.-->
### Description
<!--
* Please share a clear and concise description of the performance problem.
* Include minimal steps to reproduce the problem if possible. E.g.: the smallest possible code snippet; or a small repo to clone, with steps to run it.
-->
### Configuration
<!--
(If you are posting Benchmark.NET results, this info will be included.)
* Which version of .NET is the code running on?
* What OS version, and what distro if applicable?
* What is the architecture (x64, x86, ARM, ARM64)?
* If relevant, what are the specs of the machine?
-->
### Regression?
<!--
* Is this a regression from a previous build or release of .NET Core, or from .NET Framework? If you can try a previous release or build to find out, that can help us narrow down the problem. If you don't know, that's OK.
-->
### Data
<!--
* Please include any benchmark results, images of graphs, timings or measurements, or callstacks that are relevant.
* If possible please include text as text rather than images (so it shows up in searches).
* If applicable please include before and after measurements.
* There is helpful information about measuring code in this repo [here](https://github.com/dotnet/performance/blob/master/docs/benchmarking-workflow-dotnet-runtime.md).
-->
### Analysis
<!--
* If you have an idea where the problem might lie, let us know that here.
* Please include any pointers to code, relevant changes, or related issues you know of.
* If you don't know, you can delete this section.
-->
| ---
name: Performance issue
about: Report a performance problem or regression
title: ''
labels: 'tenet-performance'
assignees: ''
---
<!--This is just a template - feel free to delete any and all of it and replace as appropriate.-->
### Description
<!--
* Please share a clear and concise description of the performance problem.
* Include minimal steps to reproduce the problem if possible. E.g.: the smallest possible code snippet; or a small repo to clone, with steps to run it.
-->
### Configuration
<!--
(If you are posting Benchmark.NET results, this info will be included.)
* Which version of .NET is the code running on?
* What OS version, and what distro if applicable?
* What is the architecture (x64, x86, ARM, ARM64)?
* If relevant, what are the specs of the machine?
-->
### Regression?
<!--
* Is this a regression from a previous build or release of .NET Core, or from .NET Framework? If you can try a previous release or build to find out, that can help us narrow down the problem. If you don't know, that's OK.
-->
### Data
<!--
* Please include any benchmark results, images of graphs, timings or measurements, or callstacks that are relevant.
* If possible please include text as text rather than images (so it shows up in searches).
* If applicable please include before and after measurements.
* There is helpful information about measuring code in this repo [here](https://github.com/dotnet/performance/blob/master/docs/benchmarking-workflow-dotnet-runtime.md).
-->
### Analysis
<!--
* If you have an idea where the problem might lie, let us know that here.
* Please include any pointers to code, relevant changes, or related issues you know of.
* If you don't know, you can delete this section.
-->
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./docs/workflow/building/coreclr/README.md | # Building
To build just CoreCLR, use the `-subset` flag to the `build.sh` (or `build.cmd`) script at the repo root:
For Linux:
```
./build.sh -subset clr
```
For Windows:
```
build.cmd -subset clr
```
Specifying `-subset` explicitly is not necessary if it is the first argument: `./build -subset clr` and `./build clr` are equivalent.
By default, build generates a 'debug' build type, that includes asserts and is easier for some people to debug. If you want to make performance measurements, or just want tests to execute more quickly, you can also build the 'release' version (which does not have these checks) by adding the flag `-configuration release` (or `-c release`), for example:
```
./build.sh -subset clr -configuration release
```
CoreCLR also supports a 'checked' build type which has asserts enabled like 'debug', but is built with the native compiler optimizer enabled, so it runs much faster. This is the usual mode used for running tests in the CI system. You can build that using, for example:
```
./build.sh -subset clr -configuration checked
```
If you want to use Ninja to drive the native build instead of Make on non-Windows platforms, you can pass the `-ninja` flag to the build script as follows:
```
./build.cmd -subset clr -ninja
```
If you want to use Visual Studio's MSBuild to drive the native build on Windows, you can pass the `-msbuild` flag to the build script similarly to the `-ninja` flag.
We recommend using Ninja for building the project on Windows since it more efficiently uses the build machine's resources for the native runtime build in comparison to Visual Studio's MSBuild.
To pass extra compiler/linker flags to the coreclr build, set the environment variables `EXTRA_CFLAGS`, `EXTRA_CXXFLAGS` and `EXTRA_LDFLAGS` as needed. Don't set `CFLAGS`/`CXXFLAGS`/`LDFLAGS` directly as that might lead to configure-time tests failing.
This will produce outputs as follows:
- Product binaries will be dropped in `artifacts\bin\coreclr\<OS>.<arch>.<flavor>` folder.
- A NuGet package, Microsoft.Dotnet.CoreCLR, will be created under `artifacts\bin\coreclr\<OS>.<arch>.<flavor>\.nuget` folder.
- Test binaries will be dropped under `artifacts\tests\coreclr\<OS>.<arch>.<flavor>` folder. However, the root build script will not build the tests.
The build places logs in `artifacts\log` and these are useful when the build fails.
The build places all of its intermediate output in the `artifacts\obj\coreclr` directory, so if you remove that directory you can force a
full rebuild.
To build CoreCLR, the root build script invokes the `src\coreclr\build.cmd` (or build.sh) script. To build the CoreCLR tests, you must use this script.
Use `build -?` to learn about the options to this script.
See [Running Tests](../../testing/coreclr/testing.md) for instructions on running the tests.
See also [Build CoreCLR on Linux](linux-instructions.md), [Build CoreCLR on OS X](osx-instructions.md), [Build CoreCLR on FreeBSD](freebsd-instructions.md),
[Cross Compilation for ARM on Windows](cross-building.md), [Cross Compilation for Android on Linux](android.md).
| # Building
To build just CoreCLR, use the `-subset` flag to the `build.sh` (or `build.cmd`) script at the repo root:
For Linux:
```
./build.sh -subset clr
```
For Windows:
```
build.cmd -subset clr
```
Specifying `-subset` explicitly is not necessary if it is the first argument: `./build -subset clr` and `./build clr` are equivalent.
By default, build generates a 'debug' build type, that includes asserts and is easier for some people to debug. If you want to make performance measurements, or just want tests to execute more quickly, you can also build the 'release' version (which does not have these checks) by adding the flag `-configuration release` (or `-c release`), for example:
```
./build.sh -subset clr -configuration release
```
CoreCLR also supports a 'checked' build type which has asserts enabled like 'debug', but is built with the native compiler optimizer enabled, so it runs much faster. This is the usual mode used for running tests in the CI system. You can build that using, for example:
```
./build.sh -subset clr -configuration checked
```
If you want to use Ninja to drive the native build instead of Make on non-Windows platforms, you can pass the `-ninja` flag to the build script as follows:
```
./build.cmd -subset clr -ninja
```
If you want to use Visual Studio's MSBuild to drive the native build on Windows, you can pass the `-msbuild` flag to the build script similarly to the `-ninja` flag.
We recommend using Ninja for building the project on Windows since it more efficiently uses the build machine's resources for the native runtime build in comparison to Visual Studio's MSBuild.
To pass extra compiler/linker flags to the coreclr build, set the environment variables `EXTRA_CFLAGS`, `EXTRA_CXXFLAGS` and `EXTRA_LDFLAGS` as needed. Don't set `CFLAGS`/`CXXFLAGS`/`LDFLAGS` directly as that might lead to configure-time tests failing.
This will produce outputs as follows:
- Product binaries will be dropped in `artifacts\bin\coreclr\<OS>.<arch>.<flavor>` folder.
- A NuGet package, Microsoft.Dotnet.CoreCLR, will be created under `artifacts\bin\coreclr\<OS>.<arch>.<flavor>\.nuget` folder.
- Test binaries will be dropped under `artifacts\tests\coreclr\<OS>.<arch>.<flavor>` folder. However, the root build script will not build the tests.
The build places logs in `artifacts\log` and these are useful when the build fails.
The build places all of its intermediate output in the `artifacts\obj\coreclr` directory, so if you remove that directory you can force a
full rebuild.
To build CoreCLR, the root build script invokes the `src\coreclr\build.cmd` (or build.sh) script. To build the CoreCLR tests, you must use this script.
Use `build -?` to learn about the options to this script.
See [Running Tests](../../testing/coreclr/testing.md) for instructions on running the tests.
See also [Build CoreCLR on Linux](linux-instructions.md), [Build CoreCLR on OS X](osx-instructions.md), [Build CoreCLR on FreeBSD](freebsd-instructions.md),
[Cross Compilation for ARM on Windows](cross-building.md), [Cross Compilation for Android on Linux](android.md).
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/ppc32/Lglobal.c | #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gglobal.c"
#endif
| #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gglobal.c"
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/coredump/_UCD_get_mapinfo_linux.c | /**
* Extract filemap info from a coredump (Linux and similar)
*/
/*
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "_UCD_internal.h"
/**
* The format of the NT_FILE note is not well documented, but it goes something
* like this.
*
* The note has a header containing the @i count of the number of file maps, plus a
* value of the size of the offset field in each map. Since we don;t care about
* the offset field in a core file, there is no further information available on
* exactly what the means.
*
* Following the header are @count mapinfo structures. The mapinfo structure consists of
* a start address, and end address, and some wacky offset thing. The start and
* end address are the virtual addresses of a LOAD segment that was mapped from
* the named file.
*
* Following the array of mapinfo structures is a block of null-terminated C strings
* containing the mapped file names. They are ordered correspondingly to each
* entry in the map structure array.
*/
typedef struct {
unsigned long count;
unsigned long pagesz;
} linux_mapinfo_hdr_t;
typedef struct {
unsigned long start;
unsigned long end;
unsigned long offset;
} linux_mapinfo_t;
/**
* Map a file note to program headers
*
* If a NT_FILE note is recognized, parse it and add the resulting backing files
* to the program header list.
*
* Any file names that end in the string "(deleted)" are ignored.
*/
static int
_handle_file_note(uint32_t n_namesz, uint32_t n_descsz, uint32_t n_type, char *name, uint8_t *desc, void *arg)
{
struct UCD_info *ui = (struct UCD_info *)arg;
#ifdef NT_FILE
if (n_type == NT_FILE)
{
Debug(0, "found a PT_FILE note\n");
static const char * deleted = "(deleted)";
size_t deleted_len = strlen(deleted);
static const size_t mapinfo_offset = sizeof(linux_mapinfo_hdr_t);
linux_mapinfo_hdr_t *mapinfo = (linux_mapinfo_hdr_t *)desc;
linux_mapinfo_t *maps = (linux_mapinfo_t *)(desc + mapinfo_offset);
char *strings = (char *)(desc + mapinfo_offset + sizeof(linux_mapinfo_t)*mapinfo->count);
for (unsigned long i = 0; i < mapinfo->count; ++i)
{
size_t len = strlen(strings);
for (unsigned p = 0; p < ui->phdrs_count; ++p)
{
if (ui->phdrs[p].p_type == PT_LOAD
&& maps[i].start >= ui->phdrs[p].p_vaddr
&& maps[i].end <= ui->phdrs[p].p_vaddr + ui->phdrs[p].p_filesz)
{
if (len > deleted_len && memcmp(strings + len - deleted_len, deleted, deleted_len))
{
_UCD_add_backing_file_at_segment(ui, p, strings);
}
break;
}
}
strings += (len + 1);
}
}
#endif
return UNW_ESUCCESS;
}
/**
* Get filemap info from core file (Linux and similar)
*
* If there is a mapinfo not in the core file, map its contents to the phdrs.
*
* Since there may or may not be any mapinfo notes it's OK for this function to
* fail.
*/
int
_UCD_get_mapinfo(struct UCD_info *ui, coredump_phdr_t *phdrs, unsigned phdr_size)
{
int ret = UNW_ESUCCESS; /* it's OK if there are no file mappings */
for (unsigned i = 0; i < phdr_size; ++i)
{
if (phdrs[i].p_type == PT_NOTE)
{
uint8_t *segment;
size_t segment_size;
ret = _UCD_elf_read_segment(ui, &phdrs[i], &segment, &segment_size);
if (ret == UNW_ESUCCESS)
{
_UCD_elf_visit_notes(segment, segment_size, _handle_file_note, ui);
free(segment);
}
}
}
return ret;
}
| /**
* Extract filemap info from a coredump (Linux and similar)
*/
/*
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "_UCD_internal.h"
/**
* The format of the NT_FILE note is not well documented, but it goes something
* like this.
*
* The note has a header containing the @i count of the number of file maps, plus a
* value of the size of the offset field in each map. Since we don;t care about
* the offset field in a core file, there is no further information available on
* exactly what the means.
*
* Following the header are @count mapinfo structures. The mapinfo structure consists of
* a start address, and end address, and some wacky offset thing. The start and
* end address are the virtual addresses of a LOAD segment that was mapped from
* the named file.
*
* Following the array of mapinfo structures is a block of null-terminated C strings
* containing the mapped file names. They are ordered correspondingly to each
* entry in the map structure array.
*/
typedef struct {
unsigned long count;
unsigned long pagesz;
} linux_mapinfo_hdr_t;
typedef struct {
unsigned long start;
unsigned long end;
unsigned long offset;
} linux_mapinfo_t;
/**
* Map a file note to program headers
*
* If a NT_FILE note is recognized, parse it and add the resulting backing files
* to the program header list.
*
* Any file names that end in the string "(deleted)" are ignored.
*/
static int
_handle_file_note(uint32_t n_namesz, uint32_t n_descsz, uint32_t n_type, char *name, uint8_t *desc, void *arg)
{
struct UCD_info *ui = (struct UCD_info *)arg;
#ifdef NT_FILE
if (n_type == NT_FILE)
{
Debug(0, "found a PT_FILE note\n");
static const char * deleted = "(deleted)";
size_t deleted_len = strlen(deleted);
static const size_t mapinfo_offset = sizeof(linux_mapinfo_hdr_t);
linux_mapinfo_hdr_t *mapinfo = (linux_mapinfo_hdr_t *)desc;
linux_mapinfo_t *maps = (linux_mapinfo_t *)(desc + mapinfo_offset);
char *strings = (char *)(desc + mapinfo_offset + sizeof(linux_mapinfo_t)*mapinfo->count);
for (unsigned long i = 0; i < mapinfo->count; ++i)
{
size_t len = strlen(strings);
for (unsigned p = 0; p < ui->phdrs_count; ++p)
{
if (ui->phdrs[p].p_type == PT_LOAD
&& maps[i].start >= ui->phdrs[p].p_vaddr
&& maps[i].end <= ui->phdrs[p].p_vaddr + ui->phdrs[p].p_filesz)
{
if (len > deleted_len && memcmp(strings + len - deleted_len, deleted, deleted_len))
{
_UCD_add_backing_file_at_segment(ui, p, strings);
}
break;
}
}
strings += (len + 1);
}
}
#endif
return UNW_ESUCCESS;
}
/**
* Get filemap info from core file (Linux and similar)
*
* If there is a mapinfo not in the core file, map its contents to the phdrs.
*
* Since there may or may not be any mapinfo notes it's OK for this function to
* fail.
*/
int
_UCD_get_mapinfo(struct UCD_info *ui, coredump_phdr_t *phdrs, unsigned phdr_size)
{
int ret = UNW_ESUCCESS; /* it's OK if there are no file mappings */
for (unsigned i = 0; i < phdr_size; ++i)
{
if (phdrs[i].p_type == PT_NOTE)
{
uint8_t *segment;
size_t segment_size;
ret = _UCD_elf_read_segment(ui, &phdrs[i], &segment, &segment_size);
if (ret == UNW_ESUCCESS)
{
_UCD_elf_visit_notes(segment, segment_size, _handle_file_note, ui);
free(segment);
}
}
}
return ret;
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/loongarch64/Lis_signal_frame.c | #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gis_signal_frame.c"
#endif
| #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gis_signal_frame.c"
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/mips/Greg_states_iterate.c | /* libunwind - a platform-independent unwind library
Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P.
Contributed by David Mosberger-Tang <[email protected]>
Modified for x86_64 by Max Asbock <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
int
unw_reg_states_iterate (unw_cursor_t *cursor,
unw_reg_states_callback cb, void *token)
{
struct cursor *c = (struct cursor *) cursor;
return dwarf_reg_states_iterate (&c->dwarf, cb, token);
}
| /* libunwind - a platform-independent unwind library
Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P.
Contributed by David Mosberger-Tang <[email protected]>
Modified for x86_64 by Max Asbock <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
int
unw_reg_states_iterate (unw_cursor_t *cursor,
unw_reg_states_callback cb, void *token)
{
struct cursor *c = (struct cursor *) cursor;
return dwarf_reg_states_iterate (&c->dwarf, cb, token);
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/ia64/Lscript.c | #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gscript.c"
#endif
| #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gscript.c"
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/tests/metadata-verifier/cli-blob-tests.md | method-def-sig {
assembly assembly-with-methods.exe
#bad first byte
#method zero is a default ctor
#0 -> default 5 -> vararg
#signature size, zero is invalid
invalid offset blob.i (table-row (6 0) + 10) set-byte 0
#cconv
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x26
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x27
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x28
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x29
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2A
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2B
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2C
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2D
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2E
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2F
#upper nimble flags 0x80 is invalid
invalid offset blob.i (table-row (6 0) + 10) + 1 set-bit 7
#sig is too small to decode param count
invalid offset blob.i (table-row (6 0) + 10) set-byte 1
#sig is too small to decode return type
invalid offset blob.i (table-row (6 0) + 10) set-byte 2
#zero generic args
#method 1 is generic
#bytes: size cconv gen_param_count
invalid offset blob.i (table-row (6 1) + 10) + 2 set-byte 0
#set ret type to an invalid value
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x17
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x1A
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x21 #mono doesn't support internal type
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x40 #modifier
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x41 #sentinel
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x45 #pinner
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x50 #type
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x51 #boxed
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x52 #reserved
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x53 #field
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x54 #property
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x55 #enum
#bad args
#method 12 has sig void (int,int,int)
#bytes: size cconv param_count void int32 int32 int32
valid offset blob.i (table-row (6 12) + 10) + 4 set-byte 0x05
valid offset blob.i (table-row (6 12) + 10) + 5 set-byte 0x06
valid offset blob.i (table-row (6 12) + 10) + 6 set-byte 0x07
#void
invalid offset blob.i (table-row (6 12) + 10) + 5 set-byte 0x01
#byref without anything after
invalid offset blob.i (table-row (6 12) + 10) + 4 set-byte 0x10
invalid offset blob.i (table-row (6 12) + 10) + 5 set-byte 0x10
invalid offset blob.i (table-row (6 12) + 10) + 6 set-byte 0x10
}
#Test for stuff in the ret that can't be expressed with C#
method-def-ret-misc {
assembly assembly-with-custommod.exe
#method 0 has a modreq
#bytes: size cconv param_count mod_req compressed_token
invalid offset blob.i (table-row (6 0) + 10) + 4 set-byte 0x7C
invalid offset blob.i (table-row (6 0) + 10) + 4 set-byte 0x07
#switch modreq to modopt
valid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x20
#2 times byref
#method 4 returns byref
#bytes: size cconv param_count byref int32
invalid offset blob.i (table-row (6 4) + 10) + 4 set-byte 0x10
#byref of typedref
invalid offset blob.i (table-row (6 4) + 10) + 4 set-byte 0x16
}
method-ref-sig {
assembly assembly-with-signatures.exe
#member ref 0 is has a vararg sig
#member ref 1 don't use vararg
#2 sentinels
#bytes: size cconv pcount void str obj obj obj obj ... i32 i32 i32
invalid offset blob.i (table-row (0xA 0) + 4) + 10 set-byte 0x41
invalid offset blob.i (table-row (0xA 0) + 4) + 11 set-byte 0x41
#sentinel but not vararg
invalid offset blob.i (table-row (0xA 0) + 4) + 1 set-byte 0
}
stand-alone-method-sig {
assembly assembly-with-calli.exe
#standalone sig 0x2 points to a calli sig
valid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x0
valid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x1
valid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x2
valid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x3
valid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x4
valid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x5
#sig is int32 (int32)
#size cconv pcount(1) int32 int32 ->
#size cconv gcount(1) pcount(0) int32
#cannot have generics
invalid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x10,
offset blob.i (table-row (0x11 0)) + 2 set-byte 1,
offset blob.i (table-row (0x11 0)) + 3 set-byte 0
}
field-sig {
assembly assembly-with-complex-type.exe
#first byte must be 6
invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x0
invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x5
invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x7
invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x16
invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x26
}
property-sig {
assembly assembly-with-properties.exe
#bad size
invalid offset blob.i (table-row (0x17 0) + 4) set-byte 0x0
invalid offset blob.i (table-row (0x17 0) + 4) set-byte 0x1
#cconv must be 0x08 or 0x28
valid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x08
valid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x28
invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x09
invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x29
invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x48
invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x18
invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x07
invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x00
}
locals-sig {
assembly assembly-with-locals.exe
#bad local sig
#row 0 has tons of locals
#row 1 is int32&, int32
#row 2 is typedref
#typedref with byref
#row 1 is: cconv pcount(2) byref int32 int32
#row 1 goes to: cconv pcount(2) byref typedbyref int32
invalid offset blob.i (table-row (0x11 1)) + 4 set-byte 0x16
#byref pinned int32
#row 1 is: cconv pcount(2) byref int32 int32
#row 1 goes to: cconv pcount(1) byref pinned int32
invalid offset blob.i (table-row (0x11 1)) + 2 set-byte 0x01,
offset blob.i (table-row (0x11 1)) + 4 set-byte 0x45
#pinned pinned int32
#row 1 is: cconv pcount(2) byref int32 int32
#row 1 goes to: cconv pcount(1) pinned pinned int32
#LAMEIMPL MS doesn't care about this
valid offset blob.i (table-row (0x11 1)) + 2 set-byte 0x01,
offset blob.i (table-row (0x11 1)) + 3 set-byte 0x45,
offset blob.i (table-row (0x11 1)) + 4 set-byte 0x45
}
type-enc {
assembly assembly-with-types.exe
#valid
#change type from int to string
valid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x0E
#field 10 is cconv PTR int32
#make it: cconv PTR modreq
invalid offset blob.i (table-row (0x04 11) + 4) + 3 set-byte 0x1f
#pointer to pointer (not enought room to parse pointed to type)
#make it: cconv PTR PTR
invalid offset blob.i (table-row (0x04 11) + 4) + 3 set-byte 0x0f
#value type / class
#make it not have room for the token
invalid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x11
invalid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x12
#var / mvar
#make it not have room for the token
invalid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x13
invalid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x1e
#general array
#field 3 is a int32[,,]: cconv ARRAY int32 rank(3) nsizes(0) nlowb(0)
#make the array type invalid (byref/typedref/void/plain wrong)
invalid offset blob.i (table-row (0x04 3) + 4) + 3 set-byte 0x00
invalid offset blob.i (table-row (0x04 3) + 4) + 3 set-byte 0x01
invalid offset blob.i (table-row (0x04 3) + 4) + 3 set-byte 0x10
#LAMEIMPL MS accepts arrays of typedbyref, which is illegal and unsafe
invalid offset blob.i (table-row (0x04 3) + 4) + 3 set-byte 0x16
#LAMEIMPL MS verifier doesn't catch this one (runtime does)
#rank 0
invalid offset blob.i (table-row (0x04 3) + 4) + 4 set-byte 0x00
#large nsizes
invalid offset blob.i (table-row (0x04 3) + 4) + 5 set-byte 0x1F
#large nlowb
invalid offset blob.i (table-row (0x04 3) + 4) + 6 set-byte 0x1F
#generic inst
#field 20 is Test<int32>; 21 is class [mscorlib]System.IComparable`1<object>; 22 is valuetype Test2<!0>
#format is cconc GINST KIND token arg_count type*
#make bad kind
invalid offset blob.i (table-row (0x04 20) + 4) + 3 set-byte 0x05
#bad token
invalid offset blob.i (table-row (0x04 20) + 4) + 4 set-byte 0x3F
#zero arg_count
invalid offset blob.i (table-row (0x04 20) + 4) + 5 set-byte 0x0
#bad arg_count
invalid offset blob.i (table-row (0x04 20) + 4) + 5 set-byte 0x10
#fnptr
#field 10 is a fnptr
#format is: cconv FNPTR cconv pcount ret param* sentinel? param*
#LAMESPEC, it lacks the fact that fnptr allows for unmanaged call conv
#bad callconv
invalid offset blob.i (table-row (0x04 10) + 4) + 3 set-byte 0x88
#szarray
#field 17 is an array with modreq on target
#format is: cconv SZARRAY cmod* type
#array type is void
invalid offset blob.i (table-row (0x04 17) + 4) + 3 set-byte 0x01
}
typespec-sig {
assembly assembly-with-typespec.exe
#LAMESPEC
#ecma spec doesn't allow simple types such as uint32. But MS does and there
#is no harm into supporting it.
#row zero is "void*" encoded as PTR VOID
valid offset blob.i (table-row (0x1B 0)) + 1 set-byte 0x09
#type zero is invalid
invalid offset blob.i (table-row (0x1B 0)) + 1 set-byte 0x0
#LAMESPEC part II, MS allows for cmods on a typespec as well
#modreq int32 is invalid
#typespec 2 is "modreq int32*" encoded as: PTR CMOD_REQD token INT32
#change int to CMOD_REQD token INT32
valid offset blob.i (table-row (0x1B 2)) + 1 set-byte 0x1f, #CMOD_REQD
offset blob.i (table-row (0x1B 2)) + 2 set-byte read.byte (blob.i (table-row (0x1B 2)) + 3), #token
offset blob.i (table-row (0x1B 2)) + 3 set-byte 0x08 #int8
#typedref is fine too.
valid offset blob.i (table-row (0x1B 2)) + 0 set-byte 0x16
}
methodspec-sig {
assembly assembly-with-generics.exe
#LAMESPEC spec is completelly wrong on this one. method spec holds simply a generic instantation
#no type on it
#first byte is the genericinst callconv 0xA
#row zero is Gen<!1> or: GENRICINST gcount(1) type*
invalid offset blob.i (table-row (0x2B 0) + 2) + 1 set-byte 0x08
#zero arg count
invalid offset blob.i (table-row (0x2B 0) + 2) + 2 set-byte 0x0
#bad argument
invalid offset blob.i (table-row (0x2B 0) + 2) + 3 set-byte 0x01
}
method-header {
assembly assembly-with-methods.exe
#invalid header kind
#method zero is an empty .ctor (), so it takes 7 bytes (call super + ret) so we do 7 << 2 | header kind
invalid offset translate.rva.ind (table-row (0x06 0)) + 0 set-byte 0x1C
invalid offset translate.rva.ind (table-row (0x06 0)) + 0 set-byte 0x1D
#method 1 has fat header
#size must be 3
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x0013
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x1013
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x2013
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x5013
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0xF013
#maxstack can be anything between 0-2^16-1, it's up to the IL verifier to use it.
#make codesize huge enought to overflow
invalid offset translate.rva.ind (table-row (0x06 1)) + 4 set-uint 0x1FFFFFF0
#bad local vars token
#out of bounds
invalid offset translate.rva.ind (table-row (0x06 1)) + 8 set-uint 0x1100FFFF
#wrong table
invalid offset translate.rva.ind (table-row (0x06 1)) + 8 set-uint 0x1B000001
#bad fat header flags
#only 0x08 and 0x10 allowed
#regular value is
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3033 #or 0x20
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3053
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3093
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3113
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3213
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3413
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3813
#methods 2, 4 and 6 have EH tables. 2 and 4 are regular, 6 is fat 4 has 2 EH entries
#LAMEIMPL (our) well, 2 and 4 could be thin, but mono's SRE isn't keen to use small form
#thin format must have size that is n*12+4 fat n*24+4
#set invalid flags
valid offset translate.rva.ind (table-row (0x06 2)) + 4 set-ushort 0x1C #set the code size to be sure
invalid offset translate.rva.ind (table-row (0x06 2)) + 40 or-byte 0x02
invalid offset translate.rva.ind (table-row (0x06 2)) + 40 or-byte 0x04
invalid offset translate.rva.ind (table-row (0x06 2)) + 40 or-byte 0x08
invalid offset translate.rva.ind (table-row (0x06 2)) + 40 or-byte 0x10
invalid offset translate.rva.ind (table-row (0x06 2)) + 40 or-byte 0x20
#set invalid size
#not multiple of n*24+4
invalid offset translate.rva.ind (table-row (0x06 2)) + 41 set-byte 0x10
invalid offset translate.rva.ind (table-row (0x06 2)) + 41 set-byte 0x1F
#out of bound
invalid offset translate.rva.ind (table-row (0x06 2)) + 40 set-uint 0x5FFFFF41
#extra section is at + 40, so EH table at + 44, class token at + 64
#bad table
invalid offset translate.rva.ind (table-row (0x06 2)) + 64 set-uint 0x11000001
#bad token idx
invalid offset translate.rva.ind (table-row (0x06 2)) + 64 set-uint 0x010FF001
invalid offset translate.rva.ind (table-row (0x06 2)) + 64 set-uint 0x020FF001
invalid offset translate.rva.ind (table-row (0x06 2)) + 64 set-uint 0x1B0FF001
}
| method-def-sig {
assembly assembly-with-methods.exe
#bad first byte
#method zero is a default ctor
#0 -> default 5 -> vararg
#signature size, zero is invalid
invalid offset blob.i (table-row (6 0) + 10) set-byte 0
#cconv
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x26
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x27
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x28
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x29
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2A
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2B
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2C
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2D
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2E
invalid offset blob.i (table-row (6 0) + 10) + 1 set-byte 0x2F
#upper nimble flags 0x80 is invalid
invalid offset blob.i (table-row (6 0) + 10) + 1 set-bit 7
#sig is too small to decode param count
invalid offset blob.i (table-row (6 0) + 10) set-byte 1
#sig is too small to decode return type
invalid offset blob.i (table-row (6 0) + 10) set-byte 2
#zero generic args
#method 1 is generic
#bytes: size cconv gen_param_count
invalid offset blob.i (table-row (6 1) + 10) + 2 set-byte 0
#set ret type to an invalid value
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x17
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x1A
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x21 #mono doesn't support internal type
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x40 #modifier
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x41 #sentinel
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x45 #pinner
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x50 #type
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x51 #boxed
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x52 #reserved
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x53 #field
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x54 #property
invalid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x55 #enum
#bad args
#method 12 has sig void (int,int,int)
#bytes: size cconv param_count void int32 int32 int32
valid offset blob.i (table-row (6 12) + 10) + 4 set-byte 0x05
valid offset blob.i (table-row (6 12) + 10) + 5 set-byte 0x06
valid offset blob.i (table-row (6 12) + 10) + 6 set-byte 0x07
#void
invalid offset blob.i (table-row (6 12) + 10) + 5 set-byte 0x01
#byref without anything after
invalid offset blob.i (table-row (6 12) + 10) + 4 set-byte 0x10
invalid offset blob.i (table-row (6 12) + 10) + 5 set-byte 0x10
invalid offset blob.i (table-row (6 12) + 10) + 6 set-byte 0x10
}
#Test for stuff in the ret that can't be expressed with C#
method-def-ret-misc {
assembly assembly-with-custommod.exe
#method 0 has a modreq
#bytes: size cconv param_count mod_req compressed_token
invalid offset blob.i (table-row (6 0) + 10) + 4 set-byte 0x7C
invalid offset blob.i (table-row (6 0) + 10) + 4 set-byte 0x07
#switch modreq to modopt
valid offset blob.i (table-row (6 0) + 10) + 3 set-byte 0x20
#2 times byref
#method 4 returns byref
#bytes: size cconv param_count byref int32
invalid offset blob.i (table-row (6 4) + 10) + 4 set-byte 0x10
#byref of typedref
invalid offset blob.i (table-row (6 4) + 10) + 4 set-byte 0x16
}
method-ref-sig {
assembly assembly-with-signatures.exe
#member ref 0 is has a vararg sig
#member ref 1 don't use vararg
#2 sentinels
#bytes: size cconv pcount void str obj obj obj obj ... i32 i32 i32
invalid offset blob.i (table-row (0xA 0) + 4) + 10 set-byte 0x41
invalid offset blob.i (table-row (0xA 0) + 4) + 11 set-byte 0x41
#sentinel but not vararg
invalid offset blob.i (table-row (0xA 0) + 4) + 1 set-byte 0
}
stand-alone-method-sig {
assembly assembly-with-calli.exe
#standalone sig 0x2 points to a calli sig
valid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x0
valid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x1
valid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x2
valid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x3
valid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x4
valid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x5
#sig is int32 (int32)
#size cconv pcount(1) int32 int32 ->
#size cconv gcount(1) pcount(0) int32
#cannot have generics
invalid offset blob.i (table-row (0x11 0)) + 1 set-byte 0x10,
offset blob.i (table-row (0x11 0)) + 2 set-byte 1,
offset blob.i (table-row (0x11 0)) + 3 set-byte 0
}
field-sig {
assembly assembly-with-complex-type.exe
#first byte must be 6
invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x0
invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x5
invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x7
invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x16
invalid offset blob.i (table-row (4 0) + 4) + 1 set-byte 0x26
}
property-sig {
assembly assembly-with-properties.exe
#bad size
invalid offset blob.i (table-row (0x17 0) + 4) set-byte 0x0
invalid offset blob.i (table-row (0x17 0) + 4) set-byte 0x1
#cconv must be 0x08 or 0x28
valid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x08
valid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x28
invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x09
invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x29
invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x48
invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x18
invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x07
invalid offset blob.i (table-row (0x17 0) + 4) + 1 set-byte 0x00
}
locals-sig {
assembly assembly-with-locals.exe
#bad local sig
#row 0 has tons of locals
#row 1 is int32&, int32
#row 2 is typedref
#typedref with byref
#row 1 is: cconv pcount(2) byref int32 int32
#row 1 goes to: cconv pcount(2) byref typedbyref int32
invalid offset blob.i (table-row (0x11 1)) + 4 set-byte 0x16
#byref pinned int32
#row 1 is: cconv pcount(2) byref int32 int32
#row 1 goes to: cconv pcount(1) byref pinned int32
invalid offset blob.i (table-row (0x11 1)) + 2 set-byte 0x01,
offset blob.i (table-row (0x11 1)) + 4 set-byte 0x45
#pinned pinned int32
#row 1 is: cconv pcount(2) byref int32 int32
#row 1 goes to: cconv pcount(1) pinned pinned int32
#LAMEIMPL MS doesn't care about this
valid offset blob.i (table-row (0x11 1)) + 2 set-byte 0x01,
offset blob.i (table-row (0x11 1)) + 3 set-byte 0x45,
offset blob.i (table-row (0x11 1)) + 4 set-byte 0x45
}
type-enc {
assembly assembly-with-types.exe
#valid
#change type from int to string
valid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x0E
#field 10 is cconv PTR int32
#make it: cconv PTR modreq
invalid offset blob.i (table-row (0x04 11) + 4) + 3 set-byte 0x1f
#pointer to pointer (not enought room to parse pointed to type)
#make it: cconv PTR PTR
invalid offset blob.i (table-row (0x04 11) + 4) + 3 set-byte 0x0f
#value type / class
#make it not have room for the token
invalid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x11
invalid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x12
#var / mvar
#make it not have room for the token
invalid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x13
invalid offset blob.i (table-row (0x04 0) + 4) + 2 set-byte 0x1e
#general array
#field 3 is a int32[,,]: cconv ARRAY int32 rank(3) nsizes(0) nlowb(0)
#make the array type invalid (byref/typedref/void/plain wrong)
invalid offset blob.i (table-row (0x04 3) + 4) + 3 set-byte 0x00
invalid offset blob.i (table-row (0x04 3) + 4) + 3 set-byte 0x01
invalid offset blob.i (table-row (0x04 3) + 4) + 3 set-byte 0x10
#LAMEIMPL MS accepts arrays of typedbyref, which is illegal and unsafe
invalid offset blob.i (table-row (0x04 3) + 4) + 3 set-byte 0x16
#LAMEIMPL MS verifier doesn't catch this one (runtime does)
#rank 0
invalid offset blob.i (table-row (0x04 3) + 4) + 4 set-byte 0x00
#large nsizes
invalid offset blob.i (table-row (0x04 3) + 4) + 5 set-byte 0x1F
#large nlowb
invalid offset blob.i (table-row (0x04 3) + 4) + 6 set-byte 0x1F
#generic inst
#field 20 is Test<int32>; 21 is class [mscorlib]System.IComparable`1<object>; 22 is valuetype Test2<!0>
#format is cconc GINST KIND token arg_count type*
#make bad kind
invalid offset blob.i (table-row (0x04 20) + 4) + 3 set-byte 0x05
#bad token
invalid offset blob.i (table-row (0x04 20) + 4) + 4 set-byte 0x3F
#zero arg_count
invalid offset blob.i (table-row (0x04 20) + 4) + 5 set-byte 0x0
#bad arg_count
invalid offset blob.i (table-row (0x04 20) + 4) + 5 set-byte 0x10
#fnptr
#field 10 is a fnptr
#format is: cconv FNPTR cconv pcount ret param* sentinel? param*
#LAMESPEC, it lacks the fact that fnptr allows for unmanaged call conv
#bad callconv
invalid offset blob.i (table-row (0x04 10) + 4) + 3 set-byte 0x88
#szarray
#field 17 is an array with modreq on target
#format is: cconv SZARRAY cmod* type
#array type is void
invalid offset blob.i (table-row (0x04 17) + 4) + 3 set-byte 0x01
}
typespec-sig {
assembly assembly-with-typespec.exe
#LAMESPEC
#ecma spec doesn't allow simple types such as uint32. But MS does and there
#is no harm into supporting it.
#row zero is "void*" encoded as PTR VOID
valid offset blob.i (table-row (0x1B 0)) + 1 set-byte 0x09
#type zero is invalid
invalid offset blob.i (table-row (0x1B 0)) + 1 set-byte 0x0
#LAMESPEC part II, MS allows for cmods on a typespec as well
#modreq int32 is invalid
#typespec 2 is "modreq int32*" encoded as: PTR CMOD_REQD token INT32
#change int to CMOD_REQD token INT32
valid offset blob.i (table-row (0x1B 2)) + 1 set-byte 0x1f, #CMOD_REQD
offset blob.i (table-row (0x1B 2)) + 2 set-byte read.byte (blob.i (table-row (0x1B 2)) + 3), #token
offset blob.i (table-row (0x1B 2)) + 3 set-byte 0x08 #int8
#typedref is fine too.
valid offset blob.i (table-row (0x1B 2)) + 0 set-byte 0x16
}
methodspec-sig {
assembly assembly-with-generics.exe
#LAMESPEC spec is completelly wrong on this one. method spec holds simply a generic instantation
#no type on it
#first byte is the genericinst callconv 0xA
#row zero is Gen<!1> or: GENRICINST gcount(1) type*
invalid offset blob.i (table-row (0x2B 0) + 2) + 1 set-byte 0x08
#zero arg count
invalid offset blob.i (table-row (0x2B 0) + 2) + 2 set-byte 0x0
#bad argument
invalid offset blob.i (table-row (0x2B 0) + 2) + 3 set-byte 0x01
}
method-header {
assembly assembly-with-methods.exe
#invalid header kind
#method zero is an empty .ctor (), so it takes 7 bytes (call super + ret) so we do 7 << 2 | header kind
invalid offset translate.rva.ind (table-row (0x06 0)) + 0 set-byte 0x1C
invalid offset translate.rva.ind (table-row (0x06 0)) + 0 set-byte 0x1D
#method 1 has fat header
#size must be 3
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x0013
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x1013
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x2013
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x5013
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0xF013
#maxstack can be anything between 0-2^16-1, it's up to the IL verifier to use it.
#make codesize huge enought to overflow
invalid offset translate.rva.ind (table-row (0x06 1)) + 4 set-uint 0x1FFFFFF0
#bad local vars token
#out of bounds
invalid offset translate.rva.ind (table-row (0x06 1)) + 8 set-uint 0x1100FFFF
#wrong table
invalid offset translate.rva.ind (table-row (0x06 1)) + 8 set-uint 0x1B000001
#bad fat header flags
#only 0x08 and 0x10 allowed
#regular value is
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3033 #or 0x20
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3053
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3093
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3113
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3213
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3413
invalid offset translate.rva.ind (table-row (0x06 1)) + 0 set-ushort 0x3813
#methods 2, 4 and 6 have EH tables. 2 and 4 are regular, 6 is fat 4 has 2 EH entries
#LAMEIMPL (our) well, 2 and 4 could be thin, but mono's SRE isn't keen to use small form
#thin format must have size that is n*12+4 fat n*24+4
#set invalid flags
valid offset translate.rva.ind (table-row (0x06 2)) + 4 set-ushort 0x1C #set the code size to be sure
invalid offset translate.rva.ind (table-row (0x06 2)) + 40 or-byte 0x02
invalid offset translate.rva.ind (table-row (0x06 2)) + 40 or-byte 0x04
invalid offset translate.rva.ind (table-row (0x06 2)) + 40 or-byte 0x08
invalid offset translate.rva.ind (table-row (0x06 2)) + 40 or-byte 0x10
invalid offset translate.rva.ind (table-row (0x06 2)) + 40 or-byte 0x20
#set invalid size
#not multiple of n*24+4
invalid offset translate.rva.ind (table-row (0x06 2)) + 41 set-byte 0x10
invalid offset translate.rva.ind (table-row (0x06 2)) + 41 set-byte 0x1F
#out of bound
invalid offset translate.rva.ind (table-row (0x06 2)) + 40 set-uint 0x5FFFFF41
#extra section is at + 40, so EH table at + 44, class token at + 64
#bad table
invalid offset translate.rva.ind (table-row (0x06 2)) + 64 set-uint 0x11000001
#bad token idx
invalid offset translate.rva.ind (table-row (0x06 2)) + 64 set-uint 0x010FF001
invalid offset translate.rva.ind (table-row (0x06 2)) + 64 set-uint 0x020FF001
invalid offset translate.rva.ind (table-row (0x06 2)) + 64 set-uint 0x1B0FF001
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/unwind/GetDataRelBase.c | /* libunwind - a platform-independent unwind library
Copyright (C) 2003-2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind-internal.h"
unsigned long
_Unwind_GetDataRelBase (struct _Unwind_Context *context)
{
unw_proc_info_t pi;
pi.gp = 0;
unw_get_proc_info (&context->cursor, &pi);
return pi.gp;
}
unsigned long __libunwind_Unwind_GetDataRelBase (struct _Unwind_Context *)
ALIAS (_Unwind_GetDataRelBase);
| /* libunwind - a platform-independent unwind library
Copyright (C) 2003-2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind-internal.h"
unsigned long
_Unwind_GetDataRelBase (struct _Unwind_Context *context)
{
unw_proc_info_t pi;
pi.gp = 0;
unw_get_proc_info (&context->cursor, &pi);
return pi.gp;
}
unsigned long __libunwind_Unwind_GetDataRelBase (struct _Unwind_Context *)
ALIAS (_Unwind_GetDataRelBase);
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/mini/liveness.c | /**
* \file
* liveness analysis
*
* Author:
* Dietmar Maurer ([email protected])
*
* (C) 2002 Ximian, Inc.
* Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#include <mono/utils/mono-compiler.h>
#ifndef DISABLE_JIT
#include "mini.h"
#define SPILL_COST_INCREMENT (1 << (bb->nesting << 1))
#define DEBUG_LIVENESS
#define BITS_PER_CHUNK MONO_BITSET_BITS_PER_CHUNK
#define BB_ID_SHIFT 18
/*
* The liveness2 pass can't handle long vars on 32 bit platforms because the component
* vars have the same 'idx'.
*/
#if SIZEOF_REGISTER == 8
#define ENABLE_LIVENESS2
#endif
#ifdef ENABLE_LIVENESS2
static void mono_analyze_liveness2 (MonoCompile *cfg);
#endif
#define INLINE_SIZE 16
typedef struct {
int capacity;
union {
gpointer data [INLINE_SIZE];
GHashTable *hashtable;
};
} MonoPtrSet;
static void
mono_ptrset_init (MonoPtrSet *set)
{
set->capacity = 0;
}
static void
mono_ptrset_destroy (MonoPtrSet *set)
{
if (set->capacity > INLINE_SIZE)
g_hash_table_destroy (set->hashtable);
}
static void
mono_ptrset_add (MonoPtrSet *set, gpointer val)
{
//switch to hashtable
if (set->capacity == INLINE_SIZE) {
GHashTable *tmp = g_hash_table_new (NULL, NULL);
for (int i = 0; i < INLINE_SIZE; ++i)
g_hash_table_insert (tmp, set->data [i], set->data [i]);
set->hashtable = tmp;
++set->capacity;
}
if (set->capacity > INLINE_SIZE) {
g_hash_table_insert (set->hashtable, val, val);
} else {
set->data [set->capacity] = val;
++set->capacity;
}
}
static gboolean
mono_ptrset_contains (MonoPtrSet *set, gpointer val)
{
if (set->capacity <= INLINE_SIZE) {
for (int i = 0; i < set->capacity; ++i) {
if (set->data [i] == val)
return TRUE;
}
return FALSE;
}
return g_hash_table_lookup (set->hashtable, val) != NULL;
}
static void
optimize_initlocals (MonoCompile *cfg);
/* mono_bitset_mp_new:
*
* allocates a MonoBitSet inside a memory pool
*/
static MonoBitSet*
mono_bitset_mp_new (MonoMemPool *mp, guint32 size, guint32 max_size)
{
guint8 *mem = (guint8 *)mono_mempool_alloc0 (mp, size);
return mono_bitset_mem_new (mem, max_size, MONO_BITSET_DONT_FREE);
}
static MonoBitSet*
mono_bitset_mp_new_noinit (MonoMemPool *mp, guint32 size, guint32 max_size)
{
guint8 *mem = (guint8 *)mono_mempool_alloc (mp, size);
return mono_bitset_mem_new (mem, max_size, MONO_BITSET_DONT_FREE);
}
G_GNUC_UNUSED static void
mono_bitset_print (MonoBitSet *set)
{
int i;
gboolean first = TRUE;
printf ("{");
for (i = 0; i < mono_bitset_size (set); i++) {
if (mono_bitset_test (set, i)) {
if (!first)
printf (", ");
printf ("%d", i);
first = FALSE;
}
}
printf ("}\n");
}
static void
visit_bb (MonoCompile *cfg, MonoBasicBlock *bb, MonoPtrSet *visited)
{
int i;
MonoInst *ins;
if (mono_ptrset_contains (visited, bb))
return;
for (ins = bb->code; ins; ins = ins->next) {
const char *spec = INS_INFO (ins->opcode);
int regtype, srcindex, sreg, num_sregs;
int sregs [MONO_MAX_SRC_REGS];
if (ins->opcode == OP_NOP)
continue;
/* DREG */
regtype = spec [MONO_INST_DEST];
g_assert (((ins->dreg == -1) && (regtype == ' ')) || ((ins->dreg != -1) && (regtype != ' ')));
if ((ins->dreg != -1) && get_vreg_to_inst (cfg, ins->dreg)) {
MonoInst *var = get_vreg_to_inst (cfg, ins->dreg);
int idx = var->inst_c0;
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
cfg->varinfo [vi->idx]->flags |= MONO_INST_VOLATILE;
if (SIZEOF_REGISTER == 4 && (var->type == STACK_I8 || (var->type == STACK_R8 && COMPILE_SOFT_FLOAT (cfg)))) {
/* Make the component vregs volatile as well (#612206) */
get_vreg_to_inst (cfg, MONO_LVREG_LS (var->dreg))->flags |= MONO_INST_VOLATILE;
get_vreg_to_inst (cfg, MONO_LVREG_MS (var->dreg))->flags |= MONO_INST_VOLATILE;
}
}
/* SREGS */
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (srcindex = 0; srcindex < num_sregs; ++srcindex) {
sreg = sregs [srcindex];
g_assert (sreg != -1);
if (get_vreg_to_inst (cfg, sreg)) {
MonoInst *var = get_vreg_to_inst (cfg, sreg);
int idx = var->inst_c0;
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
cfg->varinfo [vi->idx]->flags |= MONO_INST_VOLATILE;
if (SIZEOF_REGISTER == 4 && (var->type == STACK_I8 || (var->type == STACK_R8 && COMPILE_SOFT_FLOAT (cfg)))) {
/* Make the component vregs volatile as well (#612206) */
get_vreg_to_inst (cfg, MONO_LVREG_LS (var->dreg))->flags |= MONO_INST_VOLATILE;
get_vreg_to_inst (cfg, MONO_LVREG_MS (var->dreg))->flags |= MONO_INST_VOLATILE;
}
}
}
}
mono_ptrset_add (visited, bb);
/*
* Need to visit all bblocks reachable from this one since they can be
* reached during exception handling.
*/
for (i = 0; i < bb->out_count; ++i) {
visit_bb (cfg, bb->out_bb [i], visited);
}
}
void
mono_liveness_handle_exception_clauses (MonoCompile *cfg)
{
MonoBasicBlock *bb;
MonoMethodHeader *header = cfg->header;
MonoExceptionClause *clause, *clause2;
int i, j;
gboolean *outer_try;
/*
* Determine which clauses are outer try clauses, i.e. they are not contained in any
* other non-try clause.
*/
outer_try = (gboolean *)mono_mempool_alloc0 (cfg->mempool, sizeof (gboolean) * header->num_clauses);
for (i = 0; i < header->num_clauses; ++i)
outer_try [i] = TRUE;
/* Iterate over the clauses backward, so outer clauses come first */
/* This avoids doing an O(2) search, since we can determine when inner clauses end */
for (i = header->num_clauses - 1; i >= 0; --i) {
clause = &header->clauses [i];
if (clause->flags != 0) {
outer_try [i] = TRUE;
/* Iterate over inner clauses */
for (j = i - 1; j >= 0; --j) {
clause2 = &header->clauses [j];
if (clause2->flags == 0 && MONO_OFFSET_IN_HANDLER (clause, clause2->try_offset)) {
outer_try [j] = FALSE;
break;
}
if (clause2->try_offset < clause->try_offset)
/* End of inner clauses */
break;
}
}
}
MonoPtrSet visited;
mono_ptrset_init (&visited);
/*
* Variables in exception handler register cannot be allocated to registers
* so make them volatile. See bug #42136. This will not be neccessary when
* the back ends could guarantee that the variables will be in the
* correct registers when a handler is called.
* This includes try blocks too, since a variable in a try block might be
* accessed after an exception handler has been run.
*/
for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
if (bb->region == -1)
continue;
if (MONO_BBLOCK_IS_IN_REGION (bb, MONO_REGION_TRY) && outer_try [MONO_REGION_CLAUSE_INDEX (bb->region)])
continue;
if (cfg->verbose_level > 2)
printf ("pessimize variables in bb %d.\n", bb->block_num);
visit_bb (cfg, bb, &visited);
}
mono_ptrset_destroy (&visited);
}
static void
update_live_range (MonoMethodVar *var, int abs_pos)
{
if (var->range.first_use.abs_pos > abs_pos)
var->range.first_use.abs_pos = abs_pos;
if (var->range.last_use.abs_pos < abs_pos)
var->range.last_use.abs_pos = abs_pos;
}
static void
analyze_liveness_bb (MonoCompile *cfg, MonoBasicBlock *bb)
{
MonoInst *ins;
int sreg, inst_num;
MonoMethodVar *vars = cfg->vars;
guint32 abs_pos = (bb->dfn << BB_ID_SHIFT);
/* Start inst_num from > 0, so last_use.abs_pos is only 0 for dead variables */
for (inst_num = 2, ins = bb->code; ins; ins = ins->next, inst_num += 2) {
const char *spec = INS_INFO (ins->opcode);
int num_sregs, i;
int sregs [MONO_MAX_SRC_REGS];
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1) {
mono_print_ins_index (1, ins);
}
#endif
if (ins->opcode == OP_NOP)
continue;
if (ins->opcode == OP_LDADDR) {
MonoInst *var = (MonoInst *)ins->inst_p0;
int idx = var->inst_c0;
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1)
printf ("\tGEN: R%d(%d)\n", var->dreg, idx);
#endif
update_live_range (&vars [idx], abs_pos + inst_num);
if (!mono_bitset_test_fast (bb->kill_set, idx))
mono_bitset_set_fast (bb->gen_set, idx);
vi->spill_costs += SPILL_COST_INCREMENT;
}
/* SREGs must come first, so MOVE r <- r is handled correctly */
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (i = 0; i < num_sregs; ++i) {
sreg = sregs [i];
if ((spec [MONO_INST_SRC1 + i] != ' ') && get_vreg_to_inst (cfg, sreg)) {
MonoInst *var = get_vreg_to_inst (cfg, sreg);
int idx = var->inst_c0;
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1)
printf ("\tGEN: R%d(%d)\n", sreg, idx);
#endif
update_live_range (&vars [idx], abs_pos + inst_num);
if (!mono_bitset_test_fast (bb->kill_set, idx))
mono_bitset_set_fast (bb->gen_set, idx);
vi->spill_costs += SPILL_COST_INCREMENT;
}
}
/* DREG */
if ((spec [MONO_INST_DEST] != ' ') && get_vreg_to_inst (cfg, ins->dreg)) {
MonoInst *var = get_vreg_to_inst (cfg, ins->dreg);
int idx = var->inst_c0;
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
if (MONO_IS_STORE_MEMBASE (ins)) {
update_live_range (&vars [idx], abs_pos + inst_num);
if (!mono_bitset_test_fast (bb->kill_set, idx))
mono_bitset_set_fast (bb->gen_set, idx);
vi->spill_costs += SPILL_COST_INCREMENT;
} else {
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1)
printf ("\tKILL: R%d(%d)\n", ins->dreg, idx);
#endif
update_live_range (&vars [idx], abs_pos + inst_num + 1);
mono_bitset_set_fast (bb->kill_set, idx);
vi->spill_costs += SPILL_COST_INCREMENT;
}
}
}
}
/* generic liveness analysis code. CFG specific parts are
* in update_gen_kill_set()
*/
void
mono_analyze_liveness (MonoCompile *cfg)
{
MonoBitSet *old_live_out_set;
int i, j, max_vars = cfg->num_varinfo;
int out_iter;
gboolean *in_worklist;
MonoBasicBlock **worklist;
guint32 l_end;
int bitsize;
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1)
printf ("\nLIVENESS:\n");
#endif
g_assert (!(cfg->comp_done & MONO_COMP_LIVENESS));
cfg->comp_done |= MONO_COMP_LIVENESS;
if (max_vars == 0)
return;
bitsize = mono_bitset_alloc_size (max_vars, 0);
for (i = 0; i < max_vars; i ++) {
MONO_VARINFO (cfg, i)->range.first_use.abs_pos = ~ 0;
MONO_VARINFO (cfg, i)->range.last_use .abs_pos = 0;
MONO_VARINFO (cfg, i)->spill_costs = 0;
}
for (i = 0; i < cfg->num_bblocks; ++i) {
MonoBasicBlock *bb = cfg->bblocks [i];
bb->gen_set = mono_bitset_mp_new (cfg->mempool, bitsize, max_vars);
bb->kill_set = mono_bitset_mp_new (cfg->mempool, bitsize, max_vars);
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1) {
printf ("BLOCK BB%d (", bb->block_num);
for (j = 0; j < bb->out_count; j++)
printf ("BB%d, ", bb->out_bb [j]->block_num);
printf ("):\n");
}
#endif
analyze_liveness_bb (cfg, bb);
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1) {
printf ("GEN BB%d: ", bb->block_num); mono_bitset_print (bb->gen_set);
printf ("KILL BB%d: ", bb->block_num); mono_bitset_print (bb->kill_set);
}
#endif
}
old_live_out_set = mono_bitset_new (max_vars, 0);
in_worklist = g_new0 (gboolean, cfg->num_bblocks + 1);
worklist = g_new (MonoBasicBlock *, cfg->num_bblocks + 1);
l_end = 0;
/*
* This is a backward dataflow analysis problem, so we process blocks in
* decreasing dfn order, this speeds up the iteration.
*/
for (i = 0; i < cfg->num_bblocks; i ++) {
MonoBasicBlock *bb = cfg->bblocks [i];
worklist [l_end ++] = bb;
in_worklist [bb->dfn] = TRUE;
/* Initialized later */
bb->live_in_set = NULL;
bb->live_out_set = mono_bitset_mp_new (cfg->mempool, bitsize, max_vars);
}
out_iter = 0;
if (cfg->verbose_level > 1)
printf ("\nITERATION:\n");
while (l_end != 0) {
MonoBasicBlock *bb = worklist [--l_end];
MonoBasicBlock *out_bb;
gboolean changed;
in_worklist [bb->dfn] = FALSE;
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1) {
printf ("P: BB%d(%d): IN: ", bb->block_num, bb->dfn);
for (j = 0; j < bb->in_count; ++j)
printf ("BB%d ", bb->in_bb [j]->block_num);
printf ("OUT:");
for (j = 0; j < bb->out_count; ++j)
printf ("BB%d ", bb->out_bb [j]->block_num);
printf ("\n");
}
#endif
if (bb->out_count == 0)
continue;
out_iter ++;
if (!bb->live_in_set) {
/* First pass over this bblock */
changed = TRUE;
}
else {
changed = FALSE;
mono_bitset_copyto_fast (bb->live_out_set, old_live_out_set);
}
for (j = 0; j < bb->out_count; j++) {
out_bb = bb->out_bb [j];
if (!out_bb->live_in_set) {
out_bb->live_in_set = mono_bitset_mp_new_noinit (cfg->mempool, bitsize, max_vars);
mono_bitset_copyto_fast (out_bb->live_out_set, out_bb->live_in_set);
mono_bitset_sub_fast (out_bb->live_in_set, out_bb->kill_set);
mono_bitset_union_fast (out_bb->live_in_set, out_bb->gen_set);
}
// FIXME: Do this somewhere else
if (bb->last_ins && bb->last_ins->opcode == OP_NOT_REACHED) {
} else {
mono_bitset_union_fast (bb->live_out_set, out_bb->live_in_set);
}
}
if (changed || !mono_bitset_equal (old_live_out_set, bb->live_out_set)) {
if (!bb->live_in_set)
bb->live_in_set = mono_bitset_mp_new_noinit (cfg->mempool, bitsize, max_vars);
mono_bitset_copyto_fast (bb->live_out_set, bb->live_in_set);
mono_bitset_sub_fast (bb->live_in_set, bb->kill_set);
mono_bitset_union_fast (bb->live_in_set, bb->gen_set);
for (j = 0; j < bb->in_count; j++) {
MonoBasicBlock *in_bb = bb->in_bb [j];
/*
* Some basic blocks do not seem to be in the
* cfg->bblocks array...
*/
if (in_bb->gen_set && !in_worklist [in_bb->dfn]) {
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1)
printf ("\tADD: %d\n", in_bb->block_num);
#endif
/*
* Put the block at the top of the stack, so it
* will be processed right away.
*/
worklist [l_end ++] = in_bb;
in_worklist [in_bb->dfn] = TRUE;
}
}
}
if (G_UNLIKELY (cfg->verbose_level > 1)) {
printf ("\tLIVE IN BB%d: ", bb->block_num);
mono_bitset_print (bb->live_in_set);
}
}
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1)
printf ("IT: %d %d.\n", cfg->num_bblocks, out_iter);
#endif
mono_bitset_free (old_live_out_set);
g_free (worklist);
g_free (in_worklist);
/* Compute live_in_set for bblocks skipped earlier */
for (i = 0; i < cfg->num_bblocks; ++i) {
MonoBasicBlock *bb = cfg->bblocks [i];
if (!bb->live_in_set) {
bb->live_in_set = mono_bitset_mp_new (cfg->mempool, bitsize, max_vars);
mono_bitset_copyto_fast (bb->live_out_set, bb->live_in_set);
mono_bitset_sub_fast (bb->live_in_set, bb->kill_set);
mono_bitset_union_fast (bb->live_in_set, bb->gen_set);
}
}
for (i = 0; i < cfg->num_bblocks; ++i) {
MonoBasicBlock *bb = cfg->bblocks [i];
guint32 max;
guint32 abs_pos = (bb->dfn << BB_ID_SHIFT);
MonoMethodVar *vars = cfg->vars;
if (!bb->live_out_set)
continue;
max = ((max_vars + (BITS_PER_CHUNK -1)) / BITS_PER_CHUNK);
for (j = 0; j < max; ++j) {
gsize bits_in;
gsize bits_out;
int k;
bits_in = mono_bitset_get_fast (bb->live_in_set, j);
bits_out = mono_bitset_get_fast (bb->live_out_set, j);
k = (j * BITS_PER_CHUNK);
while ((bits_in || bits_out)) {
if (bits_in & 1)
update_live_range (&vars [k], abs_pos + 0);
if (bits_out & 1)
update_live_range (&vars [k], abs_pos + ((1 << BB_ID_SHIFT) - 1));
bits_in >>= 1;
bits_out >>= 1;
k ++;
}
}
}
/*
* Arguments need to have their live ranges extended to the beginning of
* the method to account for the arg reg/memory -> global register copies
* in the prolog (bug #74992).
*/
for (i = 0; i < max_vars; i ++) {
MonoMethodVar *vi = MONO_VARINFO (cfg, i);
if (cfg->varinfo [vi->idx]->opcode == OP_ARG) {
if (vi->range.last_use.abs_pos == 0 && !(cfg->varinfo [vi->idx]->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT))) {
/*
* Can't eliminate the this variable in gshared code, since
* it is needed during exception handling to identify the
* method.
* It is better to check for this here instead of marking the variable
* VOLATILE, since that would prevent it from being allocated to
* registers.
*/
if (!cfg->disable_deadce_vars && !(cfg->gshared && mono_method_signature_internal (cfg->method)->hasthis && cfg->varinfo [vi->idx] == cfg->args [0]))
cfg->varinfo [vi->idx]->flags |= MONO_INST_IS_DEAD;
}
vi->range.first_use.abs_pos = 0;
}
}
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1) {
for (i = cfg->num_bblocks - 1; i >= 0; i--) {
MonoBasicBlock *bb = cfg->bblocks [i];
printf ("LIVE IN BB%d: ", bb->block_num);
mono_bitset_print (bb->live_in_set);
printf ("LIVE OUT BB%d: ", bb->block_num);
mono_bitset_print (bb->live_out_set);
}
for (i = 0; i < max_vars; i ++) {
MonoMethodVar *vi = MONO_VARINFO (cfg, i);
printf ("V%d: [0x%x - 0x%x]\n", i, vi->range.first_use.abs_pos, vi->range.last_use.abs_pos);
}
}
#endif
if (!cfg->disable_initlocals_opt)
optimize_initlocals (cfg);
#ifdef ENABLE_LIVENESS2
/* This improves code size by about 5% but slows down compilation too much */
if (cfg->compile_aot)
mono_analyze_liveness2 (cfg);
#endif
}
/**
* optimize_initlocals:
*
* Try to optimize away some of the redundant initialization code inserted because of
* 'locals init' using the liveness information.
*/
static void
optimize_initlocals (MonoCompile *cfg)
{
MonoBitSet *used;
MonoInst *ins;
MonoBasicBlock *initlocals_bb;
used = mono_bitset_new (cfg->next_vreg + 1, 0);
mono_bitset_clear_all (used);
initlocals_bb = cfg->bb_entry->next_bb;
for (ins = initlocals_bb->code; ins; ins = ins->next) {
int num_sregs, i;
int sregs [MONO_MAX_SRC_REGS];
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (i = 0; i < num_sregs; ++i)
mono_bitset_set_fast (used, sregs [i]);
if (MONO_IS_STORE_MEMBASE (ins))
mono_bitset_set_fast (used, ins->dreg);
}
for (ins = initlocals_bb->code; ins; ins = ins->next) {
const char *spec = INS_INFO (ins->opcode);
/* Look for statements whose dest is not used in this bblock and not live on exit. */
if ((spec [MONO_INST_DEST] != ' ') && !MONO_IS_STORE_MEMBASE (ins)) {
MonoInst *var = get_vreg_to_inst (cfg, ins->dreg);
if (var && !mono_bitset_test_fast (used, ins->dreg) && !mono_bitset_test_fast (initlocals_bb->live_out_set, var->inst_c0) && (var != cfg->ret) && !(var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT))) {
//printf ("DEAD: "); mono_print_ins (ins);
if (cfg->disable_initlocals_opt_refs && var->type == STACK_OBJ)
continue;
if ((ins->opcode == OP_ICONST) || (ins->opcode == OP_I8CONST) || (ins->opcode == OP_R8CONST) || (ins->opcode == OP_R4CONST)) {
NULLIFY_INS (ins);
MONO_VARINFO (cfg, var->inst_c0)->spill_costs -= 1;
/*
* We should shorten the liveness interval of these vars as well, but
* don't have enough info to do that.
*/
}
}
}
}
g_free (used);
}
void
mono_linterval_add_range (MonoCompile *cfg, MonoLiveInterval *interval, int from, int to)
{
MonoLiveRange2 *prev_range, *next_range, *new_range;
g_assert (to >= from);
/* Optimize for extending the first interval backwards */
if (G_LIKELY (interval->range && (interval->range->from > from) && (interval->range->from == to))) {
interval->range->from = from;
return;
}
/* Find a place in the list for the new range */
prev_range = NULL;
next_range = interval->range;
while ((next_range != NULL) && (next_range->from <= from)) {
prev_range = next_range;
next_range = next_range->next;
}
if (prev_range && prev_range->to == from) {
/* Merge with previous */
prev_range->to = to;
} else if (next_range && next_range->from == to) {
/* Merge with previous */
next_range->from = from;
} else {
/* Insert it */
new_range = (MonoLiveRange2 *)mono_mempool_alloc (cfg->mempool, sizeof (MonoLiveRange2));
new_range->from = from;
new_range->to = to;
new_range->next = NULL;
if (prev_range)
prev_range->next = new_range;
else
interval->range = new_range;
if (next_range)
new_range->next = next_range;
else
interval->last_range = new_range;
}
/* FIXME: Merge intersecting ranges */
}
void
mono_linterval_print (MonoLiveInterval *interval)
{
MonoLiveRange2 *range;
for (range = interval->range; range != NULL; range = range->next)
printf ("[%x-%x] ", range->from, range->to);
}
void
mono_linterval_print_nl (MonoLiveInterval *interval)
{
mono_linterval_print (interval);
printf ("\n");
}
/**
* mono_linterval_convers:
*
* Return whenever INTERVAL covers the position POS.
*/
gboolean
mono_linterval_covers (MonoLiveInterval *interval, int pos)
{
MonoLiveRange2 *range;
for (range = interval->range; range != NULL; range = range->next) {
if (pos >= range->from && pos <= range->to)
return TRUE;
if (range->from > pos)
return FALSE;
}
return FALSE;
}
/**
* mono_linterval_get_intersect_pos:
*
* Determine whenever I1 and I2 intersect, and if they do, return the first
* point of intersection. Otherwise, return -1.
*/
gint32
mono_linterval_get_intersect_pos (MonoLiveInterval *i1, MonoLiveInterval *i2)
{
MonoLiveRange2 *r1, *r2;
/* FIXME: Optimize this */
for (r1 = i1->range; r1 != NULL; r1 = r1->next) {
for (r2 = i2->range; r2 != NULL; r2 = r2->next) {
if (r2->to > r1->from && r2->from < r1->to) {
if (r2->from <= r1->from)
return r1->from;
else
return r2->from;
}
}
}
return -1;
}
/**
* mono_linterval_split
*
* Split L at POS and store the newly created intervals into L1 and L2. POS becomes
* part of L2.
*/
void
mono_linterval_split (MonoCompile *cfg, MonoLiveInterval *interval, MonoLiveInterval **i1, MonoLiveInterval **i2, int pos)
{
MonoLiveRange2 *r;
g_assert (pos > interval->range->from && pos <= interval->last_range->to);
*i1 = (MonoLiveInterval *)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoLiveInterval));
*i2 = (MonoLiveInterval *)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoLiveInterval));
for (r = interval->range; r; r = r->next) {
if (pos > r->to) {
/* Add it to the first child */
mono_linterval_add_range (cfg, *i1, r->from, r->to);
} else if (pos > r->from && pos <= r->to) {
/* Split at pos */
mono_linterval_add_range (cfg, *i1, r->from, pos - 1);
mono_linterval_add_range (cfg, *i2, pos, r->to);
} else {
/* Add it to the second child */
mono_linterval_add_range (cfg, *i2, r->from, r->to);
}
}
}
#if 1
#define LIVENESS_DEBUG(a) do { if (cfg->verbose_level > 1) do { a; } while (0); } while (0)
#define ENABLE_LIVENESS_DEBUG 1
#else
#define LIVENESS_DEBUG(a)
#endif
#ifdef ENABLE_LIVENESS2
static void
update_liveness2 (MonoCompile *cfg, MonoInst *ins, gboolean set_volatile, int inst_num, gint32 *last_use)
{
const char *spec = INS_INFO (ins->opcode);
int sreg;
int num_sregs, i;
int sregs [MONO_MAX_SRC_REGS];
LIVENESS_DEBUG (printf ("\t%x: ", inst_num); mono_print_ins (ins));
if (ins->opcode == OP_NOP || ins->opcode == OP_IL_SEQ_POINT)
return;
/* DREG */
if ((spec [MONO_INST_DEST] != ' ') && get_vreg_to_inst (cfg, ins->dreg)) {
MonoInst *var = get_vreg_to_inst (cfg, ins->dreg);
int idx = var->inst_c0;
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
if (MONO_IS_STORE_MEMBASE (ins)) {
if (last_use [idx] == 0) {
LIVENESS_DEBUG (printf ("\tlast use of R%d set to %x\n", ins->dreg, inst_num));
last_use [idx] = inst_num;
}
} else {
if (last_use [idx] > 0) {
LIVENESS_DEBUG (printf ("\tadd range to R%d: [%x, %x)\n", ins->dreg, inst_num, last_use [idx]));
mono_linterval_add_range (cfg, vi->interval, inst_num, last_use [idx]);
last_use [idx] = 0;
}
else {
/* Try dead code elimination */
if (!cfg->disable_deadce_vars && (var != cfg->ret) && !(var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)) && ((ins->opcode == OP_ICONST) || (ins->opcode == OP_I8CONST) || (ins->opcode == OP_R8CONST)) && !(var->flags & MONO_INST_VOLATILE)) {
LIVENESS_DEBUG (printf ("\tdead def of R%d, eliminated\n", ins->dreg));
NULLIFY_INS (ins);
return;
} else {
int inst_num_add = 1;
MonoInst *next = ins->next;
while (next && next->opcode == OP_IL_SEQ_POINT) {
inst_num_add++;
next = next->next;
}
LIVENESS_DEBUG (printf ("\tdead def of R%d, add range to R%d: [%x, %x]\n", ins->dreg, ins->dreg, inst_num, inst_num + inst_num_add));
mono_linterval_add_range (cfg, vi->interval, inst_num, inst_num + inst_num_add);
}
}
}
}
/* SREGs */
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (i = 0; i < num_sregs; ++i) {
sreg = sregs [i];
if ((spec [MONO_INST_SRC1 + i] != ' ') && get_vreg_to_inst (cfg, sreg)) {
MonoInst *var = get_vreg_to_inst (cfg, sreg);
int idx = var->inst_c0;
if (last_use [idx] == 0) {
LIVENESS_DEBUG (printf ("\tlast use of R%d set to %x\n", sreg, inst_num));
last_use [idx] = inst_num;
}
}
}
}
static void
mono_analyze_liveness2 (MonoCompile *cfg)
{
int bnum, idx, i, j, nins, max, max_vars, block_from, block_to, pos;
gint32 *last_use;
static guint32 disabled = -1;
if (disabled == -1)
disabled = g_hasenv ("DISABLED");
if (disabled)
return;
if (cfg->num_bblocks >= (1 << (32 - BB_ID_SHIFT - 1)))
/* Ranges would overflow */
return;
for (bnum = cfg->num_bblocks - 1; bnum >= 0; --bnum) {
MonoBasicBlock *bb = cfg->bblocks [bnum];
MonoInst *ins;
nins = 0;
for (nins = 0, ins = bb->code; ins; ins = ins->next, ++nins)
nins ++;
if (nins >= ((1 << BB_ID_SHIFT) - 1))
/* Ranges would overflow */
return;
}
LIVENESS_DEBUG (printf ("LIVENESS 2 %s\n", mono_method_full_name (cfg->method, TRUE)));
/*
if (strstr (cfg->method->name, "test_") != cfg->method->name)
return;
*/
max_vars = cfg->num_varinfo;
last_use = g_new0 (gint32, max_vars);
for (idx = 0; idx < max_vars; ++idx) {
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
vi->interval = (MonoLiveInterval *)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoLiveInterval));
}
/*
* Process bblocks in reverse order, so the addition of new live ranges
* to the intervals is faster.
*/
for (bnum = cfg->num_bblocks - 1; bnum >= 0; --bnum) {
MonoBasicBlock *bb = cfg->bblocks [bnum];
MonoInst *ins;
block_from = (bb->dfn << BB_ID_SHIFT) + 1; /* so pos > 0 */
if (bnum < cfg->num_bblocks - 1)
/* Beginning of the next bblock */
block_to = (cfg->bblocks [bnum + 1]->dfn << BB_ID_SHIFT) + 1;
else
block_to = (bb->dfn << BB_ID_SHIFT) + ((1 << BB_ID_SHIFT) - 1);
LIVENESS_DEBUG (printf ("LIVENESS BLOCK BB%d:\n", bb->block_num));
memset (last_use, 0, max_vars * sizeof (gint32));
/* For variables in bb->live_out, set last_use to block_to */
max = ((max_vars + (BITS_PER_CHUNK -1)) / BITS_PER_CHUNK);
for (j = 0; j < max; ++j) {
gsize bits_out;
int k;
bits_out = mono_bitset_get_fast (bb->live_out_set, j);
k = (j * BITS_PER_CHUNK);
while (bits_out) {
if (bits_out & 1) {
LIVENESS_DEBUG (printf ("Var R%d live at exit, set last_use to %x\n", cfg->varinfo [k]->dreg, block_to));
last_use [k] = block_to;
}
bits_out >>= 1;
k ++;
}
}
if (cfg->ret)
last_use [cfg->ret->inst_c0] = block_to;
pos = block_from + 1;
MONO_BB_FOR_EACH_INS (bb, ins) pos++;
/* Process instructions backwards */
MONO_BB_FOR_EACH_INS_REVERSE (bb, ins) {
update_liveness2 (cfg, ins, FALSE, pos, last_use);
pos--;
}
for (idx = 0; idx < max_vars; ++idx) {
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
if (last_use [idx] != 0) {
/* Live at exit, not written -> live on enter */
LIVENESS_DEBUG (printf ("Var R%d live at enter, add range to R%d: [%x, %x)\n", cfg->varinfo [idx]->dreg, cfg->varinfo [idx]->dreg, block_from, last_use [idx]));
mono_linterval_add_range (cfg, vi->interval, block_from, last_use [idx]);
}
}
}
/*
* Arguments need to have their live ranges extended to the beginning of
* the method to account for the arg reg/memory -> global register copies
* in the prolog (bug #74992).
*/
for (i = 0; i < max_vars; i ++) {
MonoMethodVar *vi = MONO_VARINFO (cfg, i);
if (cfg->varinfo [vi->idx]->opcode == OP_ARG)
mono_linterval_add_range (cfg, vi->interval, 0, 1);
}
#if 0
for (idx = 0; idx < max_vars; ++idx) {
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
LIVENESS_DEBUG (printf ("LIVENESS R%d: ", cfg->varinfo [idx]->dreg));
LIVENESS_DEBUG (mono_linterval_print (vi->interval));
LIVENESS_DEBUG (printf ("\n"));
}
#endif
g_free (last_use);
}
#endif
static void
update_liveness_gc (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins, gint32 *last_use, MonoMethodVar **vreg_to_varinfo, GSList **callsites)
{
if (ins->opcode == OP_GC_LIVENESS_DEF || ins->opcode == OP_GC_LIVENESS_USE) {
int vreg = ins->inst_c1;
MonoMethodVar *vi = vreg_to_varinfo [vreg];
int idx = vi->idx;
int pc_offset = ins->backend.pc_offset;
LIVENESS_DEBUG (printf ("\t%x: ", pc_offset); mono_print_ins (ins));
if (ins->opcode == OP_GC_LIVENESS_DEF) {
if (last_use [idx] > 0) {
LIVENESS_DEBUG (printf ("\tadd range to R%d: [%x, %x)\n", vreg, pc_offset, last_use [idx]));
last_use [idx] = 0;
}
} else {
if (last_use [idx] == 0) {
LIVENESS_DEBUG (printf ("\tlast use of R%d set to %x\n", vreg, pc_offset));
last_use [idx] = pc_offset;
}
}
} else if (ins->opcode == OP_GC_PARAM_SLOT_LIVENESS_DEF) {
GCCallSite *last;
/* Add it to the last callsite */
g_assert (*callsites);
last = (GCCallSite *)(*callsites)->data;
last->param_slots = g_slist_prepend_mempool (cfg->mempool, last->param_slots, ins);
} else if (ins->flags & MONO_INST_GC_CALLSITE) {
GCCallSite *callsite = (GCCallSite *)mono_mempool_alloc0 (cfg->mempool, sizeof (GCCallSite));
int i;
LIVENESS_DEBUG (printf ("\t%x: ", ins->backend.pc_offset); mono_print_ins (ins));
LIVENESS_DEBUG (printf ("\t\tlive: "));
callsite->bb = bb;
callsite->liveness = (guint8 *)mono_mempool_alloc0 (cfg->mempool, ALIGN_TO (cfg->num_varinfo, 8) / 8);
callsite->pc_offset = ins->backend.pc_offset;
for (i = 0; i < cfg->num_varinfo; ++i) {
if (last_use [i] != 0) {
LIVENESS_DEBUG (printf ("R%d", MONO_VARINFO (cfg, i)->vreg));
callsite->liveness [i / 8] |= (1 << (i % 8));
}
}
LIVENESS_DEBUG (printf ("\n"));
*callsites = g_slist_prepend_mempool (cfg->mempool, *callsites, callsite);
}
}
static int
get_vreg_from_var (MonoCompile *cfg, MonoInst *var)
{
if (var->opcode == OP_REGVAR)
/* dreg contains a hreg, but inst_c0 still contains the var index */
return MONO_VARINFO (cfg, var->inst_c0)->vreg;
else
/* dreg still contains the vreg */
return var->dreg;
}
/*
* mono_analyze_liveness_gc:
*
* Compute liveness bitmaps for each call site.
* This function is a modified version of mono_analyze_liveness2 ().
*/
void
mono_analyze_liveness_gc (MonoCompile *cfg)
{
int idx, i, j, nins, max, max_vars, block_from, block_to, pos, reverse_len;
gint32 *last_use;
MonoInst **reverse;
MonoMethodVar **vreg_to_varinfo = NULL;
MonoBasicBlock *bb;
GSList *callsites;
LIVENESS_DEBUG (printf ("\n------------ GC LIVENESS: ----------\n"));
max_vars = cfg->num_varinfo;
last_use = g_new0 (gint32, max_vars);
/*
* var->inst_c0 no longer contains the variable index, so compute a mapping now.
*/
vreg_to_varinfo = g_new0 (MonoMethodVar*, cfg->next_vreg);
for (idx = 0; idx < max_vars; ++idx) {
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
vreg_to_varinfo [vi->vreg] = vi;
}
reverse_len = 1024;
reverse = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * reverse_len);
for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
MonoInst *ins;
block_from = bb->real_native_offset;
block_to = bb->native_offset + bb->native_length;
LIVENESS_DEBUG (printf ("GC LIVENESS BB%d:\n", bb->block_num));
if (!bb->code)
continue;
memset (last_use, 0, max_vars * sizeof (gint32));
/* For variables in bb->live_out, set last_use to block_to */
max = ((max_vars + (BITS_PER_CHUNK -1)) / BITS_PER_CHUNK);
for (j = 0; j < max; ++j) {
gsize bits_out;
int k;
if (!bb->live_out_set)
/* The variables used in this bblock are volatile anyway */
continue;
bits_out = mono_bitset_get_fast (bb->live_out_set, j);
k = (j * BITS_PER_CHUNK);
while (bits_out) {
if ((bits_out & 1) && cfg->varinfo [k]->flags & MONO_INST_GC_TRACK) {
int vreg = get_vreg_from_var (cfg, cfg->varinfo [k]);
LIVENESS_DEBUG (printf ("Var R%d live at exit, last_use set to %x.\n", vreg, block_to));
last_use [k] = block_to;
}
bits_out >>= 1;
k ++;
}
}
for (nins = 0, pos = block_from, ins = bb->code; ins; ins = ins->next, ++nins, ++pos) {
if (nins >= reverse_len) {
int new_reverse_len = reverse_len * 2;
MonoInst **new_reverse = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * new_reverse_len);
memcpy (new_reverse, reverse, sizeof (MonoInst*) * reverse_len);
reverse = new_reverse;
reverse_len = new_reverse_len;
}
reverse [nins] = ins;
}
/* Process instructions backwards */
callsites = NULL;
for (i = nins - 1; i >= 0; --i) {
MonoInst *ins = (MonoInst*)reverse [i];
update_liveness_gc (cfg, bb, ins, last_use, vreg_to_varinfo, &callsites);
}
/* The callsites should already be sorted by pc offset because we added them backwards */
bb->gc_callsites = callsites;
}
g_free (last_use);
g_free (vreg_to_varinfo);
}
#else /* !DISABLE_JIT */
MONO_EMPTY_SOURCE_FILE (liveness);
#endif /* !DISABLE_JIT */
| /**
* \file
* liveness analysis
*
* Author:
* Dietmar Maurer ([email protected])
*
* (C) 2002 Ximian, Inc.
* Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#include <mono/utils/mono-compiler.h>
#ifndef DISABLE_JIT
#include "mini.h"
#define SPILL_COST_INCREMENT (1 << (bb->nesting << 1))
#define DEBUG_LIVENESS
#define BITS_PER_CHUNK MONO_BITSET_BITS_PER_CHUNK
#define BB_ID_SHIFT 18
/*
* The liveness2 pass can't handle long vars on 32 bit platforms because the component
* vars have the same 'idx'.
*/
#if SIZEOF_REGISTER == 8
#define ENABLE_LIVENESS2
#endif
#ifdef ENABLE_LIVENESS2
static void mono_analyze_liveness2 (MonoCompile *cfg);
#endif
#define INLINE_SIZE 16
typedef struct {
int capacity;
union {
gpointer data [INLINE_SIZE];
GHashTable *hashtable;
};
} MonoPtrSet;
static void
mono_ptrset_init (MonoPtrSet *set)
{
set->capacity = 0;
}
static void
mono_ptrset_destroy (MonoPtrSet *set)
{
if (set->capacity > INLINE_SIZE)
g_hash_table_destroy (set->hashtable);
}
static void
mono_ptrset_add (MonoPtrSet *set, gpointer val)
{
//switch to hashtable
if (set->capacity == INLINE_SIZE) {
GHashTable *tmp = g_hash_table_new (NULL, NULL);
for (int i = 0; i < INLINE_SIZE; ++i)
g_hash_table_insert (tmp, set->data [i], set->data [i]);
set->hashtable = tmp;
++set->capacity;
}
if (set->capacity > INLINE_SIZE) {
g_hash_table_insert (set->hashtable, val, val);
} else {
set->data [set->capacity] = val;
++set->capacity;
}
}
static gboolean
mono_ptrset_contains (MonoPtrSet *set, gpointer val)
{
if (set->capacity <= INLINE_SIZE) {
for (int i = 0; i < set->capacity; ++i) {
if (set->data [i] == val)
return TRUE;
}
return FALSE;
}
return g_hash_table_lookup (set->hashtable, val) != NULL;
}
static void
optimize_initlocals (MonoCompile *cfg);
/* mono_bitset_mp_new:
*
* allocates a MonoBitSet inside a memory pool
*/
static MonoBitSet*
mono_bitset_mp_new (MonoMemPool *mp, guint32 size, guint32 max_size)
{
guint8 *mem = (guint8 *)mono_mempool_alloc0 (mp, size);
return mono_bitset_mem_new (mem, max_size, MONO_BITSET_DONT_FREE);
}
static MonoBitSet*
mono_bitset_mp_new_noinit (MonoMemPool *mp, guint32 size, guint32 max_size)
{
guint8 *mem = (guint8 *)mono_mempool_alloc (mp, size);
return mono_bitset_mem_new (mem, max_size, MONO_BITSET_DONT_FREE);
}
G_GNUC_UNUSED static void
mono_bitset_print (MonoBitSet *set)
{
int i;
gboolean first = TRUE;
printf ("{");
for (i = 0; i < mono_bitset_size (set); i++) {
if (mono_bitset_test (set, i)) {
if (!first)
printf (", ");
printf ("%d", i);
first = FALSE;
}
}
printf ("}\n");
}
static void
visit_bb (MonoCompile *cfg, MonoBasicBlock *bb, MonoPtrSet *visited)
{
int i;
MonoInst *ins;
if (mono_ptrset_contains (visited, bb))
return;
for (ins = bb->code; ins; ins = ins->next) {
const char *spec = INS_INFO (ins->opcode);
int regtype, srcindex, sreg, num_sregs;
int sregs [MONO_MAX_SRC_REGS];
if (ins->opcode == OP_NOP)
continue;
/* DREG */
regtype = spec [MONO_INST_DEST];
g_assert (((ins->dreg == -1) && (regtype == ' ')) || ((ins->dreg != -1) && (regtype != ' ')));
if ((ins->dreg != -1) && get_vreg_to_inst (cfg, ins->dreg)) {
MonoInst *var = get_vreg_to_inst (cfg, ins->dreg);
int idx = var->inst_c0;
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
cfg->varinfo [vi->idx]->flags |= MONO_INST_VOLATILE;
if (SIZEOF_REGISTER == 4 && (var->type == STACK_I8 || (var->type == STACK_R8 && COMPILE_SOFT_FLOAT (cfg)))) {
/* Make the component vregs volatile as well (#612206) */
get_vreg_to_inst (cfg, MONO_LVREG_LS (var->dreg))->flags |= MONO_INST_VOLATILE;
get_vreg_to_inst (cfg, MONO_LVREG_MS (var->dreg))->flags |= MONO_INST_VOLATILE;
}
}
/* SREGS */
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (srcindex = 0; srcindex < num_sregs; ++srcindex) {
sreg = sregs [srcindex];
g_assert (sreg != -1);
if (get_vreg_to_inst (cfg, sreg)) {
MonoInst *var = get_vreg_to_inst (cfg, sreg);
int idx = var->inst_c0;
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
cfg->varinfo [vi->idx]->flags |= MONO_INST_VOLATILE;
if (SIZEOF_REGISTER == 4 && (var->type == STACK_I8 || (var->type == STACK_R8 && COMPILE_SOFT_FLOAT (cfg)))) {
/* Make the component vregs volatile as well (#612206) */
get_vreg_to_inst (cfg, MONO_LVREG_LS (var->dreg))->flags |= MONO_INST_VOLATILE;
get_vreg_to_inst (cfg, MONO_LVREG_MS (var->dreg))->flags |= MONO_INST_VOLATILE;
}
}
}
}
mono_ptrset_add (visited, bb);
/*
* Need to visit all bblocks reachable from this one since they can be
* reached during exception handling.
*/
for (i = 0; i < bb->out_count; ++i) {
visit_bb (cfg, bb->out_bb [i], visited);
}
}
void
mono_liveness_handle_exception_clauses (MonoCompile *cfg)
{
MonoBasicBlock *bb;
MonoMethodHeader *header = cfg->header;
MonoExceptionClause *clause, *clause2;
int i, j;
gboolean *outer_try;
/*
* Determine which clauses are outer try clauses, i.e. they are not contained in any
* other non-try clause.
*/
outer_try = (gboolean *)mono_mempool_alloc0 (cfg->mempool, sizeof (gboolean) * header->num_clauses);
for (i = 0; i < header->num_clauses; ++i)
outer_try [i] = TRUE;
/* Iterate over the clauses backward, so outer clauses come first */
/* This avoids doing an O(2) search, since we can determine when inner clauses end */
for (i = header->num_clauses - 1; i >= 0; --i) {
clause = &header->clauses [i];
if (clause->flags != 0) {
outer_try [i] = TRUE;
/* Iterate over inner clauses */
for (j = i - 1; j >= 0; --j) {
clause2 = &header->clauses [j];
if (clause2->flags == 0 && MONO_OFFSET_IN_HANDLER (clause, clause2->try_offset)) {
outer_try [j] = FALSE;
break;
}
if (clause2->try_offset < clause->try_offset)
/* End of inner clauses */
break;
}
}
}
MonoPtrSet visited;
mono_ptrset_init (&visited);
/*
* Variables in exception handler register cannot be allocated to registers
* so make them volatile. See bug #42136. This will not be neccessary when
* the back ends could guarantee that the variables will be in the
* correct registers when a handler is called.
* This includes try blocks too, since a variable in a try block might be
* accessed after an exception handler has been run.
*/
for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
if (bb->region == -1)
continue;
if (MONO_BBLOCK_IS_IN_REGION (bb, MONO_REGION_TRY) && outer_try [MONO_REGION_CLAUSE_INDEX (bb->region)])
continue;
if (cfg->verbose_level > 2)
printf ("pessimize variables in bb %d.\n", bb->block_num);
visit_bb (cfg, bb, &visited);
}
mono_ptrset_destroy (&visited);
}
static void
update_live_range (MonoMethodVar *var, int abs_pos)
{
if (var->range.first_use.abs_pos > abs_pos)
var->range.first_use.abs_pos = abs_pos;
if (var->range.last_use.abs_pos < abs_pos)
var->range.last_use.abs_pos = abs_pos;
}
static void
analyze_liveness_bb (MonoCompile *cfg, MonoBasicBlock *bb)
{
MonoInst *ins;
int sreg, inst_num;
MonoMethodVar *vars = cfg->vars;
guint32 abs_pos = (bb->dfn << BB_ID_SHIFT);
/* Start inst_num from > 0, so last_use.abs_pos is only 0 for dead variables */
for (inst_num = 2, ins = bb->code; ins; ins = ins->next, inst_num += 2) {
const char *spec = INS_INFO (ins->opcode);
int num_sregs, i;
int sregs [MONO_MAX_SRC_REGS];
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1) {
mono_print_ins_index (1, ins);
}
#endif
if (ins->opcode == OP_NOP)
continue;
if (ins->opcode == OP_LDADDR) {
MonoInst *var = (MonoInst *)ins->inst_p0;
int idx = var->inst_c0;
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1)
printf ("\tGEN: R%d(%d)\n", var->dreg, idx);
#endif
update_live_range (&vars [idx], abs_pos + inst_num);
if (!mono_bitset_test_fast (bb->kill_set, idx))
mono_bitset_set_fast (bb->gen_set, idx);
vi->spill_costs += SPILL_COST_INCREMENT;
}
/* SREGs must come first, so MOVE r <- r is handled correctly */
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (i = 0; i < num_sregs; ++i) {
sreg = sregs [i];
if ((spec [MONO_INST_SRC1 + i] != ' ') && get_vreg_to_inst (cfg, sreg)) {
MonoInst *var = get_vreg_to_inst (cfg, sreg);
int idx = var->inst_c0;
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1)
printf ("\tGEN: R%d(%d)\n", sreg, idx);
#endif
update_live_range (&vars [idx], abs_pos + inst_num);
if (!mono_bitset_test_fast (bb->kill_set, idx))
mono_bitset_set_fast (bb->gen_set, idx);
vi->spill_costs += SPILL_COST_INCREMENT;
}
}
/* DREG */
if ((spec [MONO_INST_DEST] != ' ') && get_vreg_to_inst (cfg, ins->dreg)) {
MonoInst *var = get_vreg_to_inst (cfg, ins->dreg);
int idx = var->inst_c0;
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
if (MONO_IS_STORE_MEMBASE (ins)) {
update_live_range (&vars [idx], abs_pos + inst_num);
if (!mono_bitset_test_fast (bb->kill_set, idx))
mono_bitset_set_fast (bb->gen_set, idx);
vi->spill_costs += SPILL_COST_INCREMENT;
} else {
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1)
printf ("\tKILL: R%d(%d)\n", ins->dreg, idx);
#endif
update_live_range (&vars [idx], abs_pos + inst_num + 1);
mono_bitset_set_fast (bb->kill_set, idx);
vi->spill_costs += SPILL_COST_INCREMENT;
}
}
}
}
/* generic liveness analysis code. CFG specific parts are
* in update_gen_kill_set()
*/
void
mono_analyze_liveness (MonoCompile *cfg)
{
MonoBitSet *old_live_out_set;
int i, j, max_vars = cfg->num_varinfo;
int out_iter;
gboolean *in_worklist;
MonoBasicBlock **worklist;
guint32 l_end;
int bitsize;
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1)
printf ("\nLIVENESS:\n");
#endif
g_assert (!(cfg->comp_done & MONO_COMP_LIVENESS));
cfg->comp_done |= MONO_COMP_LIVENESS;
if (max_vars == 0)
return;
bitsize = mono_bitset_alloc_size (max_vars, 0);
for (i = 0; i < max_vars; i ++) {
MONO_VARINFO (cfg, i)->range.first_use.abs_pos = ~ 0;
MONO_VARINFO (cfg, i)->range.last_use .abs_pos = 0;
MONO_VARINFO (cfg, i)->spill_costs = 0;
}
for (i = 0; i < cfg->num_bblocks; ++i) {
MonoBasicBlock *bb = cfg->bblocks [i];
bb->gen_set = mono_bitset_mp_new (cfg->mempool, bitsize, max_vars);
bb->kill_set = mono_bitset_mp_new (cfg->mempool, bitsize, max_vars);
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1) {
printf ("BLOCK BB%d (", bb->block_num);
for (j = 0; j < bb->out_count; j++)
printf ("BB%d, ", bb->out_bb [j]->block_num);
printf ("):\n");
}
#endif
analyze_liveness_bb (cfg, bb);
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1) {
printf ("GEN BB%d: ", bb->block_num); mono_bitset_print (bb->gen_set);
printf ("KILL BB%d: ", bb->block_num); mono_bitset_print (bb->kill_set);
}
#endif
}
old_live_out_set = mono_bitset_new (max_vars, 0);
in_worklist = g_new0 (gboolean, cfg->num_bblocks + 1);
worklist = g_new (MonoBasicBlock *, cfg->num_bblocks + 1);
l_end = 0;
/*
* This is a backward dataflow analysis problem, so we process blocks in
* decreasing dfn order, this speeds up the iteration.
*/
for (i = 0; i < cfg->num_bblocks; i ++) {
MonoBasicBlock *bb = cfg->bblocks [i];
worklist [l_end ++] = bb;
in_worklist [bb->dfn] = TRUE;
/* Initialized later */
bb->live_in_set = NULL;
bb->live_out_set = mono_bitset_mp_new (cfg->mempool, bitsize, max_vars);
}
out_iter = 0;
if (cfg->verbose_level > 1)
printf ("\nITERATION:\n");
while (l_end != 0) {
MonoBasicBlock *bb = worklist [--l_end];
MonoBasicBlock *out_bb;
gboolean changed;
in_worklist [bb->dfn] = FALSE;
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1) {
printf ("P: BB%d(%d): IN: ", bb->block_num, bb->dfn);
for (j = 0; j < bb->in_count; ++j)
printf ("BB%d ", bb->in_bb [j]->block_num);
printf ("OUT:");
for (j = 0; j < bb->out_count; ++j)
printf ("BB%d ", bb->out_bb [j]->block_num);
printf ("\n");
}
#endif
if (bb->out_count == 0)
continue;
out_iter ++;
if (!bb->live_in_set) {
/* First pass over this bblock */
changed = TRUE;
}
else {
changed = FALSE;
mono_bitset_copyto_fast (bb->live_out_set, old_live_out_set);
}
for (j = 0; j < bb->out_count; j++) {
out_bb = bb->out_bb [j];
if (!out_bb->live_in_set) {
out_bb->live_in_set = mono_bitset_mp_new_noinit (cfg->mempool, bitsize, max_vars);
mono_bitset_copyto_fast (out_bb->live_out_set, out_bb->live_in_set);
mono_bitset_sub_fast (out_bb->live_in_set, out_bb->kill_set);
mono_bitset_union_fast (out_bb->live_in_set, out_bb->gen_set);
}
// FIXME: Do this somewhere else
if (bb->last_ins && bb->last_ins->opcode == OP_NOT_REACHED) {
} else {
mono_bitset_union_fast (bb->live_out_set, out_bb->live_in_set);
}
}
if (changed || !mono_bitset_equal (old_live_out_set, bb->live_out_set)) {
if (!bb->live_in_set)
bb->live_in_set = mono_bitset_mp_new_noinit (cfg->mempool, bitsize, max_vars);
mono_bitset_copyto_fast (bb->live_out_set, bb->live_in_set);
mono_bitset_sub_fast (bb->live_in_set, bb->kill_set);
mono_bitset_union_fast (bb->live_in_set, bb->gen_set);
for (j = 0; j < bb->in_count; j++) {
MonoBasicBlock *in_bb = bb->in_bb [j];
/*
* Some basic blocks do not seem to be in the
* cfg->bblocks array...
*/
if (in_bb->gen_set && !in_worklist [in_bb->dfn]) {
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1)
printf ("\tADD: %d\n", in_bb->block_num);
#endif
/*
* Put the block at the top of the stack, so it
* will be processed right away.
*/
worklist [l_end ++] = in_bb;
in_worklist [in_bb->dfn] = TRUE;
}
}
}
if (G_UNLIKELY (cfg->verbose_level > 1)) {
printf ("\tLIVE IN BB%d: ", bb->block_num);
mono_bitset_print (bb->live_in_set);
}
}
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1)
printf ("IT: %d %d.\n", cfg->num_bblocks, out_iter);
#endif
mono_bitset_free (old_live_out_set);
g_free (worklist);
g_free (in_worklist);
/* Compute live_in_set for bblocks skipped earlier */
for (i = 0; i < cfg->num_bblocks; ++i) {
MonoBasicBlock *bb = cfg->bblocks [i];
if (!bb->live_in_set) {
bb->live_in_set = mono_bitset_mp_new (cfg->mempool, bitsize, max_vars);
mono_bitset_copyto_fast (bb->live_out_set, bb->live_in_set);
mono_bitset_sub_fast (bb->live_in_set, bb->kill_set);
mono_bitset_union_fast (bb->live_in_set, bb->gen_set);
}
}
for (i = 0; i < cfg->num_bblocks; ++i) {
MonoBasicBlock *bb = cfg->bblocks [i];
guint32 max;
guint32 abs_pos = (bb->dfn << BB_ID_SHIFT);
MonoMethodVar *vars = cfg->vars;
if (!bb->live_out_set)
continue;
max = ((max_vars + (BITS_PER_CHUNK -1)) / BITS_PER_CHUNK);
for (j = 0; j < max; ++j) {
gsize bits_in;
gsize bits_out;
int k;
bits_in = mono_bitset_get_fast (bb->live_in_set, j);
bits_out = mono_bitset_get_fast (bb->live_out_set, j);
k = (j * BITS_PER_CHUNK);
while ((bits_in || bits_out)) {
if (bits_in & 1)
update_live_range (&vars [k], abs_pos + 0);
if (bits_out & 1)
update_live_range (&vars [k], abs_pos + ((1 << BB_ID_SHIFT) - 1));
bits_in >>= 1;
bits_out >>= 1;
k ++;
}
}
}
/*
* Arguments need to have their live ranges extended to the beginning of
* the method to account for the arg reg/memory -> global register copies
* in the prolog (bug #74992).
*/
for (i = 0; i < max_vars; i ++) {
MonoMethodVar *vi = MONO_VARINFO (cfg, i);
if (cfg->varinfo [vi->idx]->opcode == OP_ARG) {
if (vi->range.last_use.abs_pos == 0 && !(cfg->varinfo [vi->idx]->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT))) {
/*
* Can't eliminate the this variable in gshared code, since
* it is needed during exception handling to identify the
* method.
* It is better to check for this here instead of marking the variable
* VOLATILE, since that would prevent it from being allocated to
* registers.
*/
if (!cfg->disable_deadce_vars && !(cfg->gshared && mono_method_signature_internal (cfg->method)->hasthis && cfg->varinfo [vi->idx] == cfg->args [0]))
cfg->varinfo [vi->idx]->flags |= MONO_INST_IS_DEAD;
}
vi->range.first_use.abs_pos = 0;
}
}
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1) {
for (i = cfg->num_bblocks - 1; i >= 0; i--) {
MonoBasicBlock *bb = cfg->bblocks [i];
printf ("LIVE IN BB%d: ", bb->block_num);
mono_bitset_print (bb->live_in_set);
printf ("LIVE OUT BB%d: ", bb->block_num);
mono_bitset_print (bb->live_out_set);
}
for (i = 0; i < max_vars; i ++) {
MonoMethodVar *vi = MONO_VARINFO (cfg, i);
printf ("V%d: [0x%x - 0x%x]\n", i, vi->range.first_use.abs_pos, vi->range.last_use.abs_pos);
}
}
#endif
if (!cfg->disable_initlocals_opt)
optimize_initlocals (cfg);
#ifdef ENABLE_LIVENESS2
/* This improves code size by about 5% but slows down compilation too much */
if (cfg->compile_aot)
mono_analyze_liveness2 (cfg);
#endif
}
/**
* optimize_initlocals:
*
* Try to optimize away some of the redundant initialization code inserted because of
* 'locals init' using the liveness information.
*/
static void
optimize_initlocals (MonoCompile *cfg)
{
MonoBitSet *used;
MonoInst *ins;
MonoBasicBlock *initlocals_bb;
used = mono_bitset_new (cfg->next_vreg + 1, 0);
mono_bitset_clear_all (used);
initlocals_bb = cfg->bb_entry->next_bb;
for (ins = initlocals_bb->code; ins; ins = ins->next) {
int num_sregs, i;
int sregs [MONO_MAX_SRC_REGS];
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (i = 0; i < num_sregs; ++i)
mono_bitset_set_fast (used, sregs [i]);
if (MONO_IS_STORE_MEMBASE (ins))
mono_bitset_set_fast (used, ins->dreg);
}
for (ins = initlocals_bb->code; ins; ins = ins->next) {
const char *spec = INS_INFO (ins->opcode);
/* Look for statements whose dest is not used in this bblock and not live on exit. */
if ((spec [MONO_INST_DEST] != ' ') && !MONO_IS_STORE_MEMBASE (ins)) {
MonoInst *var = get_vreg_to_inst (cfg, ins->dreg);
if (var && !mono_bitset_test_fast (used, ins->dreg) && !mono_bitset_test_fast (initlocals_bb->live_out_set, var->inst_c0) && (var != cfg->ret) && !(var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT))) {
//printf ("DEAD: "); mono_print_ins (ins);
if (cfg->disable_initlocals_opt_refs && var->type == STACK_OBJ)
continue;
if ((ins->opcode == OP_ICONST) || (ins->opcode == OP_I8CONST) || (ins->opcode == OP_R8CONST) || (ins->opcode == OP_R4CONST)) {
NULLIFY_INS (ins);
MONO_VARINFO (cfg, var->inst_c0)->spill_costs -= 1;
/*
* We should shorten the liveness interval of these vars as well, but
* don't have enough info to do that.
*/
}
}
}
}
g_free (used);
}
void
mono_linterval_add_range (MonoCompile *cfg, MonoLiveInterval *interval, int from, int to)
{
MonoLiveRange2 *prev_range, *next_range, *new_range;
g_assert (to >= from);
/* Optimize for extending the first interval backwards */
if (G_LIKELY (interval->range && (interval->range->from > from) && (interval->range->from == to))) {
interval->range->from = from;
return;
}
/* Find a place in the list for the new range */
prev_range = NULL;
next_range = interval->range;
while ((next_range != NULL) && (next_range->from <= from)) {
prev_range = next_range;
next_range = next_range->next;
}
if (prev_range && prev_range->to == from) {
/* Merge with previous */
prev_range->to = to;
} else if (next_range && next_range->from == to) {
/* Merge with previous */
next_range->from = from;
} else {
/* Insert it */
new_range = (MonoLiveRange2 *)mono_mempool_alloc (cfg->mempool, sizeof (MonoLiveRange2));
new_range->from = from;
new_range->to = to;
new_range->next = NULL;
if (prev_range)
prev_range->next = new_range;
else
interval->range = new_range;
if (next_range)
new_range->next = next_range;
else
interval->last_range = new_range;
}
/* FIXME: Merge intersecting ranges */
}
void
mono_linterval_print (MonoLiveInterval *interval)
{
MonoLiveRange2 *range;
for (range = interval->range; range != NULL; range = range->next)
printf ("[%x-%x] ", range->from, range->to);
}
void
mono_linterval_print_nl (MonoLiveInterval *interval)
{
mono_linterval_print (interval);
printf ("\n");
}
/**
* mono_linterval_convers:
*
* Return whenever INTERVAL covers the position POS.
*/
gboolean
mono_linterval_covers (MonoLiveInterval *interval, int pos)
{
MonoLiveRange2 *range;
for (range = interval->range; range != NULL; range = range->next) {
if (pos >= range->from && pos <= range->to)
return TRUE;
if (range->from > pos)
return FALSE;
}
return FALSE;
}
/**
* mono_linterval_get_intersect_pos:
*
* Determine whenever I1 and I2 intersect, and if they do, return the first
* point of intersection. Otherwise, return -1.
*/
gint32
mono_linterval_get_intersect_pos (MonoLiveInterval *i1, MonoLiveInterval *i2)
{
MonoLiveRange2 *r1, *r2;
/* FIXME: Optimize this */
for (r1 = i1->range; r1 != NULL; r1 = r1->next) {
for (r2 = i2->range; r2 != NULL; r2 = r2->next) {
if (r2->to > r1->from && r2->from < r1->to) {
if (r2->from <= r1->from)
return r1->from;
else
return r2->from;
}
}
}
return -1;
}
/**
* mono_linterval_split
*
* Split L at POS and store the newly created intervals into L1 and L2. POS becomes
* part of L2.
*/
void
mono_linterval_split (MonoCompile *cfg, MonoLiveInterval *interval, MonoLiveInterval **i1, MonoLiveInterval **i2, int pos)
{
MonoLiveRange2 *r;
g_assert (pos > interval->range->from && pos <= interval->last_range->to);
*i1 = (MonoLiveInterval *)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoLiveInterval));
*i2 = (MonoLiveInterval *)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoLiveInterval));
for (r = interval->range; r; r = r->next) {
if (pos > r->to) {
/* Add it to the first child */
mono_linterval_add_range (cfg, *i1, r->from, r->to);
} else if (pos > r->from && pos <= r->to) {
/* Split at pos */
mono_linterval_add_range (cfg, *i1, r->from, pos - 1);
mono_linterval_add_range (cfg, *i2, pos, r->to);
} else {
/* Add it to the second child */
mono_linterval_add_range (cfg, *i2, r->from, r->to);
}
}
}
#if 1
#define LIVENESS_DEBUG(a) do { if (cfg->verbose_level > 1) do { a; } while (0); } while (0)
#define ENABLE_LIVENESS_DEBUG 1
#else
#define LIVENESS_DEBUG(a)
#endif
#ifdef ENABLE_LIVENESS2
static void
update_liveness2 (MonoCompile *cfg, MonoInst *ins, gboolean set_volatile, int inst_num, gint32 *last_use)
{
const char *spec = INS_INFO (ins->opcode);
int sreg;
int num_sregs, i;
int sregs [MONO_MAX_SRC_REGS];
LIVENESS_DEBUG (printf ("\t%x: ", inst_num); mono_print_ins (ins));
if (ins->opcode == OP_NOP || ins->opcode == OP_IL_SEQ_POINT)
return;
/* DREG */
if ((spec [MONO_INST_DEST] != ' ') && get_vreg_to_inst (cfg, ins->dreg)) {
MonoInst *var = get_vreg_to_inst (cfg, ins->dreg);
int idx = var->inst_c0;
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
if (MONO_IS_STORE_MEMBASE (ins)) {
if (last_use [idx] == 0) {
LIVENESS_DEBUG (printf ("\tlast use of R%d set to %x\n", ins->dreg, inst_num));
last_use [idx] = inst_num;
}
} else {
if (last_use [idx] > 0) {
LIVENESS_DEBUG (printf ("\tadd range to R%d: [%x, %x)\n", ins->dreg, inst_num, last_use [idx]));
mono_linterval_add_range (cfg, vi->interval, inst_num, last_use [idx]);
last_use [idx] = 0;
}
else {
/* Try dead code elimination */
if (!cfg->disable_deadce_vars && (var != cfg->ret) && !(var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)) && ((ins->opcode == OP_ICONST) || (ins->opcode == OP_I8CONST) || (ins->opcode == OP_R8CONST)) && !(var->flags & MONO_INST_VOLATILE)) {
LIVENESS_DEBUG (printf ("\tdead def of R%d, eliminated\n", ins->dreg));
NULLIFY_INS (ins);
return;
} else {
int inst_num_add = 1;
MonoInst *next = ins->next;
while (next && next->opcode == OP_IL_SEQ_POINT) {
inst_num_add++;
next = next->next;
}
LIVENESS_DEBUG (printf ("\tdead def of R%d, add range to R%d: [%x, %x]\n", ins->dreg, ins->dreg, inst_num, inst_num + inst_num_add));
mono_linterval_add_range (cfg, vi->interval, inst_num, inst_num + inst_num_add);
}
}
}
}
/* SREGs */
num_sregs = mono_inst_get_src_registers (ins, sregs);
for (i = 0; i < num_sregs; ++i) {
sreg = sregs [i];
if ((spec [MONO_INST_SRC1 + i] != ' ') && get_vreg_to_inst (cfg, sreg)) {
MonoInst *var = get_vreg_to_inst (cfg, sreg);
int idx = var->inst_c0;
if (last_use [idx] == 0) {
LIVENESS_DEBUG (printf ("\tlast use of R%d set to %x\n", sreg, inst_num));
last_use [idx] = inst_num;
}
}
}
}
static void
mono_analyze_liveness2 (MonoCompile *cfg)
{
int bnum, idx, i, j, nins, max, max_vars, block_from, block_to, pos;
gint32 *last_use;
static guint32 disabled = -1;
if (disabled == -1)
disabled = g_hasenv ("DISABLED");
if (disabled)
return;
if (cfg->num_bblocks >= (1 << (32 - BB_ID_SHIFT - 1)))
/* Ranges would overflow */
return;
for (bnum = cfg->num_bblocks - 1; bnum >= 0; --bnum) {
MonoBasicBlock *bb = cfg->bblocks [bnum];
MonoInst *ins;
nins = 0;
for (nins = 0, ins = bb->code; ins; ins = ins->next, ++nins)
nins ++;
if (nins >= ((1 << BB_ID_SHIFT) - 1))
/* Ranges would overflow */
return;
}
LIVENESS_DEBUG (printf ("LIVENESS 2 %s\n", mono_method_full_name (cfg->method, TRUE)));
/*
if (strstr (cfg->method->name, "test_") != cfg->method->name)
return;
*/
max_vars = cfg->num_varinfo;
last_use = g_new0 (gint32, max_vars);
for (idx = 0; idx < max_vars; ++idx) {
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
vi->interval = (MonoLiveInterval *)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoLiveInterval));
}
/*
* Process bblocks in reverse order, so the addition of new live ranges
* to the intervals is faster.
*/
for (bnum = cfg->num_bblocks - 1; bnum >= 0; --bnum) {
MonoBasicBlock *bb = cfg->bblocks [bnum];
MonoInst *ins;
block_from = (bb->dfn << BB_ID_SHIFT) + 1; /* so pos > 0 */
if (bnum < cfg->num_bblocks - 1)
/* Beginning of the next bblock */
block_to = (cfg->bblocks [bnum + 1]->dfn << BB_ID_SHIFT) + 1;
else
block_to = (bb->dfn << BB_ID_SHIFT) + ((1 << BB_ID_SHIFT) - 1);
LIVENESS_DEBUG (printf ("LIVENESS BLOCK BB%d:\n", bb->block_num));
memset (last_use, 0, max_vars * sizeof (gint32));
/* For variables in bb->live_out, set last_use to block_to */
max = ((max_vars + (BITS_PER_CHUNK -1)) / BITS_PER_CHUNK);
for (j = 0; j < max; ++j) {
gsize bits_out;
int k;
bits_out = mono_bitset_get_fast (bb->live_out_set, j);
k = (j * BITS_PER_CHUNK);
while (bits_out) {
if (bits_out & 1) {
LIVENESS_DEBUG (printf ("Var R%d live at exit, set last_use to %x\n", cfg->varinfo [k]->dreg, block_to));
last_use [k] = block_to;
}
bits_out >>= 1;
k ++;
}
}
if (cfg->ret)
last_use [cfg->ret->inst_c0] = block_to;
pos = block_from + 1;
MONO_BB_FOR_EACH_INS (bb, ins) pos++;
/* Process instructions backwards */
MONO_BB_FOR_EACH_INS_REVERSE (bb, ins) {
update_liveness2 (cfg, ins, FALSE, pos, last_use);
pos--;
}
for (idx = 0; idx < max_vars; ++idx) {
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
if (last_use [idx] != 0) {
/* Live at exit, not written -> live on enter */
LIVENESS_DEBUG (printf ("Var R%d live at enter, add range to R%d: [%x, %x)\n", cfg->varinfo [idx]->dreg, cfg->varinfo [idx]->dreg, block_from, last_use [idx]));
mono_linterval_add_range (cfg, vi->interval, block_from, last_use [idx]);
}
}
}
/*
* Arguments need to have their live ranges extended to the beginning of
* the method to account for the arg reg/memory -> global register copies
* in the prolog (bug #74992).
*/
for (i = 0; i < max_vars; i ++) {
MonoMethodVar *vi = MONO_VARINFO (cfg, i);
if (cfg->varinfo [vi->idx]->opcode == OP_ARG)
mono_linterval_add_range (cfg, vi->interval, 0, 1);
}
#if 0
for (idx = 0; idx < max_vars; ++idx) {
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
LIVENESS_DEBUG (printf ("LIVENESS R%d: ", cfg->varinfo [idx]->dreg));
LIVENESS_DEBUG (mono_linterval_print (vi->interval));
LIVENESS_DEBUG (printf ("\n"));
}
#endif
g_free (last_use);
}
#endif
static void
update_liveness_gc (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins, gint32 *last_use, MonoMethodVar **vreg_to_varinfo, GSList **callsites)
{
if (ins->opcode == OP_GC_LIVENESS_DEF || ins->opcode == OP_GC_LIVENESS_USE) {
int vreg = ins->inst_c1;
MonoMethodVar *vi = vreg_to_varinfo [vreg];
int idx = vi->idx;
int pc_offset = ins->backend.pc_offset;
LIVENESS_DEBUG (printf ("\t%x: ", pc_offset); mono_print_ins (ins));
if (ins->opcode == OP_GC_LIVENESS_DEF) {
if (last_use [idx] > 0) {
LIVENESS_DEBUG (printf ("\tadd range to R%d: [%x, %x)\n", vreg, pc_offset, last_use [idx]));
last_use [idx] = 0;
}
} else {
if (last_use [idx] == 0) {
LIVENESS_DEBUG (printf ("\tlast use of R%d set to %x\n", vreg, pc_offset));
last_use [idx] = pc_offset;
}
}
} else if (ins->opcode == OP_GC_PARAM_SLOT_LIVENESS_DEF) {
GCCallSite *last;
/* Add it to the last callsite */
g_assert (*callsites);
last = (GCCallSite *)(*callsites)->data;
last->param_slots = g_slist_prepend_mempool (cfg->mempool, last->param_slots, ins);
} else if (ins->flags & MONO_INST_GC_CALLSITE) {
GCCallSite *callsite = (GCCallSite *)mono_mempool_alloc0 (cfg->mempool, sizeof (GCCallSite));
int i;
LIVENESS_DEBUG (printf ("\t%x: ", ins->backend.pc_offset); mono_print_ins (ins));
LIVENESS_DEBUG (printf ("\t\tlive: "));
callsite->bb = bb;
callsite->liveness = (guint8 *)mono_mempool_alloc0 (cfg->mempool, ALIGN_TO (cfg->num_varinfo, 8) / 8);
callsite->pc_offset = ins->backend.pc_offset;
for (i = 0; i < cfg->num_varinfo; ++i) {
if (last_use [i] != 0) {
LIVENESS_DEBUG (printf ("R%d", MONO_VARINFO (cfg, i)->vreg));
callsite->liveness [i / 8] |= (1 << (i % 8));
}
}
LIVENESS_DEBUG (printf ("\n"));
*callsites = g_slist_prepend_mempool (cfg->mempool, *callsites, callsite);
}
}
static int
get_vreg_from_var (MonoCompile *cfg, MonoInst *var)
{
if (var->opcode == OP_REGVAR)
/* dreg contains a hreg, but inst_c0 still contains the var index */
return MONO_VARINFO (cfg, var->inst_c0)->vreg;
else
/* dreg still contains the vreg */
return var->dreg;
}
/*
* mono_analyze_liveness_gc:
*
* Compute liveness bitmaps for each call site.
* This function is a modified version of mono_analyze_liveness2 ().
*/
void
mono_analyze_liveness_gc (MonoCompile *cfg)
{
int idx, i, j, nins, max, max_vars, block_from, block_to, pos, reverse_len;
gint32 *last_use;
MonoInst **reverse;
MonoMethodVar **vreg_to_varinfo = NULL;
MonoBasicBlock *bb;
GSList *callsites;
LIVENESS_DEBUG (printf ("\n------------ GC LIVENESS: ----------\n"));
max_vars = cfg->num_varinfo;
last_use = g_new0 (gint32, max_vars);
/*
* var->inst_c0 no longer contains the variable index, so compute a mapping now.
*/
vreg_to_varinfo = g_new0 (MonoMethodVar*, cfg->next_vreg);
for (idx = 0; idx < max_vars; ++idx) {
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
vreg_to_varinfo [vi->vreg] = vi;
}
reverse_len = 1024;
reverse = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * reverse_len);
for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
MonoInst *ins;
block_from = bb->real_native_offset;
block_to = bb->native_offset + bb->native_length;
LIVENESS_DEBUG (printf ("GC LIVENESS BB%d:\n", bb->block_num));
if (!bb->code)
continue;
memset (last_use, 0, max_vars * sizeof (gint32));
/* For variables in bb->live_out, set last_use to block_to */
max = ((max_vars + (BITS_PER_CHUNK -1)) / BITS_PER_CHUNK);
for (j = 0; j < max; ++j) {
gsize bits_out;
int k;
if (!bb->live_out_set)
/* The variables used in this bblock are volatile anyway */
continue;
bits_out = mono_bitset_get_fast (bb->live_out_set, j);
k = (j * BITS_PER_CHUNK);
while (bits_out) {
if ((bits_out & 1) && cfg->varinfo [k]->flags & MONO_INST_GC_TRACK) {
int vreg = get_vreg_from_var (cfg, cfg->varinfo [k]);
LIVENESS_DEBUG (printf ("Var R%d live at exit, last_use set to %x.\n", vreg, block_to));
last_use [k] = block_to;
}
bits_out >>= 1;
k ++;
}
}
for (nins = 0, pos = block_from, ins = bb->code; ins; ins = ins->next, ++nins, ++pos) {
if (nins >= reverse_len) {
int new_reverse_len = reverse_len * 2;
MonoInst **new_reverse = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * new_reverse_len);
memcpy (new_reverse, reverse, sizeof (MonoInst*) * reverse_len);
reverse = new_reverse;
reverse_len = new_reverse_len;
}
reverse [nins] = ins;
}
/* Process instructions backwards */
callsites = NULL;
for (i = nins - 1; i >= 0; --i) {
MonoInst *ins = (MonoInst*)reverse [i];
update_liveness_gc (cfg, bb, ins, last_use, vreg_to_varinfo, &callsites);
}
/* The callsites should already be sorted by pc offset because we added them backwards */
bb->gc_callsites = callsites;
}
g_free (last_use);
g_free (vreg_to_varinfo);
}
#else /* !DISABLE_JIT */
MONO_EMPTY_SOURCE_FILE (liveness);
#endif /* !DISABLE_JIT */
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/s390x/Lcreate_addr_space.c | #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gcreate_addr_space.c"
#endif
| #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gcreate_addr_space.c"
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./docs/workflow/testing/coreclr/automated-stress-testing-diagnostic-server.md | # AutoTrace:
> see: `src/vm/autotrace.h|cpp` for the code
AutoTrace is used to run automated testing of the Diagnostic Server based tracing and specifically
EventPipe. The feature itself is enabled via the feature flag `-DFEATURE_AUTO_TRACE`.
## Mechanism:
AutoTrace injects a waitable event into the startup path of the runtime and waits on that event until
some number of Diagnostics IPC (see: Diagnostics IPC in the dotnet/diagnostics repo) connections have occurred.
The runtime then creates some number of processes using a supplied path that typically are Diagnostics IPC based tracers.
Once all the tracers have connected to the server, the event will be signaled and execution will continue as normal.
## Use:
Two environment variables dictate behavior:
- `COMPlus_AutoTrace_N_Tracers`: The number of tracers to create. Should be a number in `[0,64]` where `0` will bypass the wait for attach.
- `COMPlus_AutoTrace_Command`: The path to the executable to be invoked. Typically this will be a `run.sh|cmd` script.
> (NB: you should `cd` into the directory you intend to execute `COMPlus_AutoTrace_Command` from as the first line of the script.)
Once turned on, AutoTrace will run the specified command `COMPlus_AutoTrace_N_Tracers` times.
| # AutoTrace:
> see: `src/vm/autotrace.h|cpp` for the code
AutoTrace is used to run automated testing of the Diagnostic Server based tracing and specifically
EventPipe. The feature itself is enabled via the feature flag `-DFEATURE_AUTO_TRACE`.
## Mechanism:
AutoTrace injects a waitable event into the startup path of the runtime and waits on that event until
some number of Diagnostics IPC (see: Diagnostics IPC in the dotnet/diagnostics repo) connections have occurred.
The runtime then creates some number of processes using a supplied path that typically are Diagnostics IPC based tracers.
Once all the tracers have connected to the server, the event will be signaled and execution will continue as normal.
## Use:
Two environment variables dictate behavior:
- `COMPlus_AutoTrace_N_Tracers`: The number of tracers to create. Should be a number in `[0,64]` where `0` will bypass the wait for attach.
- `COMPlus_AutoTrace_Command`: The path to the executable to be invoked. Typically this will be a `run.sh|cmd` script.
> (NB: you should `cd` into the directory you intend to execute `COMPlus_AutoTrace_Command` from as the first line of the script.)
Once turned on, AutoTrace will run the specified command `COMPlus_AutoTrace_N_Tracers` times.
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/hppa/Gcreate_addr_space.c | /* libunwind - a platform-independent unwind library
Copyright (C) 2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <stdlib.h>
#include "unwind_i.h"
unw_addr_space_t
unw_create_addr_space (unw_accessors_t *a, int byte_order)
{
#ifdef UNW_LOCAL_ONLY
return NULL;
#else
unw_addr_space_t as;
/*
* hppa supports only big-endian.
*/
if (byte_order != 0 && byte_order != UNW_BIG_ENDIAN)
return NULL;
as = malloc (sizeof (*as));
if (!as)
return NULL;
memset (as, 0, sizeof (*as));
as->acc = *a;
return as;
#endif
}
| /* libunwind - a platform-independent unwind library
Copyright (C) 2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <stdlib.h>
#include "unwind_i.h"
unw_addr_space_t
unw_create_addr_space (unw_accessors_t *a, int byte_order)
{
#ifdef UNW_LOCAL_ONLY
return NULL;
#else
unw_addr_space_t as;
/*
* hppa supports only big-endian.
*/
if (byte_order != 0 && byte_order != UNW_BIG_ENDIAN)
return NULL;
as = malloc (sizeof (*as));
if (!as)
return NULL;
memset (as, 0, sizeof (*as));
as->acc = *a;
return as;
#endif
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/metadata/icall.c | /**
* \file
*
* Authors:
* Dietmar Maurer ([email protected])
* Paolo Molaro ([email protected])
* Patrik Torstensson ([email protected])
* Marek Safar ([email protected])
* Aleksey Kliger ([email protected])
*
* Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
* Copyright 2004-2009 Novell, Inc (http://www.novell.com)
* Copyright 2011-2015 Xamarin Inc (http://www.xamarin.com).
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#if defined(TARGET_WIN32) || defined(HOST_WIN32)
#include <stdio.h>
#endif
#include <glib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#if defined (HAVE_WCHAR_H)
#include <wchar.h>
#endif
#include "mono/metadata/icall-internals.h"
#include "mono/utils/mono-membar.h"
#include <mono/metadata/object.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/monitor.h>
#include <mono/metadata/reflection.h>
#include <mono/metadata/image-internals.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/assembly-internals.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/exception-internals.h>
#include <mono/metadata/w32file.h>
#include <mono/metadata/mono-endian.h>
#include <mono/metadata/tokentype.h>
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/metadata-update.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/class-init.h>
#include <mono/metadata/reflection-internals.h>
#include <mono/metadata/marshal.h>
#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-gc.h>
#include <mono/metadata/appdomain-icalls.h>
#include <mono/metadata/string-icalls.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/cil-coff.h>
#include <mono/metadata/mono-perfcounters.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-ptr-array.h>
#include <mono/metadata/verify-internals.h>
#include <mono/metadata/runtime.h>
#include <mono/metadata/seq-points-data.h>
#include <mono/metadata/icall-table.h>
#include <mono/metadata/handle.h>
#include <mono/metadata/w32event.h>
#include <mono/metadata/abi-details.h>
#include <mono/metadata/loader-internals.h>
#include <mono/utils/monobitset.h>
#include <mono/utils/mono-time.h>
#include <mono/utils/mono-proclib.h>
#include <mono/utils/mono-string.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-digest.h>
#include <mono/utils/bsearch.h>
#include <mono/utils/mono-os-mutex.h>
#include <mono/utils/mono-threads.h>
#include <mono/metadata/w32error.h>
#include <mono/utils/w32api.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-math.h>
#if !defined(HOST_WIN32) && defined(HAVE_SYS_UTSNAME_H)
#include <sys/utsname.h>
#endif
#if defined(HOST_WIN32)
#include <windows.h>
#endif
#include "icall-decl.h"
#include "mono/utils/mono-threads-coop.h"
#include "mono/metadata/icall-signatures.h"
#include "mono/utils/mono-signal-handler.h"
#if _MSC_VER
#pragma warning(disable:4047) // FIXME differs in levels of indirection
#endif
//#define MONO_DEBUG_ICALLARRAY
// Inline with CoreCLR heuristics, https://github.com/dotnet/runtime/blob/69e114c1abf91241a0eeecf1ecceab4711b8aa62/src/coreclr/vm/threads.cpp#L6408.
// Minimum stack size should be sufficient to allow a typical non-recursive call chain to execute,
// including potential exception handling and garbage collection. Used for probing for available
// stack space through RuntimeHelpers.EnsureSufficientExecutionStack.
#if TARGET_SIZEOF_VOID_P == 8
#define MONO_MIN_EXECUTION_STACK_SIZE (128 * 1024)
#else
#define MONO_MIN_EXECUTION_STACK_SIZE (64 * 1024)
#endif
#ifdef MONO_DEBUG_ICALLARRAY
static char debug_icallarray; // 0:uninitialized 1:true 2:false
static gboolean
icallarray_print_enabled (void)
{
if (!debug_icallarray)
debug_icallarray = MONO_TRACE_IS_TRACED (G_LOG_LEVEL_DEBUG, MONO_TRACE_ICALLARRAY) ? 1 : 2;
return debug_icallarray == 1;
}
static void
icallarray_print (const char *format, ...)
{
if (!icallarray_print_enabled ())
return;
va_list args;
va_start (args, format);
g_printv (format, args);
va_end (args);
}
#else
#define icallarray_print_enabled() (FALSE)
#define icallarray_print(...) /* nothing */
#endif
/* Lazy class loading functions */
static GENERATE_GET_CLASS_WITH_CACHE (module, "System.Reflection", "Module")
static void
array_set_value_impl (MonoArrayHandle arr, MonoObjectHandle value, guint32 pos, gboolean strict_enums, gboolean strict_signs, MonoError *error);
static MonoArrayHandle
type_array_from_modifiers (MonoType *type, int optional, MonoError *error);
static inline MonoBoolean
is_generic_parameter (MonoType *type)
{
return !m_type_is_byref (type) && (type->type == MONO_TYPE_VAR || type->type == MONO_TYPE_MVAR);
}
#ifdef HOST_WIN32
static void
mono_icall_make_platform_path (gchar *path)
{
for (size_t i = strlen (path); i > 0; i--)
if (path [i-1] == '\\')
path [i-1] = '/';
}
static const gchar *
mono_icall_get_file_path_prefix (const gchar *path)
{
if (*path == '/' && *(path + 1) == '/') {
return "file:";
} else {
return "file:///";
}
}
#else
static inline void
mono_icall_make_platform_path (gchar *path)
{
return;
}
static inline const gchar *
mono_icall_get_file_path_prefix (const gchar *path)
{
return "file://";
}
#endif /* HOST_WIN32 */
MonoJitICallInfos mono_jit_icall_info;
MonoObjectHandle
ves_icall_System_Array_GetValueImpl (MonoArrayHandle array, guint32 pos, MonoError *error)
{
MonoClass * const array_class = mono_handle_class (array);
MonoClass * const element_class = m_class_get_element_class (array_class);
if (m_class_is_native_pointer (element_class)) {
mono_error_set_not_supported (error, NULL);
return NULL_HANDLE;
}
if (m_class_is_valuetype (element_class)) {
gsize element_size = mono_array_element_size (array_class);
gpointer element_address = mono_array_addr_with_size_fast (MONO_HANDLE_RAW (array), element_size, (gsize)pos);
return mono_value_box_handle (element_class, element_address, error);
}
MonoObjectHandle result = mono_new_null ();
mono_handle_array_getref (result, array, pos);
return result;
}
void
ves_icall_System_Array_SetValueImpl (MonoArrayHandle arr, MonoObjectHandle value, guint32 pos, MonoError *error)
{
array_set_value_impl (arr, value, pos, TRUE, TRUE, error);
}
static inline void
set_invalid_cast (MonoError *error, MonoClass *src_class, MonoClass *dst_class)
{
mono_get_runtime_callbacks ()->set_cast_details (src_class, dst_class);
mono_error_set_invalid_cast (error);
}
void
ves_icall_System_Array_SetValueRelaxedImpl (MonoArrayHandle arr, MonoObjectHandle value, guint32 pos, MonoError *error)
{
array_set_value_impl (arr, value, pos, FALSE, FALSE, error);
}
// Copied from CoreCLR: https://github.com/dotnet/coreclr/blob/d3e39bc2f81e3dbf9e4b96347f62b49d8700336c/src/vm/invokeutil.cpp#L33
#define PT_Primitive 0x01000000
static const guint32 primitive_conversions [] = {
0x00, // MONO_TYPE_END
0x00, // MONO_TYPE_VOID
PT_Primitive | 0x0004, // MONO_TYPE_BOOLEAN
PT_Primitive | 0x3F88, // MONO_TYPE_CHAR (W = U2, CHAR, I4, U4, I8, U8, R4, R8)
PT_Primitive | 0x3550, // MONO_TYPE_I1 (W = I1, I2, I4, I8, R4, R8)
PT_Primitive | 0x3FE8, // MONO_TYPE_U1 (W = CHAR, U1, I2, U2, I4, U4, I8, U8, R4, R8)
PT_Primitive | 0x3540, // MONO_TYPE_I2 (W = I2, I4, I8, R4, R8)
PT_Primitive | 0x3F88, // MONO_TYPE_U2 (W = U2, CHAR, I4, U4, I8, U8, R4, R8)
PT_Primitive | 0x3500, // MONO_TYPE_I4 (W = I4, I8, R4, R8)
PT_Primitive | 0x3E00, // MONO_TYPE_U4 (W = U4, I8, R4, R8)
PT_Primitive | 0x3400, // MONO_TYPE_I8 (W = I8, R4, R8)
PT_Primitive | 0x3800, // MONO_TYPE_U8 (W = U8, R4, R8)
PT_Primitive | 0x3000, // MONO_TYPE_R4 (W = R4, R8)
PT_Primitive | 0x2000, // MONO_TYPE_R8 (W = R8)
};
// Copied from CoreCLR: https://github.com/dotnet/coreclr/blob/030a3ea9b8dbeae89c90d34441d4d9a1cf4a7de6/src/vm/invokeutil.h#L176
static
gboolean can_primitive_widen (MonoTypeEnum src_type, MonoTypeEnum dest_type)
{
if (dest_type > MONO_TYPE_R8 || src_type > MONO_TYPE_R8) {
return (MONO_TYPE_I == dest_type && MONO_TYPE_I == src_type) || (MONO_TYPE_U == dest_type && MONO_TYPE_U == src_type);
}
return ((1 << dest_type) & primitive_conversions [src_type]) != 0;
}
// Copied from CoreCLR: https://github.com/dotnet/coreclr/blob/eafa8648ebee92de1380278b15cd5c2b6ef11218/src/vm/array.cpp#L1406
static MonoTypeEnum
get_normalized_integral_array_element_type (MonoTypeEnum elementType)
{
// Array Primitive types such as E_T_I4 and E_T_U4 are interchangeable
// Enums with interchangeable underlying types are interchangable
// BOOL is NOT interchangeable with I1/U1, neither CHAR -- with I2/U2
switch (elementType) {
case MONO_TYPE_U1:
case MONO_TYPE_U2:
case MONO_TYPE_U4:
case MONO_TYPE_U8:
case MONO_TYPE_U:
return (MonoTypeEnum) (elementType - 1); // normalize to signed type
}
return elementType;
}
MonoBoolean
ves_icall_System_Array_CanChangePrimitive (MonoReflectionType *volatile* ref_src_type_handle, MonoReflectionType *volatile* ref_dst_type_handle, MonoBoolean reliable)
{
MonoReflectionType* const ref_src_type = *ref_src_type_handle;
MonoReflectionType* const ref_dst_type = *ref_dst_type_handle;
MonoType *src_type = ref_src_type->type;
MonoType *dst_type = ref_dst_type->type;
g_assert (mono_type_is_primitive (src_type));
g_assert (mono_type_is_primitive (dst_type));
MonoTypeEnum normalized_src_type = get_normalized_integral_array_element_type (src_type->type);
MonoTypeEnum normalized_dst_type = get_normalized_integral_array_element_type (dst_type->type);
// Allow conversions like int <-> uint
if (normalized_src_type == normalized_dst_type) {
return TRUE;
}
// Widening is not allowed if reliable is true.
if (reliable) {
return FALSE;
}
// NOTE we don't use normalized types here so int -> ulong will be false
// see https://github.com/dotnet/coreclr/pull/25209#issuecomment-505952295
return can_primitive_widen (src_type->type, dst_type->type);
}
static void
array_set_value_impl (MonoArrayHandle arr_handle, MonoObjectHandle value_handle, guint32 pos, gboolean strict_enums, gboolean strict_signs, MonoError *error)
{
MonoClass *ac, *vc, *ec;
gint32 esize, vsize;
gpointer *ea = NULL, *va = NULL;
guint64 u64 = 0;
gint64 i64 = 0;
gdouble r64 = 0;
gboolean castOk = FALSE;
gboolean et_isenum = FALSE;
gboolean vt_isenum = FALSE;
if (!MONO_HANDLE_IS_NULL (value_handle))
vc = mono_handle_class (value_handle);
else
vc = NULL;
ac = mono_handle_class (arr_handle);
ec = m_class_get_element_class (ac);
esize = mono_array_element_size (ac);
if (mono_class_is_nullable (ec)) {
if (vc && m_class_is_primitive (vc) && vc != m_class_get_nullable_elem_class (ec)) {
// T -> Nullable<T> T must be exact
set_invalid_cast (error, vc, ec);
goto leave;
}
MONO_ENTER_NO_SAFEPOINTS;
ea = (gpointer*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (arr_handle), esize, pos);
if (!MONO_HANDLE_IS_NULL (value_handle))
va = (gpointer*) mono_object_unbox_internal (MONO_HANDLE_RAW (value_handle));
mono_nullable_init_unboxed ((guint8*)ea, va, ec);
MONO_EXIT_NO_SAFEPOINTS;
goto leave;
}
if (MONO_HANDLE_IS_NULL (value_handle)) {
MONO_ENTER_NO_SAFEPOINTS;
ea = (gpointer*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (arr_handle), esize, pos);
mono_gc_bzero_atomic (ea, esize);
MONO_EXIT_NO_SAFEPOINTS;
goto leave;
}
#define WIDENING_MSG NULL
#define WIDENING_ARG NULL
#define NO_WIDENING_CONVERSION G_STMT_START{ \
mono_error_set_argument (error, WIDENING_ARG, WIDENING_MSG); \
break; \
}G_STMT_END
#define CHECK_WIDENING_CONVERSION(extra) G_STMT_START{ \
if (esize < vsize + (extra)) { \
mono_error_set_argument (error, WIDENING_ARG, WIDENING_MSG); \
break; \
} \
}G_STMT_END
#define INVALID_CAST G_STMT_START{ \
mono_get_runtime_callbacks ()->set_cast_details (vc, ec); \
mono_error_set_invalid_cast (error); \
break; \
}G_STMT_END
MonoTypeEnum et;
et = m_class_get_byval_arg (ec)->type;
MonoTypeEnum vt;
vt = m_class_get_byval_arg (vc)->type;
/* Check element (destination) type. */
switch (et) {
case MONO_TYPE_STRING:
switch (vt) {
case MONO_TYPE_STRING:
break;
default:
INVALID_CAST;
}
break;
case MONO_TYPE_BOOLEAN:
switch (vt) {
case MONO_TYPE_BOOLEAN:
break;
case MONO_TYPE_CHAR:
case MONO_TYPE_U1:
case MONO_TYPE_U2:
case MONO_TYPE_U4:
case MONO_TYPE_U8:
case MONO_TYPE_I1:
case MONO_TYPE_I2:
case MONO_TYPE_I4:
case MONO_TYPE_I8:
case MONO_TYPE_R4:
case MONO_TYPE_R8:
NO_WIDENING_CONVERSION;
break;
default:
INVALID_CAST;
}
break;
default:
break;
}
if (!is_ok (error))
goto leave;
castOk = mono_object_handle_isinst_mbyref_raw (value_handle, ec, error);
if (!is_ok (error))
goto leave;
if (!m_class_is_valuetype (ec)) {
if (!castOk)
INVALID_CAST;
if (is_ok (error))
MONO_HANDLE_ARRAY_SETREF (arr_handle, pos, value_handle);
goto leave;
}
if (castOk) {
MONO_ENTER_NO_SAFEPOINTS;
ea = (gpointer*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (arr_handle), esize, pos);
va = (gpointer*) mono_object_unbox_internal (MONO_HANDLE_RAW (value_handle));
if (m_class_has_references (ec))
mono_value_copy_internal (ea, va, ec);
else
mono_gc_memmove_atomic (ea, va, esize);
MONO_EXIT_NO_SAFEPOINTS;
goto leave;
}
if (!m_class_is_valuetype (vc))
INVALID_CAST;
if (!is_ok (error))
goto leave;
vsize = mono_class_value_size (vc, NULL);
et_isenum = et == MONO_TYPE_VALUETYPE && m_class_is_enumtype (m_class_get_byval_arg (ec)->data.klass);
vt_isenum = vt == MONO_TYPE_VALUETYPE && m_class_is_enumtype (m_class_get_byval_arg (vc)->data.klass);
if (strict_enums && et_isenum && !vt_isenum) {
INVALID_CAST;
goto leave;
}
if (et_isenum)
et = mono_class_enum_basetype_internal (m_class_get_byval_arg (ec)->data.klass)->type;
if (vt_isenum)
vt = mono_class_enum_basetype_internal (m_class_get_byval_arg (vc)->data.klass)->type;
// Treat MONO_TYPE_U/I as MONO_TYPE_U8/I8/U4/I4
#if SIZEOF_VOID_P == 8
vt = vt == MONO_TYPE_U ? MONO_TYPE_U8 : (vt == MONO_TYPE_I ? MONO_TYPE_I8 : vt);
et = et == MONO_TYPE_U ? MONO_TYPE_U8 : (et == MONO_TYPE_I ? MONO_TYPE_I8 : et);
#else
vt = vt == MONO_TYPE_U ? MONO_TYPE_U4 : (vt == MONO_TYPE_I ? MONO_TYPE_I4 : vt);
et = et == MONO_TYPE_U ? MONO_TYPE_U4 : (et == MONO_TYPE_I ? MONO_TYPE_I4 : et);
#endif
#define ASSIGN_UNSIGNED(etype) G_STMT_START{\
switch (vt) { \
case MONO_TYPE_U1: \
case MONO_TYPE_U2: \
case MONO_TYPE_U4: \
case MONO_TYPE_U8: \
case MONO_TYPE_CHAR: \
CHECK_WIDENING_CONVERSION(0); \
*(etype *) ea = (etype) u64; \
break; \
/* You can't assign a signed value to an unsigned array. */ \
case MONO_TYPE_I1: \
case MONO_TYPE_I2: \
case MONO_TYPE_I4: \
case MONO_TYPE_I8: \
if (!strict_signs) { \
CHECK_WIDENING_CONVERSION(0); \
*(etype *) ea = (etype) i64; \
break; \
} \
/* You can't assign a floating point number to an integer array. */ \
case MONO_TYPE_R4: \
case MONO_TYPE_R8: \
NO_WIDENING_CONVERSION; \
break; \
default: \
INVALID_CAST; \
break; \
} \
}G_STMT_END
#define ASSIGN_SIGNED(etype) G_STMT_START{\
switch (vt) { \
case MONO_TYPE_I1: \
case MONO_TYPE_I2: \
case MONO_TYPE_I4: \
case MONO_TYPE_I8: \
CHECK_WIDENING_CONVERSION(0); \
*(etype *) ea = (etype) i64; \
break; \
/* You can assign an unsigned value to a signed array if the array's */ \
/* element size is larger than the value size. */ \
case MONO_TYPE_U1: \
case MONO_TYPE_U2: \
case MONO_TYPE_U4: \
case MONO_TYPE_U8: \
case MONO_TYPE_CHAR: \
CHECK_WIDENING_CONVERSION(strict_signs ? 1 : 0); \
*(etype *) ea = (etype) u64; \
break; \
/* You can't assign a floating point number to an integer array. */ \
case MONO_TYPE_R4: \
case MONO_TYPE_R8: \
NO_WIDENING_CONVERSION; \
break; \
default: \
INVALID_CAST; \
break; \
} \
}G_STMT_END
#define ASSIGN_REAL(etype) G_STMT_START{\
switch (vt) { \
case MONO_TYPE_R4: \
case MONO_TYPE_R8: \
CHECK_WIDENING_CONVERSION(0); \
*(etype *) ea = (etype) r64; \
break; \
/* All integer values fit into a floating point array, so we don't */ \
/* need to CHECK_WIDENING_CONVERSION here. */ \
case MONO_TYPE_I1: \
case MONO_TYPE_I2: \
case MONO_TYPE_I4: \
case MONO_TYPE_I8: \
*(etype *) ea = (etype) i64; \
break; \
case MONO_TYPE_U1: \
case MONO_TYPE_U2: \
case MONO_TYPE_U4: \
case MONO_TYPE_U8: \
case MONO_TYPE_CHAR: \
*(etype *) ea = (etype) u64; \
break; \
default: \
INVALID_CAST; \
break; \
} \
}G_STMT_END
MONO_ENTER_NO_SAFEPOINTS;
g_assert (!MONO_HANDLE_IS_NULL (value_handle));
g_assert (m_class_is_valuetype (vc));
va = (gpointer*) mono_object_unbox_internal (MONO_HANDLE_RAW (value_handle));
ea = (gpointer*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (arr_handle), esize, pos);
switch (vt) {
case MONO_TYPE_U1:
u64 = *(guint8 *) va;
break;
case MONO_TYPE_U2:
u64 = *(guint16 *) va;
break;
case MONO_TYPE_U4:
u64 = *(guint32 *) va;
break;
case MONO_TYPE_U8:
u64 = *(guint64 *) va;
break;
case MONO_TYPE_I1:
i64 = *(gint8 *) va;
break;
case MONO_TYPE_I2:
i64 = *(gint16 *) va;
break;
case MONO_TYPE_I4:
i64 = *(gint32 *) va;
break;
case MONO_TYPE_I8:
i64 = *(gint64 *) va;
break;
case MONO_TYPE_R4:
r64 = *(gfloat *) va;
break;
case MONO_TYPE_R8:
r64 = *(gdouble *) va;
break;
case MONO_TYPE_CHAR:
u64 = *(guint16 *) va;
break;
case MONO_TYPE_BOOLEAN:
/* Boolean is only compatible with itself. */
switch (et) {
case MONO_TYPE_CHAR:
case MONO_TYPE_U1:
case MONO_TYPE_U2:
case MONO_TYPE_U4:
case MONO_TYPE_U8:
case MONO_TYPE_I1:
case MONO_TYPE_I2:
case MONO_TYPE_I4:
case MONO_TYPE_I8:
case MONO_TYPE_R4:
case MONO_TYPE_R8:
NO_WIDENING_CONVERSION;
break;
default:
INVALID_CAST;
}
break;
default:
break;
}
/* If we can't do a direct copy, let's try a widening conversion. */
if (is_ok (error)) {
switch (et) {
case MONO_TYPE_CHAR:
ASSIGN_UNSIGNED (guint16);
break;
case MONO_TYPE_U1:
ASSIGN_UNSIGNED (guint8);
break;
case MONO_TYPE_U2:
ASSIGN_UNSIGNED (guint16);
break;
case MONO_TYPE_U4:
ASSIGN_UNSIGNED (guint32);
break;
case MONO_TYPE_U8:
ASSIGN_UNSIGNED (guint64);
break;
case MONO_TYPE_I1:
ASSIGN_SIGNED (gint8);
break;
case MONO_TYPE_I2:
ASSIGN_SIGNED (gint16);
break;
case MONO_TYPE_I4:
ASSIGN_SIGNED (gint32);
break;
case MONO_TYPE_I8:
ASSIGN_SIGNED (gint64);
break;
case MONO_TYPE_R4:
ASSIGN_REAL (gfloat);
break;
case MONO_TYPE_R8:
ASSIGN_REAL (gdouble);
break;
default:
INVALID_CAST;
}
}
MONO_EXIT_NO_SAFEPOINTS;
#undef INVALID_CAST
#undef NO_WIDENING_CONVERSION
#undef CHECK_WIDENING_CONVERSION
#undef ASSIGN_UNSIGNED
#undef ASSIGN_SIGNED
#undef ASSIGN_REAL
leave:
return;
}
void
ves_icall_System_Array_InternalCreate (MonoArray *volatile* result, MonoType* type, gint32 rank, gint32* pLengths, gint32* pLowerBounds)
{
ERROR_DECL (error);
MonoClass* klass = mono_class_from_mono_type_internal (type);
if (!mono_class_init_checked (klass, error))
goto exit;
if (m_class_get_byval_arg (m_class_get_element_class (klass))->type == MONO_TYPE_VOID) {
mono_error_set_not_supported (error, "Arrays of System.Void are not supported.");
goto exit;
}
if (m_type_is_byref (type) || m_class_is_byreflike (klass)) {
mono_error_set_not_supported (error, NULL);
goto exit;
}
MonoGenericClass *gklass;
gklass = mono_class_try_get_generic_class (klass);
if (is_generic_parameter (type) || mono_class_is_gtd (klass) || (gklass && gklass->context.class_inst->is_open)) {
mono_error_set_not_supported (error, NULL);
goto exit;
}
/* vectors are not the same as one dimensional arrays with non-zero bounds */
gboolean bounded;
bounded = pLowerBounds != NULL && rank == 1 && pLowerBounds [0] != 0;
MonoClass* aklass;
aklass = mono_class_create_bounded_array (klass, rank, bounded);
uintptr_t aklass_rank;
aklass_rank = m_class_get_rank (aklass);
uintptr_t* sizes;
sizes = g_newa (uintptr_t, aklass_rank * 2);
intptr_t* lower_bounds;
lower_bounds = (intptr_t*)(sizes + aklass_rank);
// Copy lengths and lower_bounds from gint32 to [u]intptr_t.
for (uintptr_t i = 0; i < aklass_rank; ++i) {
if (pLowerBounds != NULL) {
lower_bounds [i] = pLowerBounds [i];
if ((gint64) pLowerBounds [i] + (gint64) pLengths [i] > G_MAXINT32) {
mono_error_set_argument_out_of_range (error, NULL, "Length + bound must not exceed Int32.MaxValue.");
goto exit;
}
} else {
lower_bounds [i] = 0;
}
sizes [i] = pLengths [i];
}
*result = mono_array_new_full_checked (aklass, sizes, lower_bounds, error);
exit:
mono_error_set_pending_exception (error);
}
gint32
ves_icall_System_Array_GetCorElementTypeOfElementType (MonoArrayHandle arr, MonoError *error)
{
MonoType *type = mono_type_get_underlying_type (m_class_get_byval_arg (m_class_get_element_class (mono_handle_class (arr))));
return type->type;
}
gint32
ves_icall_System_Array_IsValueOfElementType (MonoArrayHandle arr, MonoObjectHandle obj, MonoError *error)
{
return m_class_get_element_class (mono_handle_class (arr)) == mono_handle_class (obj);
}
static mono_array_size_t
mono_array_get_length (MonoArrayHandle arr, gint32 dimension, MonoError *error)
{
if (dimension < 0 || dimension >= m_class_get_rank (mono_handle_class (arr))) {
mono_error_set_index_out_of_range (error);
return 0;
}
return MONO_HANDLE_GETVAL (arr, bounds) ? MONO_HANDLE_GETVAL (arr, bounds [dimension].length)
: MONO_HANDLE_GETVAL (arr, max_length);
}
gint32
ves_icall_System_Array_GetLength (MonoArrayHandle arr, gint32 dimension, MonoError *error)
{
icallarray_print ("%s arr:%p dimension:%d\n", __func__, MONO_HANDLE_RAW (arr), (int)dimension);
mono_array_size_t const length = mono_array_get_length (arr, dimension, error);
if (length > G_MAXINT32) {
mono_error_set_overflow (error);
return 0;
}
return (gint32)length;
}
gint32
ves_icall_System_Array_GetLowerBound (MonoArrayHandle arr, gint32 dimension, MonoError *error)
{
icallarray_print ("%s arr:%p dimension:%d\n", __func__, MONO_HANDLE_RAW (arr), (int)dimension);
if (dimension < 0 || dimension >= m_class_get_rank (mono_handle_class (arr))) {
mono_error_set_index_out_of_range (error);
return 0;
}
return MONO_HANDLE_GETVAL (arr, bounds) ? MONO_HANDLE_GETVAL (arr, bounds [dimension].lower_bound)
: 0;
}
MonoBoolean
ves_icall_System_Array_FastCopy (MonoArrayHandle source, int source_idx, MonoArrayHandle dest, int dest_idx, int length, MonoError *error)
{
MonoVTable * const src_vtable = MONO_HANDLE_GETVAL (source, obj.vtable);
MonoVTable * const dest_vtable = MONO_HANDLE_GETVAL (dest, obj.vtable);
if (src_vtable->rank != dest_vtable->rank)
return FALSE;
MonoArrayBounds *source_bounds = MONO_HANDLE_GETVAL (source, bounds);
MonoArrayBounds *dest_bounds = MONO_HANDLE_GETVAL (dest, bounds);
for (int i = 0; i < src_vtable->rank; i++) {
if ((source_bounds && source_bounds [i].lower_bound > 0) ||
(dest_bounds && dest_bounds [i].lower_bound > 0))
return FALSE;
}
/* there's no integer overflow since mono_array_length_internal returns an unsigned integer */
if ((dest_idx + length > mono_array_handle_length (dest)) ||
(source_idx + length > mono_array_handle_length (source)))
return FALSE;
MonoClass * const src_class = m_class_get_element_class (src_vtable->klass);
MonoClass * const dest_class = m_class_get_element_class (dest_vtable->klass);
/*
* Handle common cases.
*/
/* Case1: object[] -> valuetype[] (ArrayList::ToArray)
We fallback to managed here since we need to typecheck each boxed valuetype before storing them in the dest array.
*/
if (src_class == mono_defaults.object_class && m_class_is_valuetype (dest_class))
return FALSE;
/* Check if we're copying a char[] <==> (u)short[] */
if (src_class != dest_class) {
if (m_class_is_valuetype (dest_class) || m_class_is_enumtype (dest_class) ||
m_class_is_valuetype (src_class) || m_class_is_valuetype (src_class))
return FALSE;
/* It's only safe to copy between arrays if we can ensure the source will always have a subtype of the destination. We bail otherwise. */
if (!mono_class_is_subclass_of_internal (src_class, dest_class, FALSE))
return FALSE;
if (m_class_is_native_pointer (src_class) || m_class_is_native_pointer (dest_class))
return FALSE;
}
if (m_class_is_valuetype (dest_class)) {
gsize const element_size = mono_array_element_size (MONO_HANDLE_GETVAL (source, obj.vtable->klass));
MONO_ENTER_NO_SAFEPOINTS; // gchandle would also work here, is slow, breaks profiler tests.
gconstpointer const source_addr =
mono_array_addr_with_size_fast (MONO_HANDLE_RAW (source), element_size, source_idx);
if (m_class_has_references (dest_class)) {
mono_value_copy_array_handle (dest, dest_idx, source_addr, length);
} else {
gpointer const dest_addr =
mono_array_addr_with_size_fast (MONO_HANDLE_RAW (dest), element_size, dest_idx);
mono_gc_memmove_atomic (dest_addr, source_addr, element_size * length);
}
MONO_EXIT_NO_SAFEPOINTS;
} else {
mono_array_handle_memcpy_refs (dest, dest_idx, source, source_idx, length);
}
return TRUE;
}
void
ves_icall_System_Array_GetGenericValue_icall (MonoArray **arr, guint32 pos, gpointer value)
{
icallarray_print ("%s arr:%p pos:%u value:%p\n", __func__, *arr, pos, value);
MONO_REQ_GC_UNSAFE_MODE; // because of gpointer value
MonoClass * const ac = mono_object_class (*arr);
gsize const esize = mono_array_element_size (ac);
gconstpointer * const ea = (gconstpointer*)((char*)(*arr)->vector + (pos * esize));
mono_gc_memmove_atomic (value, ea, esize);
}
void
ves_icall_System_Array_SetGenericValue_icall (MonoArray **arr, guint32 pos, gpointer value)
{
icallarray_print ("%s arr:%p pos:%u value:%p\n", __func__, *arr, pos, value);
MONO_REQ_GC_UNSAFE_MODE; // because of gpointer value
MonoClass * const ac = mono_object_class (*arr);
MonoClass * const ec = m_class_get_element_class (ac);
gsize const esize = mono_array_element_size (ac);
gpointer * const ea = (gpointer*)((char*)(*arr)->vector + (pos * esize));
if (MONO_TYPE_IS_REFERENCE (m_class_get_byval_arg (ec))) {
g_assert (esize == sizeof (gpointer));
mono_gc_wbarrier_generic_store_internal (ea, *(MonoObject **)value);
} else {
g_assert (m_class_is_inited (ec));
g_assert (esize == mono_class_value_size (ec, NULL));
if (m_class_has_references (ec))
mono_gc_wbarrier_value_copy_internal (ea, value, 1, ec);
else
mono_gc_memmove_atomic (ea, value, esize);
}
}
void
ves_icall_System_Runtime_RuntimeImports_Memmove (guint8 *destination, guint8 *source, size_t byte_count)
{
mono_gc_memmove_atomic (destination, source, byte_count);
}
void
ves_icall_System_Buffer_BulkMoveWithWriteBarrier (guint8 *destination, guint8 *source, size_t len, MonoType *type)
{
if (MONO_TYPE_IS_REFERENCE (type))
mono_gc_wbarrier_arrayref_copy_internal (destination, source, (guint)len);
else
mono_gc_wbarrier_value_copy_internal (destination, source, (guint)len, mono_class_from_mono_type_internal (type));
}
void
ves_icall_System_Runtime_RuntimeImports_ZeroMemory (guint8 *p, size_t byte_length)
{
memset (p, 0, byte_length);
}
gpointer
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetSpanDataFrom (MonoClassField *field_handle, MonoType_ptr targetTypeHandle, gpointer countPtr, MonoError *error)
{
gint32* count = (gint32*)countPtr;
MonoType *field_type = mono_field_get_type_checked (field_handle, error);
if (!field_type) {
mono_error_set_argument (error, "fldHandle", "fldHandle invalid");
return NULL;
}
if (!(field_type->attrs & FIELD_ATTRIBUTE_HAS_FIELD_RVA)) {
mono_error_set_argument_format (error, "field_handle", "Field '%s' doesn't have an RVA", mono_field_get_name (field_handle));
return NULL;
}
MonoType *type = targetTypeHandle;
if (MONO_TYPE_IS_REFERENCE (type) || type->type == MONO_TYPE_VALUETYPE) {
mono_error_set_argument (error, "array", "Cannot initialize array of non-primitive type");
return NULL;
}
int swizzle = 1;
int align;
#if G_BYTE_ORDER != G_LITTLE_ENDIAN
swizzle = mono_type_size (type, &align);
#endif
int dummy;
*count = mono_type_size (field_type, &dummy)/mono_type_size (type, &align);
return (gpointer)mono_field_get_rva (field_handle, swizzle);
}
void
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoArrayHandle array, MonoClassField *field_handle, MonoError *error)
{
MonoClass *klass = mono_handle_class (array);
guint32 size = mono_array_element_size (klass);
MonoType *type = mono_type_get_underlying_type (m_class_get_byval_arg (m_class_get_element_class (klass)));
int align;
const char *field_data;
if (MONO_TYPE_IS_REFERENCE (type) || type->type == MONO_TYPE_VALUETYPE) {
mono_error_set_argument (error, "array", "Cannot initialize array of non-primitive type");
return;
}
MonoType *field_type = mono_field_get_type_checked (field_handle, error);
if (!field_type)
return;
if (!(field_type->attrs & FIELD_ATTRIBUTE_HAS_FIELD_RVA)) {
mono_error_set_argument_format (error, "field_handle", "Field '%s' doesn't have an RVA", mono_field_get_name (field_handle));
return;
}
size *= MONO_HANDLE_GETVAL(array, max_length);
field_data = mono_field_get_data (field_handle);
if (size > mono_type_size (field_handle->type, &align)) {
mono_error_set_argument (error, "field_handle", "Field not large enough to fill array");
return;
}
#if G_BYTE_ORDER != G_LITTLE_ENDIAN
#define SWAP(n) { \
guint ## n *data = (guint ## n *) mono_array_addr_internal (MONO_HANDLE_RAW(array), char, 0); \
guint ## n *src = (guint ## n *) field_data; \
int i, \
nEnt = (size / sizeof(guint ## n)); \
\
for (i = 0; i < nEnt; i++) { \
data[i] = read ## n (&src[i]); \
} \
}
/* printf ("Initialize array with elements of %s type\n", klass->element_class->name); */
switch (type->type) {
case MONO_TYPE_CHAR:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
SWAP (16);
break;
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_R4:
SWAP (32);
break;
case MONO_TYPE_I8:
case MONO_TYPE_U8:
case MONO_TYPE_R8:
SWAP (64);
break;
default:
memcpy (mono_array_addr_internal (MONO_HANDLE_RAW(array), char, 0), field_data, size);
break;
}
#else
memcpy (mono_array_addr_internal (MONO_HANDLE_RAW(array), char, 0), field_data, size);
#endif
}
MonoObjectHandle
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue (MonoObjectHandle obj, MonoError *error)
{
if (MONO_HANDLE_IS_NULL (obj) || !m_class_is_valuetype (mono_handle_class (obj)))
return obj;
return mono_object_clone_handle (obj, error);
}
void
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor (MonoType *handle, MonoError *error)
{
MonoClass *klass;
MonoVTable *vtable;
MONO_CHECK_ARG_NULL (handle,);
klass = mono_class_from_mono_type_internal (handle);
MONO_CHECK_ARG (handle, klass,);
if (mono_class_is_gtd (klass))
return;
vtable = mono_class_vtable_checked (klass, error);
return_if_nok (error);
/* This will call the type constructor */
mono_runtime_class_init_full (vtable, error);
}
void
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunModuleConstructor (MonoImage *image, MonoError *error)
{
mono_image_check_for_module_cctor (image);
if (!image->has_module_cctor)
return;
MonoClass *module_klass = mono_class_get_checked (image, MONO_TOKEN_TYPE_DEF | 1, error);
return_if_nok (error);
MonoVTable * vtable = mono_class_vtable_checked (module_klass, error);
return_if_nok (error);
mono_runtime_class_init_full (vtable, error);
}
MonoBoolean
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStack (void)
{
MonoThreadInfo *thread = mono_thread_info_current ();
void *current = &thread;
// Stack upper/lower bound should have been calculated and set as part of register_thread.
// If not, we are optimistic and assume there is enough room.
if (!thread->stack_start_limit || !thread->stack_end)
return TRUE;
// Stack start limit is stack lower bound. Make sure there is enough room left.
void *limit = ((uint8_t *)thread->stack_start_limit) + ALIGN_TO (MONO_STACK_OVERFLOW_GUARD_SIZE + MONO_MIN_EXECUTION_STACK_SIZE, ((gssize)mono_pagesize ()));
if (current < limit)
return FALSE;
if (mono_get_runtime_callbacks ()->is_interpreter_enabled () &&
!mono_get_runtime_callbacks ()->interp_sufficient_stack (MONO_MIN_EXECUTION_STACK_SIZE))
return FALSE;
return TRUE;
}
MonoObjectHandle
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetUninitializedObjectInternal (MonoType *handle, MonoError *error)
{
MonoClass *klass;
MonoVTable *vtable;
g_assert (handle);
klass = mono_class_from_mono_type_internal (handle);
if (m_class_is_string (klass)) {
mono_error_set_argument (error, NULL, NULL);
return NULL_HANDLE;
}
if (mono_class_is_array (klass) || mono_class_is_pointer (klass) || m_type_is_byref (handle)) {
mono_error_set_argument (error, NULL, NULL);
return NULL_HANDLE;
}
if (MONO_TYPE_IS_VOID (handle)) {
mono_error_set_argument (error, NULL, NULL);
return NULL_HANDLE;
}
if (m_class_is_abstract (klass) || m_class_is_interface (klass) || m_class_is_gtd (klass)) {
mono_error_set_member_access (error, NULL);
return NULL_HANDLE;
}
if (m_class_is_byreflike (klass)) {
mono_error_set_not_supported (error, NULL);
return NULL_HANDLE;
}
if (!mono_class_is_before_field_init (klass)) {
vtable = mono_class_vtable_checked (klass, error);
return_val_if_nok (error, NULL_HANDLE);
mono_runtime_class_init_full (vtable, error);
return_val_if_nok (error, NULL_HANDLE);
}
if (m_class_is_nullable (klass))
return mono_object_new_handle (m_class_get_nullable_elem_class (klass), error);
else
return mono_object_new_handle (klass, error);
}
void
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_PrepareMethod (MonoMethod *method, gpointer inst_types, int n_inst_types, MonoError *error)
{
if (method->flags & METHOD_ATTRIBUTE_ABSTRACT) {
mono_error_set_argument (error, NULL, NULL);
return;
}
MonoGenericContainer *container = NULL;
if (method->is_generic)
container = mono_method_get_generic_container (method);
else if (m_class_is_gtd (method->klass))
container = mono_class_get_generic_container (method->klass);
if (container) {
int nparams = container->type_argc + (container->parent ? container->parent->type_argc : 0);
if (nparams != n_inst_types) {
mono_error_set_argument (error, NULL, NULL);
return;
}
}
// FIXME: Implement
}
MonoObjectHandle
ves_icall_System_Object_MemberwiseClone (MonoObjectHandle this_obj, MonoError *error)
{
return mono_object_clone_handle (this_obj, error);
}
gint32
ves_icall_System_ValueType_InternalGetHashCode (MonoObjectHandle this_obj, MonoArrayHandleOut fields, MonoError *error)
{
MonoClass *klass;
MonoClassField **unhandled = NULL;
int count = 0;
gint32 result = (int)(gsize)mono_defaults.int32_class;
MonoClassField* field;
gpointer iter;
klass = mono_handle_class (this_obj);
if (mono_class_num_fields (klass) == 0)
return result;
/*
* Compute the starting value of the hashcode for fields of primitive
* types, and return the remaining fields in an array to the managed side.
* This way, we can avoid costly reflection operations in managed code.
*/
iter = NULL;
while ((field = mono_class_get_fields_internal (klass, &iter))) {
if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
continue;
if (mono_field_is_deleted (field))
continue;
gpointer addr = (guint8*)MONO_HANDLE_RAW (this_obj) + field->offset;
/* FIXME: Add more types */
switch (field->type->type) {
case MONO_TYPE_I4:
result ^= *(gint32*)addr;
break;
case MONO_TYPE_PTR:
result ^= mono_aligned_addr_hash (*(gpointer*)addr);
break;
case MONO_TYPE_STRING: {
MonoString *s;
s = *(MonoString**)addr;
if (s != NULL)
result ^= mono_string_hash_internal (s);
break;
}
default:
if (!unhandled)
unhandled = g_newa (MonoClassField*, mono_class_num_fields (klass));
unhandled [count ++] = field;
}
}
if (unhandled) {
MonoArrayHandle fields_arr = mono_array_new_handle (mono_defaults.object_class, count, error);
return_val_if_nok (error, 0);
MONO_HANDLE_ASSIGN (fields, fields_arr);
MonoObjectHandle h = MONO_HANDLE_NEW (MonoObject, NULL);
for (int i = 0; i < count; ++i) {
MonoObject *o = mono_field_get_value_object_checked (unhandled [i], MONO_HANDLE_RAW (this_obj), error);
return_val_if_nok (error, 0);
MONO_HANDLE_ASSIGN_RAW (h, o);
mono_array_handle_setref (fields_arr, i, h);
}
} else {
MONO_HANDLE_ASSIGN (fields, NULL_HANDLE);
}
return result;
}
MonoBoolean
ves_icall_System_ValueType_Equals (MonoObjectHandle this_obj, MonoObjectHandle that, MonoArrayHandleOut fields, MonoError *error)
{
MonoClass *klass;
MonoClassField **unhandled = NULL;
MonoClassField* field;
gpointer iter;
int count = 0;
MONO_CHECK_ARG_NULL_HANDLE (that, FALSE);
MONO_HANDLE_ASSIGN (fields, NULL_HANDLE);
if (mono_handle_vtable (this_obj) != mono_handle_vtable (that))
return FALSE;
klass = mono_handle_class (this_obj);
if (m_class_is_enumtype (klass) && mono_class_enum_basetype_internal (klass) && mono_class_enum_basetype_internal (klass)->type == MONO_TYPE_I4)
return *(gint32*)mono_handle_get_data_unsafe (this_obj) == *(gint32*)mono_handle_get_data_unsafe (that);
/*
* Do the comparison for fields of primitive type and return a result if
* possible. Otherwise, return the remaining fields in an array to the
* managed side. This way, we can avoid costly reflection operations in
* managed code.
*/
iter = NULL;
while ((field = mono_class_get_fields_internal (klass, &iter))) {
if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
continue;
if (mono_field_is_deleted (field))
continue;
guint8 *this_field = (guint8 *)MONO_HANDLE_RAW (this_obj) + field->offset;
guint8 *that_field = (guint8 *)MONO_HANDLE_RAW (that) + field->offset;
#define UNALIGNED_COMPARE(type) \
do { \
type left, right; \
memcpy (&left, this_field, sizeof (type)); \
memcpy (&right, that_field, sizeof (type)); \
if (left != right) \
return FALSE; \
} while (0)
/* FIXME: Add more types */
switch (field->type->type) {
case MONO_TYPE_U1:
case MONO_TYPE_I1:
case MONO_TYPE_BOOLEAN:
if (*this_field != *that_field)
return FALSE;
break;
case MONO_TYPE_U2:
case MONO_TYPE_I2:
case MONO_TYPE_CHAR:
#ifdef NO_UNALIGNED_ACCESS
if (G_UNLIKELY ((intptr_t) this_field & 1 || (intptr_t) that_field & 1))
UNALIGNED_COMPARE (gint16);
else
#endif
if (*(gint16 *) this_field != *(gint16 *) that_field)
return FALSE;
break;
case MONO_TYPE_U4:
case MONO_TYPE_I4:
#ifdef NO_UNALIGNED_ACCESS
if (G_UNLIKELY ((intptr_t) this_field & 3 || (intptr_t) that_field & 3))
UNALIGNED_COMPARE (gint32);
else
#endif
if (*(gint32 *) this_field != *(gint32 *) that_field)
return FALSE;
break;
case MONO_TYPE_U8:
case MONO_TYPE_I8:
#ifdef NO_UNALIGNED_ACCESS
if (G_UNLIKELY ((intptr_t) this_field & 7 || (intptr_t) that_field & 7))
UNALIGNED_COMPARE (gint64);
else
#endif
if (*(gint64 *) this_field != *(gint64 *) that_field)
return FALSE;
break;
case MONO_TYPE_R4: {
float d1, d2;
#ifdef NO_UNALIGNED_ACCESS
memcpy (&d1, this_field, sizeof (float));
memcpy (&d2, that_field, sizeof (float));
#else
d1 = *(float *) this_field;
d2 = *(float *) that_field;
#endif
if (d1 != d2 && !(mono_isnan (d1) && mono_isnan (d2)))
return FALSE;
break;
}
case MONO_TYPE_R8: {
double d1, d2;
#ifdef NO_UNALIGNED_ACCESS
memcpy (&d1, this_field, sizeof (double));
memcpy (&d2, that_field, sizeof (double));
#else
d1 = *(double *) this_field;
d2 = *(double *) that_field;
#endif
if (d1 != d2 && !(mono_isnan (d1) && mono_isnan (d2)))
return FALSE;
break;
}
case MONO_TYPE_PTR:
#ifdef NO_UNALIGNED_ACCESS
if (G_UNLIKELY ((intptr_t) this_field & 7 || (intptr_t) that_field & 7))
UNALIGNED_COMPARE (gpointer);
else
#endif
if (*(gpointer *) this_field != *(gpointer *) that_field)
return FALSE;
break;
case MONO_TYPE_STRING: {
MonoString *s1, *s2;
guint32 s1len, s2len;
s1 = *(MonoString**)this_field;
s2 = *(MonoString**)that_field;
if (s1 == s2)
break;
if ((s1 == NULL) || (s2 == NULL))
return FALSE;
s1len = mono_string_length_internal (s1);
s2len = mono_string_length_internal (s2);
if (s1len != s2len)
return FALSE;
if (memcmp (mono_string_chars_internal (s1), mono_string_chars_internal (s2), s1len * sizeof (gunichar2)) != 0)
return FALSE;
break;
}
default:
if (!unhandled)
unhandled = g_newa (MonoClassField*, mono_class_num_fields (klass));
unhandled [count ++] = field;
}
#undef UNALIGNED_COMPARE
if (m_class_is_enumtype (klass))
/* enums only have one non-static field */
break;
}
if (unhandled) {
MonoArrayHandle fields_arr = mono_array_new_handle (mono_defaults.object_class, count * 2, error);
return_val_if_nok (error, 0);
MONO_HANDLE_ASSIGN (fields, fields_arr);
MonoObjectHandle h = MONO_HANDLE_NEW (MonoObject, NULL);
for (int i = 0; i < count; ++i) {
MonoObject *o = mono_field_get_value_object_checked (unhandled [i], MONO_HANDLE_RAW (this_obj), error);
return_val_if_nok (error, FALSE);
MONO_HANDLE_ASSIGN_RAW (h, o);
mono_array_handle_setref (fields_arr, i * 2, h);
o = mono_field_get_value_object_checked (unhandled [i], MONO_HANDLE_RAW (that), error);
return_val_if_nok (error, FALSE);
MONO_HANDLE_ASSIGN_RAW (h, o);
mono_array_handle_setref (fields_arr, (i * 2) + 1, h);
}
return FALSE;
} else {
return TRUE;
}
}
static gboolean
get_executing (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
{
MonoMethod **dest = (MonoMethod **)data;
/* skip unmanaged frames */
if (!managed)
return FALSE;
if (!(*dest)) {
if (!strcmp (m_class_get_name_space (m->klass), "System.Reflection"))
return FALSE;
*dest = m;
return TRUE;
}
return FALSE;
}
static gboolean
in_corlib_name_space (MonoClass *klass, const char *name_space)
{
return m_class_get_image (klass) == mono_defaults.corlib &&
!strcmp (m_class_get_name_space (klass), name_space);
}
static gboolean
get_caller_no_reflection (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
{
MonoMethod **dest = (MonoMethod **)data;
/* skip unmanaged frames */
if (!managed)
return FALSE;
if (m->wrapper_type != MONO_WRAPPER_NONE)
return FALSE;
if (m == *dest) {
*dest = NULL;
return FALSE;
}
if (in_corlib_name_space (m->klass, "System.Reflection"))
return FALSE;
if (!(*dest)) {
*dest = m;
return TRUE;
}
return FALSE;
}
static gboolean
get_caller_no_system_or_reflection (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
{
MonoMethod **dest = (MonoMethod **)data;
/* skip unmanaged frames */
if (!managed)
return FALSE;
if (m->wrapper_type != MONO_WRAPPER_NONE)
return FALSE;
if (m == *dest) {
*dest = NULL;
return FALSE;
}
if (in_corlib_name_space (m->klass, "System.Reflection") || in_corlib_name_space (m->klass, "System"))
return FALSE;
if (!(*dest)) {
*dest = m;
return TRUE;
}
return FALSE;
}
/**
* mono_runtime_get_caller_no_system_or_reflection:
*
* Walk the stack of the current thread and find the first managed method that
* is not in the mscorlib System or System.Reflection namespace. This skips
* unmanaged callers and wrapper methods.
*
* \returns a pointer to the \c MonoMethod or NULL if we walked past all the
* callers.
*/
MonoMethod*
mono_runtime_get_caller_no_system_or_reflection (void)
{
MonoMethod *dest = NULL;
mono_stack_walk_no_il (get_caller_no_system_or_reflection, &dest);
return dest;
}
/*
* mono_runtime_get_caller_from_stack_mark:
*
* Walk the stack and return the assembly of the method referenced
* by the stack mark STACK_MARK.
*/
MonoAssembly*
mono_runtime_get_caller_from_stack_mark (MonoStackCrawlMark *stack_mark)
{
// FIXME: Use the stack mark
MonoMethod *dest = NULL;
mono_stack_walk_no_il (get_caller_no_system_or_reflection, &dest);
if (dest)
return m_class_get_image (dest->klass)->assembly;
else
return NULL;
}
static MonoReflectionType*
type_from_parsed_name (MonoTypeNameParse *info, MonoStackCrawlMark *stack_mark, MonoBoolean ignoreCase, MonoAssembly **caller_assembly, MonoError *error)
{
MonoMethod *m;
MonoType *type = NULL;
MonoAssembly *assembly = NULL;
gboolean type_resolve = FALSE;
MonoImage *rootimage = NULL;
MonoAssemblyLoadContext *alc = mono_alc_get_ambient ();
/*
* We must compute the calling assembly as type loading must happen under a metadata context.
* For example. The main assembly is a.exe and Type.GetType is called from dir/b.dll. Without
* the metadata context (basedir currently) set to dir/b.dll we won't be able to load a dir/c.dll.
*/
m = mono_method_get_last_managed ();
if (m && m_class_get_image (m->klass) != mono_defaults.corlib) {
/* Happens with inlining */
assembly = m_class_get_image (m->klass)->assembly;
} else {
assembly = mono_runtime_get_caller_from_stack_mark (stack_mark);
}
if (assembly) {
type_resolve = TRUE;
rootimage = assembly->image;
} else {
// FIXME: once wasm can use stack marks, consider turning all this into an assert
g_warning (G_STRLOC);
}
*caller_assembly = assembly;
if (info->assembly.name) {
MonoAssemblyByNameRequest req;
mono_assembly_request_prepare_byname (&req, alc);
req.requesting_assembly = assembly;
req.basedir = assembly ? assembly->basedir : NULL;
assembly = mono_assembly_request_byname (&info->assembly, &req, NULL);
}
if (assembly) {
/* When loading from the current assembly, AppDomain.TypeResolve will not be called yet */
type = mono_reflection_get_type_checked (alc, rootimage, assembly->image, info, ignoreCase, TRUE, &type_resolve, error);
goto_if_nok (error, fail);
}
// XXXX - aleksey -
// Say we're looking for System.Generic.Dict<int, Local>
// we FAIL the get type above, because S.G.Dict isn't in assembly->image. So we drop down here.
// but then we FAIL AGAIN because now we pass null as the image and the rootimage and everything
// is messed up when we go to construct the Local as the type arg...
//
// By contrast, if we started with Mine<System.Generic.Dict<int, Local>> we'd go in with assembly->image
// as the root and then even the detour into generics would still not cause issues when we went to load Local.
if (!info->assembly.name && !type) {
/* try mscorlib */
type = mono_reflection_get_type_checked (alc, rootimage, NULL, info, ignoreCase, TRUE, &type_resolve, error);
goto_if_nok (error, fail);
}
if (assembly && !type && type_resolve) {
type_resolve = FALSE; /* This will invoke TypeResolve if not done in the first 'if' */
type = mono_reflection_get_type_checked (alc, rootimage, assembly->image, info, ignoreCase, TRUE, &type_resolve, error);
goto_if_nok (error, fail);
}
if (!type)
goto fail;
return mono_type_get_object_checked (type, error);
fail:
return NULL;
}
void
ves_icall_System_RuntimeTypeHandle_internal_from_name (char *name,
MonoStackCrawlMark *stack_mark,
MonoObjectHandleOnStack res,
MonoBoolean throwOnError,
MonoBoolean ignoreCase,
MonoError *error)
{
MonoTypeNameParse info;
gboolean free_info = FALSE;
MonoAssembly *caller_assembly;
free_info = TRUE;
if (!mono_reflection_parse_type_checked (name, &info, error))
goto leave;
/* mono_reflection_parse_type() mangles the string */
HANDLE_ON_STACK_SET (res, type_from_parsed_name (&info, (MonoStackCrawlMark*)stack_mark, ignoreCase, &caller_assembly, error));
goto_if_nok (error, leave);
if (!(*res)) {
if (throwOnError) {
char *tname = info.name_space ? g_strdup_printf ("%s.%s", info.name_space, info.name) : g_strdup (info.name);
char *aname;
if (info.assembly.name)
aname = mono_stringify_assembly_name (&info.assembly);
else if (caller_assembly)
aname = mono_stringify_assembly_name (mono_assembly_get_name_internal (caller_assembly));
else
aname = g_strdup ("");
mono_error_set_type_load_name (error, tname, aname, "");
}
goto leave;
}
leave:
if (free_info)
mono_reflection_free_type_info (&info);
if (!is_ok (error)) {
if (!throwOnError) {
mono_error_cleanup (error);
error_init (error);
}
}
}
MonoReflectionTypeHandle
ves_icall_System_Type_internal_from_handle (MonoType *handle, MonoError *error)
{
return mono_type_get_object_handle (handle, error);
}
MonoType*
ves_icall_Mono_RuntimeClassHandle_GetTypeFromClass (MonoClass *klass)
{
return m_class_get_byval_arg (klass);
}
void
ves_icall_Mono_RuntimeGPtrArrayHandle_GPtrArrayFree (GPtrArray *ptr_array)
{
g_ptr_array_free (ptr_array, TRUE);
}
void
ves_icall_Mono_SafeStringMarshal_GFree (void *c_str)
{
g_free (c_str);
}
char*
ves_icall_Mono_SafeStringMarshal_StringToUtf8 (MonoString *volatile* s)
{
ERROR_DECL (error);
char *result = mono_string_to_utf8_checked_internal (*s, error);
mono_error_set_pending_exception (error);
return result;
}
/* System.TypeCode */
typedef enum {
TYPECODE_EMPTY,
TYPECODE_OBJECT,
TYPECODE_DBNULL,
TYPECODE_BOOLEAN,
TYPECODE_CHAR,
TYPECODE_SBYTE,
TYPECODE_BYTE,
TYPECODE_INT16,
TYPECODE_UINT16,
TYPECODE_INT32,
TYPECODE_UINT32,
TYPECODE_INT64,
TYPECODE_UINT64,
TYPECODE_SINGLE,
TYPECODE_DOUBLE,
TYPECODE_DECIMAL,
TYPECODE_DATETIME,
TYPECODE_STRING = 18
} TypeCode;
MonoBoolean
ves_icall_RuntimeTypeHandle_type_is_assignable_from (MonoQCallTypeHandle type_handle, MonoQCallTypeHandle c_handle, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
MonoType *ctype = c_handle.type;
MonoClass *klassc = mono_class_from_mono_type_internal (ctype);
if (m_type_is_byref (type) ^ m_type_is_byref (ctype))
return FALSE;
if (m_type_is_byref (type)) {
return mono_byref_type_is_assignable_from (type, ctype, FALSE);
}
gboolean result;
mono_class_is_assignable_from_checked (klass, klassc, &result, error);
return result;
}
MonoBoolean
ves_icall_RuntimeTypeHandle_is_subclass_of (MonoQCallTypeHandle child_handle, MonoQCallTypeHandle base_handle, MonoError *error)
{
MonoType *childType = child_handle.type;
MonoType *baseType = base_handle.type;
mono_bool result = FALSE;
MonoClass *childClass;
MonoClass *baseClass;
childClass = mono_class_from_mono_type_internal (childType);
baseClass = mono_class_from_mono_type_internal (baseType);
if (G_UNLIKELY (m_type_is_byref (childType)))
return !m_type_is_byref (baseType) && baseClass == mono_defaults.object_class;
if (G_UNLIKELY (m_type_is_byref (baseType)))
return FALSE;
if (childType == baseType)
/* .NET IsSubclassOf is not reflexive */
return FALSE;
if (G_UNLIKELY (is_generic_parameter (childType))) {
/* slow path: walk the type hierarchy looking at base types
* until we see baseType. If the current type is not a gparam,
* break out of the loop and use is_subclass_of.
*/
MonoClass *c = mono_generic_param_get_base_type (childClass);
result = FALSE;
while (c != NULL) {
if (c == baseClass)
return TRUE;
if (!is_generic_parameter (m_class_get_byval_arg (c)))
return mono_class_is_subclass_of_internal (c, baseClass, FALSE);
else
c = mono_generic_param_get_base_type (c);
}
return result;
} else {
return mono_class_is_subclass_of_internal (childClass, baseClass, FALSE);
}
}
guint32
ves_icall_RuntimeTypeHandle_IsInstanceOfType (MonoQCallTypeHandle type_handle, MonoObjectHandle obj, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_val_if_nok (error, FALSE);
MonoObjectHandle inst = mono_object_handle_isinst (obj, klass, error);
return_val_if_nok (error, FALSE);
return !MONO_HANDLE_IS_NULL (inst);
}
guint32
ves_icall_RuntimeTypeHandle_GetAttributes (MonoQCallTypeHandle type_handle)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type) || type->type == MONO_TYPE_PTR || type->type == MONO_TYPE_FNPTR)
return TYPE_ATTRIBUTE_PUBLIC;
MonoClass *klass = mono_class_from_mono_type_internal (type);
return mono_class_get_flags (klass);
}
guint32
ves_icall_RuntimeTypeHandle_GetMetadataToken (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *mc = mono_class_from_mono_type_internal (type);
if (!mono_class_init_internal (mc)) {
mono_error_set_for_class_failure (error, mc);
return 0;
}
return m_class_get_type_token (mc);
}
MonoReflectionMarshalAsAttributeHandle
ves_icall_System_Reflection_FieldInfo_get_marshal_info (MonoReflectionFieldHandle field_h, MonoError *error)
{
MonoClassField *field = MONO_HANDLE_GETVAL (field_h, field);
MonoClass *klass = m_field_get_parent (field);
MonoGenericClass *gklass = mono_class_try_get_generic_class (klass);
if (mono_class_is_gtd (klass) ||
(gklass && gklass->context.class_inst->is_open))
return MONO_HANDLE_CAST (MonoReflectionMarshalAsAttribute, NULL_HANDLE);
MonoType *ftype = mono_field_get_type_internal (field);
if (ftype && !(ftype->attrs & FIELD_ATTRIBUTE_HAS_FIELD_MARSHAL))
return MONO_HANDLE_CAST (MonoReflectionMarshalAsAttribute, NULL_HANDLE);
MonoMarshalType *info = mono_marshal_load_type_info (klass);
for (int i = 0; i < info->num_fields; ++i) {
if (info->fields [i].field == field) {
if (!info->fields [i].mspec)
return MONO_HANDLE_CAST (MonoReflectionMarshalAsAttribute, NULL_HANDLE);
else {
return mono_reflection_marshal_as_attribute_from_marshal_spec (klass, info->fields [i].mspec, error);
}
}
}
return MONO_HANDLE_CAST (MonoReflectionMarshalAsAttribute, NULL_HANDLE);
}
MonoReflectionFieldHandle
ves_icall_System_Reflection_FieldInfo_internal_from_handle_type (MonoClassField *handle, MonoType *type, MonoError *error)
{
MonoClass *klass;
g_assert (handle);
if (!type) {
klass = m_field_get_parent (handle);
} else {
klass = mono_class_from_mono_type_internal (type);
gboolean found = klass == m_field_get_parent (handle) || mono_class_has_parent (klass, m_field_get_parent (handle));
if (!found)
/* The managed code will throw the exception */
return MONO_HANDLE_CAST (MonoReflectionField, NULL_HANDLE);
}
return mono_field_get_object_handle (klass, handle, error);
}
MonoReflectionEventHandle
ves_icall_System_Reflection_EventInfo_internal_from_handle_type (MonoEvent *handle, MonoType *type, MonoError *error)
{
MonoClass *klass;
g_assert (handle);
if (!type) {
klass = handle->parent;
} else {
klass = mono_class_from_mono_type_internal (type);
gboolean found = klass == handle->parent || mono_class_has_parent (klass, handle->parent);
if (!found)
/* Managed code will throw an exception */
return MONO_HANDLE_CAST (MonoReflectionEvent, NULL_HANDLE);
}
return mono_event_get_object_handle (klass, handle, error);
}
MonoReflectionPropertyHandle
ves_icall_System_Reflection_RuntimePropertyInfo_internal_from_handle_type (MonoProperty *handle, MonoType *type, MonoError *error)
{
MonoClass *klass;
g_assert (handle);
if (!type) {
klass = handle->parent;
} else {
klass = mono_class_from_mono_type_internal (type);
gboolean found = klass == handle->parent || mono_class_has_parent (klass, handle->parent);
if (!found)
/* Managed code will throw an exception */
return MONO_HANDLE_CAST (MonoReflectionProperty, NULL_HANDLE);
}
return mono_property_get_object_handle (klass, handle, error);
}
MonoArrayHandle
ves_icall_System_Reflection_FieldInfo_GetTypeModifiers (MonoReflectionFieldHandle field_h, MonoBoolean optional, MonoError *error)
{
MonoClassField *field = MONO_HANDLE_GETVAL (field_h, field);
MonoType *type = mono_field_get_type_checked (field, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
return type_array_from_modifiers (type, optional, error);
}
int
ves_icall_get_method_attributes (MonoMethod *method)
{
return method->flags;
}
void
ves_icall_get_method_info (MonoMethod *method, MonoMethodInfo *info, MonoError *error)
{
MonoMethodSignature* sig = mono_method_signature_checked (method, error);
return_if_nok (error);
MonoReflectionTypeHandle rt = mono_type_get_object_handle (m_class_get_byval_arg (method->klass), error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, parent, MONO_HANDLE_RAW (rt));
MONO_HANDLE_ASSIGN (rt, mono_type_get_object_handle (sig->ret, error));
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, ret, MONO_HANDLE_RAW (rt));
info->attrs = method->flags;
info->implattrs = method->iflags;
guint32 callconv;
if (sig->call_convention == MONO_CALL_DEFAULT)
callconv = sig->sentinelpos >= 0 ? 2 : 1;
else {
if (sig->call_convention == MONO_CALL_VARARG || sig->sentinelpos >= 0)
callconv = 2;
else
callconv = 1;
}
callconv |= (sig->hasthis << 5) | (sig->explicit_this << 6);
info->callconv = callconv;
}
MonoArrayHandle
ves_icall_System_Reflection_MonoMethodInfo_get_parameter_info (MonoMethod *method, MonoReflectionMethodHandle member, MonoError *error)
{
MonoReflectionTypeHandle reftype = MONO_HANDLE_NEW (MonoReflectionType, NULL);
MONO_HANDLE_GET (reftype, member, reftype);
MonoClass *klass = NULL;
if (!MONO_HANDLE_IS_NULL (reftype))
klass = mono_class_from_mono_type_internal (MONO_HANDLE_GETVAL (reftype, type));
return mono_param_get_objects_internal (method, klass, error);
}
MonoReflectionMarshalAsAttributeHandle
ves_icall_System_MonoMethodInfo_get_retval_marshal (MonoMethod *method, MonoError *error)
{
MonoReflectionMarshalAsAttributeHandle res = MONO_HANDLE_NEW (MonoReflectionMarshalAsAttribute, NULL);
MonoMarshalSpec **mspecs = g_new (MonoMarshalSpec*, mono_method_signature_internal (method)->param_count + 1);
mono_method_get_marshal_info (method, mspecs);
if (mspecs [0]) {
MONO_HANDLE_ASSIGN (res, mono_reflection_marshal_as_attribute_from_marshal_spec (method->klass, mspecs [0], error));
goto_if_nok (error, leave);
}
leave:
for (int i = mono_method_signature_internal (method)->param_count; i >= 0; i--)
if (mspecs [i])
mono_metadata_free_marshal_spec (mspecs [i]);
g_free (mspecs);
return res;
}
gint32
ves_icall_RuntimeFieldInfo_GetFieldOffset (MonoReflectionFieldHandle field, MonoError *error)
{
MonoClassField *class_field = MONO_HANDLE_GETVAL (field, field);
mono_class_setup_fields (m_field_get_parent (class_field));
return class_field->offset - MONO_ABI_SIZEOF (MonoObject);
}
MonoReflectionTypeHandle
ves_icall_RuntimeFieldInfo_GetParentType (MonoReflectionFieldHandle field, MonoBoolean declaring, MonoError *error)
{
MonoClass *parent;
if (declaring) {
MonoClassField *f = MONO_HANDLE_GETVAL (field, field);
parent = m_field_get_parent (f);
} else {
parent = MONO_HANDLE_GETVAL (field, klass);
}
return mono_type_get_object_handle (m_class_get_byval_arg (parent), error);
}
MonoObjectHandle
ves_icall_RuntimeFieldInfo_GetValueInternal (MonoReflectionFieldHandle field_handle, MonoObjectHandle obj_handle, MonoError *error)
{
MonoReflectionField * const field = MONO_HANDLE_RAW (field_handle);
MonoClassField *cf = field->field;
MonoObject * const obj = MONO_HANDLE_RAW (obj_handle);
MonoObject *result;
result = mono_field_get_value_object_checked (cf, obj, error);
return MONO_HANDLE_NEW (MonoObject, result);
}
void
ves_icall_RuntimeFieldInfo_SetValueInternal (MonoReflectionFieldHandle field, MonoObjectHandle obj, MonoObjectHandle value, MonoError *error)
{
MonoClassField *cf = MONO_HANDLE_GETVAL (field, field);
MonoType *type = mono_field_get_type_checked (cf, error);
return_if_nok (error);
gboolean isref = FALSE;
MonoGCHandle value_gchandle = 0;
gchar *v = NULL;
if (!m_type_is_byref (type)) {
switch (type->type) {
case MONO_TYPE_U1:
case MONO_TYPE_I1:
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_U2:
case MONO_TYPE_I2:
case MONO_TYPE_CHAR:
case MONO_TYPE_U:
case MONO_TYPE_I:
case MONO_TYPE_U4:
case MONO_TYPE_I4:
case MONO_TYPE_R4:
case MONO_TYPE_U8:
case MONO_TYPE_I8:
case MONO_TYPE_R8:
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_PTR:
isref = FALSE;
if (!MONO_HANDLE_IS_NULL (value)) {
if (m_class_is_valuetype (mono_handle_class (value)))
v = (char*)mono_object_handle_pin_unbox (value, &value_gchandle);
else {
char* n = g_strdup_printf ("Object of type '%s' cannot be converted to type '%s'.", m_class_get_name (mono_handle_class (value)), m_class_get_name (mono_class_from_mono_type_internal (type)));
mono_error_set_argument (error, cf->name, n);
g_free (n);
return;
}
}
break;
case MONO_TYPE_STRING:
case MONO_TYPE_OBJECT:
case MONO_TYPE_CLASS:
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY:
/* Do nothing */
isref = TRUE;
break;
case MONO_TYPE_GENERICINST: {
MonoGenericClass *gclass = type->data.generic_class;
g_assert (!gclass->context.class_inst->is_open);
if (mono_class_is_nullable (mono_class_from_mono_type_internal (type))) {
MonoClass *nklass = mono_class_from_mono_type_internal (type);
/*
* Convert the boxed vtype into a Nullable structure.
* This is complicated by the fact that Nullables have
* a variable structure.
*/
MonoObjectHandle nullable = mono_object_new_handle (nklass, error);
return_if_nok (error);
MonoGCHandle nullable_gchandle = 0;
guint8 *nval = (guint8*)mono_object_handle_pin_unbox (nullable, &nullable_gchandle);
mono_nullable_init_from_handle (nval, value, nklass);
isref = FALSE;
value_gchandle = nullable_gchandle;
v = (gchar*)nval;
}
else {
isref = !m_class_is_valuetype (gclass->container_class);
if (!isref && !MONO_HANDLE_IS_NULL (value)) {
v = (char*)mono_object_handle_pin_unbox (value, &value_gchandle);
};
}
break;
}
default:
g_error ("type 0x%x not handled in "
"ves_icall_FieldInfo_SetValueInternal", type->type);
return;
}
}
/* either value is a reference type, or it's a value type and we pinned
* it and v points to the payload. */
g_assert ((isref && v == NULL && value_gchandle == 0) ||
(!isref && v != NULL && value_gchandle != 0) ||
(!isref && v == NULL && value_gchandle == 0));
if (type->attrs & FIELD_ATTRIBUTE_STATIC) {
MonoVTable *vtable = mono_class_vtable_checked (m_field_get_parent (cf), error);
goto_if_nok (error, leave);
if (!vtable->initialized) {
if (!mono_runtime_class_init_full (vtable, error))
goto leave;
}
if (isref)
mono_field_static_set_value_internal (vtable, cf, MONO_HANDLE_RAW (value)); /* FIXME make mono_field_static_set_value work with handles for value */
else
mono_field_static_set_value_internal (vtable, cf, v);
} else {
if (isref)
MONO_HANDLE_SET_FIELD_REF (obj, cf, value);
else
mono_field_set_value_internal (MONO_HANDLE_RAW (obj), cf, v); /* FIXME: make mono_field_set_value take a handle for obj */
}
leave:
if (value_gchandle)
mono_gchandle_free_internal (value_gchandle);
}
static MonoObjectHandle
typed_reference_to_object (MonoTypedRef *tref, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoObjectHandle result;
if (MONO_TYPE_IS_REFERENCE (tref->type)) {
MonoObject** objp = (MonoObject **)tref->value;
result = MONO_HANDLE_NEW (MonoObject, *objp);
} else if (mono_type_is_pointer (tref->type)) {
/* Boxed as UIntPtr */
result = mono_value_box_handle (mono_get_uintptr_class (), tref->value, error);
} else {
result = mono_value_box_handle (tref->klass, tref->value, error);
}
HANDLE_FUNCTION_RETURN_REF (MonoObject, result);
}
MonoObjectHandle
ves_icall_System_RuntimeFieldHandle_GetValueDirect (MonoReflectionFieldHandle field_h, MonoReflectionTypeHandle field_type_h, MonoTypedRef *obj, MonoReflectionTypeHandle context_type_h, MonoError *error)
{
MonoClassField *field = MONO_HANDLE_GETVAL (field_h, field);
MonoClass *klass = mono_class_from_mono_type_internal (field->type);
if (!MONO_TYPE_ISSTRUCT (m_class_get_byval_arg (m_field_get_parent (field)))) {
mono_error_set_not_implemented (error, "");
return MONO_HANDLE_NEW (MonoObject, NULL);
} else if (MONO_TYPE_IS_REFERENCE (field->type)) {
return MONO_HANDLE_NEW (MonoObject, *(MonoObject**)((guint8*)obj->value + field->offset - sizeof (MonoObject)));
} else {
return mono_value_box_handle (klass, (guint8*)obj->value + field->offset - sizeof (MonoObject), error);
}
}
void
ves_icall_System_RuntimeFieldHandle_SetValueDirect (MonoReflectionFieldHandle field_h, MonoReflectionTypeHandle field_type_h, MonoTypedRef *obj, MonoObjectHandle value_h, MonoReflectionTypeHandle context_type_h, MonoError *error)
{
MonoClassField *f = MONO_HANDLE_GETVAL (field_h, field);
g_assert (obj);
mono_class_setup_fields (m_field_get_parent (f));
if (!MONO_TYPE_ISSTRUCT (m_class_get_byval_arg (m_field_get_parent (f)))) {
MonoObjectHandle objHandle = typed_reference_to_object (obj, error);
return_if_nok (error);
ves_icall_RuntimeFieldInfo_SetValueInternal (field_h, objHandle, value_h, error);
} else if (MONO_TYPE_IS_REFERENCE (f->type)) {
mono_copy_value (f->type, (guint8*)obj->value + m_field_get_offset (f) - sizeof (MonoObject), MONO_HANDLE_RAW (value_h), FALSE);
} else {
MonoGCHandle gchandle = NULL;
g_assert (MONO_HANDLE_RAW (value_h));
mono_copy_value (f->type, (guint8*)obj->value + m_field_get_offset (f) - sizeof (MonoObject), mono_object_handle_pin_unbox (value_h, &gchandle), FALSE);
mono_gchandle_free_internal (gchandle);
}
}
MonoObjectHandle
ves_icall_RuntimeFieldInfo_GetRawConstantValue (MonoReflectionFieldHandle rfield, MonoError* error)
{
MonoObjectHandle o_handle = NULL_HANDLE_INIT;
MonoObject *o = NULL;
MonoClassField *field = MONO_HANDLE_GETVAL (rfield, field);
MonoClass *klass;
gchar *v;
MonoTypeEnum def_type;
const char *def_value;
MonoType *t;
MonoStringHandle string_handle = MONO_HANDLE_NEW (MonoString, NULL); // FIXME? Not always needed.
mono_class_init_internal (m_field_get_parent (field));
t = mono_field_get_type_checked (field, error);
goto_if_nok (error, return_null);
if (!(t->attrs & FIELD_ATTRIBUTE_HAS_DEFAULT))
goto invalid_operation;
if (image_is_dynamic (m_class_get_image (m_field_get_parent (field)))) {
MonoClass *klass = m_field_get_parent (field);
int fidx = field - m_class_get_fields (klass);
MonoFieldDefaultValue *def_values = mono_class_get_field_def_values (klass);
g_assert (def_values);
def_type = def_values [fidx].def_type;
def_value = def_values [fidx].data;
if (def_type == MONO_TYPE_END)
goto invalid_operation;
} else {
def_value = mono_class_get_field_default_value (field, &def_type);
/* FIXME, maybe we should try to raise TLE if field->parent is broken */
if (!def_value)
goto invalid_operation;
}
/*FIXME unify this with reflection.c:mono_get_object_from_blob*/
switch (def_type) {
case MONO_TYPE_U1:
case MONO_TYPE_I1:
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_U2:
case MONO_TYPE_I2:
case MONO_TYPE_CHAR:
case MONO_TYPE_U:
case MONO_TYPE_I:
case MONO_TYPE_U4:
case MONO_TYPE_I4:
case MONO_TYPE_R4:
case MONO_TYPE_U8:
case MONO_TYPE_I8:
case MONO_TYPE_R8: {
MonoType *t;
/* boxed value type */
t = g_new0 (MonoType, 1);
t->type = def_type;
klass = mono_class_from_mono_type_internal (t);
g_free (t);
o = mono_object_new_checked (klass, error);
goto_if_nok (error, return_null);
o_handle = MONO_HANDLE_NEW (MonoObject, o);
v = ((gchar *) o) + sizeof (MonoObject);
(void)mono_get_constant_value_from_blob (def_type, def_value, v, string_handle, error);
goto_if_nok (error, return_null);
break;
}
case MONO_TYPE_STRING:
case MONO_TYPE_CLASS:
(void)mono_get_constant_value_from_blob (def_type, def_value, &o, string_handle, error);
goto_if_nok (error, return_null);
o_handle = MONO_HANDLE_NEW (MonoObject, o);
break;
default:
g_assert_not_reached ();
}
goto exit;
invalid_operation:
mono_error_set_invalid_operation (error, NULL);
// fall through
return_null:
o_handle = NULL_HANDLE;
// fall through
exit:
return o_handle;
}
MonoReflectionTypeHandle
ves_icall_RuntimeFieldInfo_ResolveType (MonoReflectionFieldHandle ref_field, MonoError *error)
{
MonoClassField *field = MONO_HANDLE_GETVAL (ref_field, field);
MonoType *type = mono_field_get_type_checked (field, error);
return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE));
return mono_type_get_object_handle (type, error);
}
void
ves_icall_RuntimePropertyInfo_get_property_info (MonoReflectionPropertyHandle property, MonoPropertyInfo *info, PInfo req_info, MonoError *error)
{
const MonoProperty *pproperty = MONO_HANDLE_GETVAL (property, property);
if ((req_info & PInfo_ReflectedType) != 0) {
MonoClass *klass = MONO_HANDLE_GETVAL (property, klass);
MonoReflectionTypeHandle rt = mono_type_get_object_handle (m_class_get_byval_arg (klass), error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, parent, MONO_HANDLE_RAW (rt));
}
if ((req_info & PInfo_DeclaringType) != 0) {
MonoReflectionTypeHandle rt = mono_type_get_object_handle (m_class_get_byval_arg (pproperty->parent), error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, declaring_type, MONO_HANDLE_RAW (rt));
}
if ((req_info & PInfo_Name) != 0) {
MonoStringHandle name = mono_string_new_handle (pproperty->name, error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, name, MONO_HANDLE_RAW (name));
}
if ((req_info & PInfo_Attributes) != 0)
info->attrs = pproperty->attrs;
if ((req_info & PInfo_GetMethod) != 0) {
MonoClass *property_klass = MONO_HANDLE_GETVAL (property, klass);
MonoReflectionMethodHandle rm;
if (pproperty->get &&
(((pproperty->get->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) != METHOD_ATTRIBUTE_PRIVATE) ||
pproperty->get->klass == property_klass)) {
rm = mono_method_get_object_handle (pproperty->get, property_klass, error);
return_if_nok (error);
} else {
rm = MONO_HANDLE_NEW (MonoReflectionMethod, NULL);
}
MONO_STRUCT_SETREF_INTERNAL (info, get, MONO_HANDLE_RAW (rm));
}
if ((req_info & PInfo_SetMethod) != 0) {
MonoClass *property_klass = MONO_HANDLE_GETVAL (property, klass);
MonoReflectionMethodHandle rm;
if (pproperty->set &&
(((pproperty->set->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) != METHOD_ATTRIBUTE_PRIVATE) ||
pproperty->set->klass == property_klass)) {
rm = mono_method_get_object_handle (pproperty->set, property_klass, error);
return_if_nok (error);
} else {
rm = MONO_HANDLE_NEW (MonoReflectionMethod, NULL);
}
MONO_STRUCT_SETREF_INTERNAL (info, set, MONO_HANDLE_RAW (rm));
}
/*
* There may be other methods defined for properties, though, it seems they are not exposed
* in the reflection API
*/
}
static gboolean
add_event_other_methods_to_array (MonoMethod *m, MonoArrayHandle dest, int i, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoReflectionMethodHandle rm = mono_method_get_object_handle (m, NULL, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, i, rm);
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
void
ves_icall_RuntimeEventInfo_get_event_info (MonoReflectionMonoEventHandle ref_event, MonoEventInfo *info, MonoError *error)
{
MonoClass *klass = MONO_HANDLE_GETVAL (ref_event, klass);
MonoEvent *event = MONO_HANDLE_GETVAL (ref_event, event);
MonoReflectionTypeHandle rt = mono_type_get_object_handle (m_class_get_byval_arg (klass), error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, reflected_type, MONO_HANDLE_RAW (rt));
rt = mono_type_get_object_handle (m_class_get_byval_arg (event->parent), error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, declaring_type, MONO_HANDLE_RAW (rt));
MonoStringHandle ev_name = mono_string_new_handle (event->name, error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, name, MONO_HANDLE_RAW (ev_name));
info->attrs = event->attrs;
MonoReflectionMethodHandle rm;
if (event->add) {
rm = mono_method_get_object_handle (event->add, klass, error);
return_if_nok (error);
} else {
rm = MONO_HANDLE_NEW (MonoReflectionMethod, NULL);
}
MONO_STRUCT_SETREF_INTERNAL (info, add_method, MONO_HANDLE_RAW (rm));
if (event->remove) {
rm = mono_method_get_object_handle (event->remove, klass, error);
return_if_nok (error);
} else {
rm = MONO_HANDLE_NEW (MonoReflectionMethod, NULL);
}
MONO_STRUCT_SETREF_INTERNAL (info, remove_method, MONO_HANDLE_RAW (rm));
if (event->raise) {
rm = mono_method_get_object_handle (event->raise, klass, error);
return_if_nok (error);
} else {
rm = MONO_HANDLE_NEW (MonoReflectionMethod, NULL);
}
MONO_STRUCT_SETREF_INTERNAL (info, raise_method, MONO_HANDLE_RAW (rm));
#ifndef MONO_SMALL_CONFIG
if (event->other) {
int i, n = 0;
while (event->other [n])
n++;
MonoArrayHandle info_arr = mono_array_new_handle (mono_defaults.method_info_class, n, error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, other_methods, MONO_HANDLE_RAW (info_arr));
for (i = 0; i < n; i++)
if (!add_event_other_methods_to_array (event->other [i], info_arr, i, error))
return;
}
#endif
}
static void
collect_interfaces (MonoClass *klass, GHashTable *ifaces, MonoError *error)
{
int i;
MonoClass *ic;
mono_class_setup_interfaces (klass, error);
return_if_nok (error);
int klass_interface_count = m_class_get_interface_count (klass);
MonoClass **klass_interfaces = m_class_get_interfaces (klass);
for (i = 0; i < klass_interface_count; i++) {
ic = klass_interfaces [i];
g_hash_table_insert (ifaces, ic, ic);
collect_interfaces (ic, ifaces, error);
return_if_nok (error);
}
}
typedef struct {
MonoArrayHandle iface_array;
MonoGenericContext *context;
MonoError *error;
int next_idx;
} FillIfaceArrayData;
static void
fill_iface_array (gpointer key, gpointer value, gpointer user_data)
{
HANDLE_FUNCTION_ENTER ();
FillIfaceArrayData *data = (FillIfaceArrayData *)user_data;
MonoClass *ic = (MonoClass *)key;
MonoType *ret = m_class_get_byval_arg (ic), *inflated = NULL;
MonoError *error = data->error;
goto_if_nok (error, leave);
if (data->context && mono_class_is_ginst (ic) && mono_class_get_generic_class (ic)->context.class_inst->is_open) {
inflated = ret = mono_class_inflate_generic_type_checked (ret, data->context, error);
goto_if_nok (error, leave);
}
MonoReflectionTypeHandle rt;
rt = mono_type_get_object_handle (ret, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (data->iface_array, data->next_idx, rt);
data->next_idx++;
if (inflated)
mono_metadata_free_type (inflated);
leave:
HANDLE_FUNCTION_RETURN ();
}
static guint
get_interfaces_hash (gconstpointer v1)
{
MonoClass *k = (MonoClass*)v1;
return m_class_get_type_token (k);
}
void
ves_icall_RuntimeType_GetInterfaces (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
GHashTable *iface_hash = g_hash_table_new (get_interfaces_hash, NULL);
MonoGenericContext *context = NULL;
if (mono_class_is_ginst (klass) && mono_class_get_generic_class (klass)->context.class_inst->is_open) {
context = mono_class_get_context (klass);
klass = mono_class_get_generic_class (klass)->container_class;
}
for (MonoClass *parent = klass; parent; parent = m_class_get_parent (parent)) {
mono_class_setup_interfaces (parent, error);
goto_if_nok (error, fail);
collect_interfaces (parent, iface_hash, error);
goto_if_nok (error, fail);
}
MonoDomain *domain = mono_get_root_domain ();
int len;
len = g_hash_table_size (iface_hash);
if (len == 0) {
g_hash_table_destroy (iface_hash);
if (!domain->empty_types) {
domain->empty_types = mono_array_new_cached (mono_defaults.runtimetype_class, 0, error);
goto_if_nok (error, fail);
}
HANDLE_ON_STACK_SET (res, domain->empty_types);
return;
}
FillIfaceArrayData data;
data.iface_array = MONO_HANDLE_NEW (MonoArray, mono_array_new_cached (mono_defaults.runtimetype_class, len, error));
goto_if_nok (error, fail);
data.context = context;
data.error = error;
data.next_idx = 0;
g_hash_table_foreach (iface_hash, fill_iface_array, &data);
goto_if_nok (error, fail);
g_hash_table_destroy (iface_hash);
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (data.iface_array));
return;
fail:
g_hash_table_destroy (iface_hash);
}
static gboolean
method_is_reabstracted (MonoMethod *method)
{
/* only on interfaces */
/* method is marked "final abstract" */
/* FIXME: we need some other way to detect reabstracted methods. "final" is an incidental detail of the spec. */
return m_method_is_final (method) && m_method_is_abstract (method);
}
static gboolean
method_is_dim (MonoMethod *method)
{
/* only valid on interface methods*/
/* method is marked "virtual" but not "virtual abstract" */
return m_method_is_virtual (method) && !m_method_is_abstract (method);
}
static gboolean
set_interface_map_data_method_object (MonoMethod *method, MonoClass *iclass, int ioffset, MonoClass *klass, MonoArrayHandle targets, MonoArrayHandle methods, int i, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoReflectionMethodHandle member = mono_method_get_object_handle (method, iclass, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (methods, i, member);
MonoMethod* foundMethod = m_class_get_vtable (klass) [i + ioffset];
if (mono_class_has_dim_conflicts (klass) && mono_class_is_interface (foundMethod->klass)) {
GSList* conflicts = mono_class_get_dim_conflicts (klass);
GSList* l;
MonoMethod* decl = method;
if (decl->is_inflated)
decl = ((MonoMethodInflated*)decl)->declaring;
gboolean in_conflict = FALSE;
for (l = conflicts; l; l = l->next) {
if (decl == l->data) {
in_conflict = TRUE;
break;
}
}
if (in_conflict) {
MONO_HANDLE_ARRAY_SETREF (targets, i, NULL_HANDLE);
goto leave;
}
}
/*
* if the iterface method is reabstracted, and either the found implementation method is abstract, or the found
* implementation method is from another DIM (meaning neither klass nor any of its ancestor classes implemented
* the method), then say the target method is null.
*/
if (method_is_reabstracted (method) &&
(m_method_is_abstract (foundMethod) ||
(mono_class_is_interface (foundMethod->klass) && method_is_dim (foundMethod))))
MONO_HANDLE_ARRAY_SETREF (targets, i, NULL_HANDLE);
else if (mono_class_is_interface (foundMethod->klass) && method_is_reabstracted (foundMethod) && !m_class_is_abstract (klass)) {
/* if the method we found is a reabstracted DIM method, but the class isn't abstract, return NULL */
/*
* (C# doesn't seem to allow constructing such types, it requires the whole class to be abstract - in
* which case we are supposed to return the reabstracted interface method. But in IL we can make a
* non-abstract class with reabstracted interface methods - which is supposed to fail with an
* EntryPointNotFoundException at invoke time, but does not prevent the class from loading.)
*/
MONO_HANDLE_ARRAY_SETREF (targets, i, NULL_HANDLE);
} else {
MONO_HANDLE_ASSIGN (member, mono_method_get_object_handle (foundMethod, mono_class_is_interface (foundMethod->klass) ? foundMethod->klass : klass, error));
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (targets, i, member);
}
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
void
ves_icall_RuntimeType_GetInterfaceMapData (MonoQCallTypeHandle type_handle, MonoQCallTypeHandle iface_handle, MonoArrayHandleOut targets, MonoArrayHandleOut methods, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
MonoType *iface = iface_handle.type;
MonoClass *iclass = mono_class_from_mono_type_internal (iface);
mono_class_init_checked (klass, error);
return_if_nok (error);
mono_class_init_checked (iclass, error);
return_if_nok (error);
mono_class_setup_vtable (klass);
gboolean variance_used;
int ioffset = mono_class_interface_offset_with_variance (klass, iclass, &variance_used);
if (ioffset == -1)
return;
MonoMethod* method;
int i = 0;
gpointer iter = NULL;
while ((method = mono_class_get_methods(iclass, &iter))) {
if (method->flags & METHOD_ATTRIBUTE_VIRTUAL)
i++;
}
MonoArrayHandle targets_arr = mono_array_new_handle (mono_defaults.method_info_class, i, error);
return_if_nok (error);
MONO_HANDLE_ASSIGN (targets, targets_arr);
MonoArrayHandle methods_arr = mono_array_new_handle (mono_defaults.method_info_class, i, error);
return_if_nok (error);
MONO_HANDLE_ASSIGN (methods, methods_arr);
i = 0;
iter = NULL;
while ((method = mono_class_get_methods (iclass, &iter))) {
if (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL))
continue;
if (!set_interface_map_data_method_object (method, iclass, ioffset, klass, targets, methods, i, error))
return;
i ++;
}
}
void
ves_icall_RuntimeType_GetPacking (MonoQCallTypeHandle type_handle, guint32 *packing, guint32 *size, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_if_nok (error);
if (image_is_dynamic (m_class_get_image (klass))) {
MonoGCHandle ref_info_handle = mono_class_get_ref_info_handle (klass);
g_assert (ref_info_handle);
MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder*)mono_gchandle_get_target_internal (ref_info_handle);
g_assert (tb);
*packing = tb->packing_size;
*size = tb->class_size;
} else {
mono_metadata_packing_from_typedef (m_class_get_image (klass), m_class_get_type_token (klass), packing, size);
}
}
void
ves_icall_RuntimeTypeHandle_GetElementType (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
if (!m_type_is_byref (type) && type->type == MONO_TYPE_SZARRAY) {
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (type->data.klass), error));
return;
}
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_if_nok (error);
// GetElementType should only return a type for:
// Array Pointer PassedByRef
if (m_type_is_byref (type))
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (klass), error));
else if (m_class_get_element_class (klass) && MONO_CLASS_IS_ARRAY (klass))
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (m_class_get_element_class (klass)), error));
else if (m_class_get_element_class (klass) && type->type == MONO_TYPE_PTR)
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (m_class_get_element_class (klass)), error));
else
HANDLE_ON_STACK_SET (res, NULL);
}
void
ves_icall_RuntimeTypeHandle_GetBaseType (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return;
MonoClass *klass = mono_class_from_mono_type_internal (type);
if (!m_class_get_parent (klass))
return;
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (m_class_get_parent (klass)), error));
}
guint32
ves_icall_RuntimeTypeHandle_GetCorElementType (MonoQCallTypeHandle type_handle)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return MONO_TYPE_BYREF;
else
return (guint32)type->type;
}
MonoBoolean
ves_icall_RuntimeTypeHandle_HasReferences (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass;
klass = mono_class_from_mono_type_internal (type);
mono_class_init_internal (klass);
return m_class_has_references (klass);
}
MonoBoolean
ves_icall_RuntimeTypeHandle_IsByRefLike (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
/* .NET Core says byref types are not IsByRefLike */
if (m_type_is_byref (type))
return FALSE;
MonoClass *klass = mono_class_from_mono_type_internal (type);
return m_class_is_byreflike (klass);
}
MonoBoolean
ves_icall_RuntimeTypeHandle_IsComObject (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_val_if_nok (error, FALSE);
return mono_class_is_com_object (klass);
}
guint32
ves_icall_reflection_get_token (MonoObjectHandle obj, MonoError *error)
{
return mono_reflection_get_token_checked (obj, error);
}
void
ves_icall_RuntimeTypeHandle_GetModule (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *t = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (t);
MonoReflectionModuleHandle module;
module = mono_module_get_object_handle (m_class_get_image (klass), error);
return_if_nok (error);
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (module));
}
void
ves_icall_RuntimeTypeHandle_GetAssembly (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *t = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (t);
MonoReflectionAssemblyHandle assembly;
assembly = mono_assembly_get_object_handle (m_class_get_image (klass)->assembly, error);
return_if_nok (error);
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (assembly));
}
void
ves_icall_RuntimeType_GetDeclaringType (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass;
if (m_type_is_byref (type))
return;
if (type->type == MONO_TYPE_VAR) {
MonoGenericContainer *param = mono_type_get_generic_param_owner (type);
klass = param ? param->owner.klass : NULL;
} else if (type->type == MONO_TYPE_MVAR) {
MonoGenericContainer *param = mono_type_get_generic_param_owner (type);
klass = param ? param->owner.method->klass : NULL;
} else {
klass = m_class_get_nested_in (mono_class_from_mono_type_internal (type));
}
if (!klass)
return;
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (klass), error));
}
void
ves_icall_RuntimeType_GetName (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
// FIXME: this should be escaped in some scenarios with mono_identifier_escape_type_name_chars
// Determining exactly when to do so is fairly difficult, so for now we don't bother to avoid regressions
const char *klass_name = m_class_get_name (klass);
if (m_type_is_byref (type)) {
char *n = g_strdup_printf ("%s&", klass_name);
HANDLE_ON_STACK_SET (res, mono_string_new_checked (n, error));
g_free (n);
} else {
HANDLE_ON_STACK_SET (res, mono_string_new_checked (klass_name, error));
}
}
void
ves_icall_RuntimeType_GetNamespace (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
MonoClass *klass_nested_in;
while ((klass_nested_in = m_class_get_nested_in (klass)))
klass = klass_nested_in;
if (m_class_get_name_space (klass) [0] == '\0')
return;
char *escaped = mono_identifier_escape_type_name_chars (m_class_get_name_space (klass));
HANDLE_ON_STACK_SET (res, mono_string_new_checked (escaped, error));
g_free (escaped);
}
gint32
ves_icall_RuntimeTypeHandle_GetArrayRank (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
if (type->type != MONO_TYPE_ARRAY && type->type != MONO_TYPE_SZARRAY) {
mono_error_set_argument (error, "type", "Type must be an array type");
return 0;
}
MonoClass *klass = mono_class_from_mono_type_internal (type);
return m_class_get_rank (klass);
}
static MonoArrayHandle
create_type_array (MonoBoolean runtimeTypeArray, int count, MonoError *error)
{
return mono_array_new_handle (runtimeTypeArray ? mono_defaults.runtimetype_class : mono_defaults.systemtype_class, count, error);
}
static gboolean
set_type_object_in_array (MonoType *type, MonoArrayHandle dest, int i, MonoError *error)
{
HANDLE_FUNCTION_ENTER();
MonoReflectionTypeHandle rt = mono_type_get_object_handle (type, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, i, rt);
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
void
ves_icall_RuntimeType_GetGenericArgumentsInternal (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res_handle, MonoBoolean runtimeTypeArray, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
MonoArrayHandle res = MONO_HANDLE_NEW (MonoArray, NULL);
if (mono_class_is_gtd (klass)) {
MonoGenericContainer *container = mono_class_get_generic_container (klass);
MONO_HANDLE_ASSIGN (res, create_type_array (runtimeTypeArray, container->type_argc, error));
return_if_nok (error);
for (int i = 0; i < container->type_argc; ++i) {
MonoClass *pklass = mono_class_create_generic_parameter (mono_generic_container_get_param (container, i));
if (!set_type_object_in_array (m_class_get_byval_arg (pklass), res, i, error))
return;
}
} else if (mono_class_is_ginst (klass)) {
MonoGenericInst *inst = mono_class_get_generic_class (klass)->context.class_inst;
MONO_HANDLE_ASSIGN (res, create_type_array (runtimeTypeArray, inst->type_argc, error));
return_if_nok (error);
for (int i = 0; i < inst->type_argc; ++i) {
if (!set_type_object_in_array (inst->type_argv [i], res, i, error))
return;
}
}
HANDLE_ON_STACK_SET(res_handle, MONO_HANDLE_RAW (res));
}
MonoBoolean
ves_icall_RuntimeTypeHandle_IsGenericTypeDefinition (MonoQCallTypeHandle type_handle)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return FALSE;
MonoClass *klass = mono_class_from_mono_type_internal (type);
return mono_class_is_gtd (klass);
}
void
ves_icall_RuntimeTypeHandle_GetGenericTypeDefinition_impl (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return;
MonoClass *klass;
klass = mono_class_from_mono_type_internal (type);
if (mono_class_is_gtd (klass)) {
HANDLE_ON_STACK_SET (res, NULL);
return;
}
if (mono_class_is_ginst (klass)) {
MonoClass *generic_class = mono_class_get_generic_class (klass)->container_class;
MonoGCHandle ref_info_handle = mono_class_get_ref_info_handle (generic_class);
if (m_class_was_typebuilder (generic_class) && ref_info_handle) {
MonoObjectHandle tb = mono_gchandle_get_target_handle (ref_info_handle);
g_assert (!MONO_HANDLE_IS_NULL (tb));
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (tb));
} else {
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (generic_class), error));
}
}
}
void
ves_icall_RuntimeType_MakeGenericType (MonoReflectionTypeHandle reftype, MonoArrayHandle type_array, MonoObjectHandleOnStack res, MonoError *error)
{
g_assert (IS_MONOTYPE_HANDLE (reftype));
MonoType *type = MONO_HANDLE_GETVAL (reftype, type);
mono_class_init_checked (mono_class_from_mono_type_internal (type), error);
return_if_nok (error);
int count = mono_array_handle_length (type_array);
MonoType **types = g_new0 (MonoType *, count);
MonoReflectionTypeHandle t = MONO_HANDLE_NEW (MonoReflectionType, NULL);
for (int i = 0; i < count; i++) {
MONO_HANDLE_ARRAY_GETREF (t, type_array, i);
types [i] = MONO_HANDLE_GETVAL (t, type);
}
MonoType *geninst = mono_reflection_bind_generic_parameters (reftype, count, types, error);
g_free (types);
if (!geninst)
return;
MonoClass *klass = mono_class_from_mono_type_internal (geninst);
/*we might inflate to the GTD*/
if (mono_class_is_ginst (klass) && !mono_verifier_class_is_valid_generic_instantiation (klass)) {
mono_error_set_argument (error, "typeArguments", "Invalid generic arguments");
return;
}
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (geninst, error));
}
MonoBoolean
ves_icall_RuntimeTypeHandle_HasInstantiation (MonoQCallTypeHandle type_handle)
{
MonoClass *klass;
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return FALSE;
klass = mono_class_from_mono_type_internal (type);
return mono_class_is_ginst (klass) || mono_class_is_gtd (klass);
}
gint32
ves_icall_RuntimeType_GetGenericParameterPosition (MonoQCallTypeHandle type_handle)
{
MonoType *type = type_handle.type;
if (is_generic_parameter (type))
return mono_type_get_generic_param_num (type);
return -1;
}
MonoGenericParamInfo *
ves_icall_RuntimeTypeHandle_GetGenericParameterInfo (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
return mono_generic_param_info (type->data.generic_param);
}
MonoReflectionMethodHandle
ves_icall_RuntimeType_GetCorrespondingInflatedMethod (MonoQCallTypeHandle type_handle,
MonoReflectionMethodHandle generic,
MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
MonoMethod *generic_method = MONO_HANDLE_GETVAL (generic, method);
MonoReflectionMethodHandle ret = MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
MonoMethod *method;
gpointer iter = NULL;
while ((method = mono_class_get_methods (klass, &iter))) {
if (method->token == generic_method->token) {
ret = mono_method_get_object_handle (method, klass, error);
return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
}
}
return ret;
}
void
ves_icall_RuntimeType_GetDeclaringMethod (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type) || (type->type != MONO_TYPE_MVAR && type->type != MONO_TYPE_VAR)) {
mono_error_set_invalid_operation (error, "DeclaringMethod can only be used on generic arguments");
return;
}
if (type->type == MONO_TYPE_VAR)
return;
MonoMethod *method;
method = mono_type_get_generic_param_owner (type)->owner.method;
g_assert (method);
HANDLE_ON_STACK_SET (res, mono_method_get_object_checked (method, method->klass, error));
}
void
ves_icall_RuntimeMethodInfo_GetPInvoke (MonoReflectionMethodHandle ref_method, int* flags, MonoStringHandleOut entry_point, MonoStringHandleOut dll_name, MonoError *error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
MonoImage *image = m_class_get_image (method->klass);
MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)method;
MonoTableInfo *tables = image->tables;
MonoTableInfo *im = &tables [MONO_TABLE_IMPLMAP];
MonoTableInfo *mr = &tables [MONO_TABLE_MODULEREF];
guint32 im_cols [MONO_IMPLMAP_SIZE];
guint32 scope_token;
const char *import = NULL;
const char *scope = NULL;
if (image_is_dynamic (image)) {
MonoReflectionMethodAux *method_aux =
(MonoReflectionMethodAux *)g_hash_table_lookup (((MonoDynamicImage*)image)->method_aux_hash, method);
if (method_aux) {
import = method_aux->dllentry;
scope = method_aux->dll;
}
if (!import || !scope) {
mono_error_set_argument (error, "method", "System.Refleciton.Emit method with invalid pinvoke information");
return;
}
}
else {
if (piinfo->implmap_idx) {
mono_metadata_decode_row (im, piinfo->implmap_idx - 1, im_cols, MONO_IMPLMAP_SIZE);
piinfo->piflags = im_cols [MONO_IMPLMAP_FLAGS];
import = mono_metadata_string_heap (image, im_cols [MONO_IMPLMAP_NAME]);
scope_token = mono_metadata_decode_row_col (mr, im_cols [MONO_IMPLMAP_SCOPE] - 1, MONO_MODULEREF_NAME);
scope = mono_metadata_string_heap (image, scope_token);
}
}
*flags = piinfo->piflags;
MONO_HANDLE_ASSIGN (entry_point, mono_string_new_handle (import, error));
return_if_nok (error);
MONO_HANDLE_ASSIGN (dll_name, mono_string_new_handle (scope, error));
}
MonoReflectionMethodHandle
ves_icall_RuntimeMethodInfo_GetGenericMethodDefinition (MonoReflectionMethodHandle ref_method, MonoError *error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
if (method->is_generic)
return ref_method;
if (!method->is_inflated)
return MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
MonoMethodInflated *imethod = (MonoMethodInflated *) method;
MonoMethod *result = imethod->declaring;
/* Not a generic method. */
if (!result->is_generic)
return MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
if (image_is_dynamic (m_class_get_image (method->klass))) {
MonoDynamicImage *image = (MonoDynamicImage*)m_class_get_image (method->klass);
/*
* FIXME: Why is this stuff needed at all ? Why can't the code below work for
* the dynamic case as well ?
*/
mono_image_lock ((MonoImage*)image);
MonoReflectionMethodHandle res = MONO_HANDLE_NEW (MonoReflectionMethod, (MonoReflectionMethod*)mono_g_hash_table_lookup (image->generic_def_objects, imethod));
mono_image_unlock ((MonoImage*)image);
if (!MONO_HANDLE_IS_NULL (res))
return res;
}
if (imethod->context.class_inst) {
MonoClass *klass = ((MonoMethod *) imethod)->klass;
/*Generic methods gets the context of the GTD.*/
if (mono_class_get_context (klass)) {
result = mono_class_inflate_generic_method_full_checked (result, klass, mono_class_get_context (klass), error);
return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
}
}
return mono_method_get_object_handle (result, NULL, error);
}
static GENERATE_TRY_GET_CLASS_WITH_CACHE (stream, "System.IO", "Stream")
static int io_stream_begin_read_slot = -1;
static int io_stream_begin_write_slot = -1;
static int io_stream_end_read_slot = -1;
static int io_stream_end_write_slot = -1;
static gboolean io_stream_slots_set = FALSE;
static void
init_io_stream_slots (void)
{
MonoClass* klass = mono_class_try_get_stream_class ();
mono_class_setup_vtable (klass);
MonoMethod **klass_methods = m_class_get_methods (klass);
if (!klass_methods) {
mono_class_setup_methods (klass);
klass_methods = m_class_get_methods (klass);
}
int method_count = mono_class_get_method_count (klass);
int methods_found = 0;
for (int i = 0; i < method_count; i++) {
// find slots for Begin(End)Read and Begin(End)Write
MonoMethod* m = klass_methods [i];
if (m->slot == -1)
continue;
if (!strcmp (m->name, "BeginRead")) {
methods_found++;
io_stream_begin_read_slot = m->slot;
} else if (!strcmp (m->name, "BeginWrite")) {
methods_found++;
io_stream_begin_write_slot = m->slot;
} else if (!strcmp (m->name, "EndRead")) {
methods_found++;
io_stream_end_read_slot = m->slot;
} else if (!strcmp (m->name, "EndWrite")) {
methods_found++;
io_stream_end_write_slot = m->slot;
}
}
g_assert (methods_found <= 4); // some of them can be linked out
io_stream_slots_set = TRUE;
}
MonoBoolean
ves_icall_System_IO_Stream_HasOverriddenBeginEndRead (MonoObjectHandle stream, MonoError *error)
{
MonoClass* curr_klass = MONO_HANDLE_GET_CLASS (stream);
MonoClass* base_klass = mono_class_try_get_stream_class ();
if (!io_stream_slots_set)
init_io_stream_slots ();
// slots can still be -1 and it means Linker removed the methods from the base class (Stream)
// in this case we can safely assume the methods are not overridden
// otherwise - check vtable
MonoMethod **curr_klass_vtable = m_class_get_vtable (curr_klass);
gboolean begin_read_is_overriden = io_stream_begin_read_slot != -1 && curr_klass_vtable [io_stream_begin_read_slot]->klass != base_klass;
gboolean end_read_is_overriden = io_stream_end_read_slot != -1 && curr_klass_vtable [io_stream_end_read_slot]->klass != base_klass;
// return true if BeginRead or EndRead were overriden
return begin_read_is_overriden || end_read_is_overriden;
}
MonoBoolean
ves_icall_System_IO_Stream_HasOverriddenBeginEndWrite (MonoObjectHandle stream, MonoError *error)
{
MonoClass* curr_klass = MONO_HANDLE_GETVAL (stream, vtable)->klass;
MonoClass* base_klass = mono_class_try_get_stream_class ();
if (!io_stream_slots_set)
init_io_stream_slots ();
// slots can still be -1 and it means Linker removed the methods from the base class (Stream)
// in this case we can safely assume the methods are not overridden
// otherwise - check vtable
MonoMethod **curr_klass_vtable = m_class_get_vtable (curr_klass);
gboolean begin_write_is_overriden = io_stream_begin_write_slot != -1 && curr_klass_vtable [io_stream_begin_write_slot]->klass != base_klass;
gboolean end_write_is_overriden = io_stream_end_write_slot != -1 && curr_klass_vtable [io_stream_end_write_slot]->klass != base_klass;
// return true if BeginWrite or EndWrite were overriden
return begin_write_is_overriden || end_write_is_overriden;
}
MonoBoolean
ves_icall_RuntimeMethodInfo_get_IsGenericMethod (MonoReflectionMethodHandle ref_method, MonoError *erro)
{
MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
return mono_method_signature_internal (method)->generic_param_count != 0;
}
MonoBoolean
ves_icall_RuntimeMethodInfo_get_IsGenericMethodDefinition (MonoReflectionMethodHandle ref_method, MonoError *Error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
return method->is_generic;
}
static gboolean
set_array_generic_argument_handle_inflated (MonoGenericInst *inst, int i, MonoArrayHandle arr, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoReflectionTypeHandle rt = mono_type_get_object_handle (inst->type_argv [i], error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (arr, i, rt);
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
static gboolean
set_array_generic_argument_handle_gparam (MonoGenericContainer *container, int i, MonoArrayHandle arr, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoGenericParam *param = mono_generic_container_get_param (container, i);
MonoClass *pklass = mono_class_create_generic_parameter (param);
MonoReflectionTypeHandle rt = mono_type_get_object_handle (m_class_get_byval_arg (pklass), error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (arr, i, rt);
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
MonoArrayHandle
ves_icall_RuntimeMethodInfo_GetGenericArguments (MonoReflectionMethodHandle ref_method, MonoError *error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
if (method->is_inflated) {
MonoGenericInst *inst = mono_method_get_context (method)->method_inst;
if (inst) {
int count = inst->type_argc;
MonoArrayHandle res = mono_array_new_handle (mono_defaults.systemtype_class, count, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
for (int i = 0; i < count; i++) {
if (!set_array_generic_argument_handle_inflated (inst, i, res, error))
break;
}
return_val_if_nok (error, NULL_HANDLE_ARRAY);
return res;
}
}
int count = mono_method_signature_internal (method)->generic_param_count;
MonoArrayHandle res = mono_array_new_handle (mono_defaults.systemtype_class, count, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
MonoGenericContainer *container = mono_method_get_generic_container (method);
for (int i = 0; i < count; i++) {
if (!set_array_generic_argument_handle_gparam (container, i, res, error))
break;
}
return_val_if_nok (error, NULL_HANDLE_ARRAY);
return res;
}
MonoObjectHandle
ves_icall_InternalInvoke (MonoReflectionMethodHandle method_handle, MonoObjectHandle this_arg_handle,
MonoSpanOfObjects *params_span, MonoExceptionHandleOut exception_out, MonoError *error)
{
MonoReflectionMethod* const method = MONO_HANDLE_RAW (method_handle);
MonoObject* const this_arg = MONO_HANDLE_RAW (this_arg_handle);
g_assert (params_span != NULL);
/*
* Invoke from reflection is supposed to always be a virtual call (the API
* is stupid), mono_runtime_invoke_*() calls the provided method, allowing
* greater flexibility.
*/
MonoMethod *m = method->method;
MonoMethodSignature* const sig = mono_method_signature_internal (m);
int pcount = 0;
void *obj = this_arg;
MonoObject *result = NULL;
MonoArray *arr = NULL;
MonoException *exception = NULL;
*MONO_HANDLE_REF (exception_out) = NULL;
if (!(m->flags & METHOD_ATTRIBUTE_STATIC)) {
if (!mono_class_vtable_checked (m->klass, error)) {
mono_error_cleanup (error); /* FIXME does this make sense? */
error_init_reuse (error);
exception = mono_class_get_exception_for_failure (m->klass);
goto return_null;
}
if (this_arg) {
m = mono_object_get_virtual_method_internal (this_arg, m);
/* must pass the pointer to the value for valuetype methods */
if (m_class_is_valuetype (m->klass)) {
obj = mono_object_unbox_internal (this_arg);
// FIXMEcoop? Does obj need to be put into a handle?
}
} else if (strcmp (m->name, ".ctor") && !m->wrapper_type) {
exception = mono_exception_from_name_msg (mono_defaults.corlib, "System.Reflection", "TargetException", "Non-static method requires a target.");
goto return_null;
}
}
/* Array constructor */
if (m_class_get_rank (m->klass) && !strcmp (m->name, ".ctor")) {
int i;
pcount = mono_span_length (params_span);
uintptr_t * const lengths = g_newa (uintptr_t, pcount);
/* Note: the synthetized array .ctors have int32 as argument type */
for (i = 0; i < pcount; ++i)
lengths [i] = *(int32_t*) ((char*)mono_span_get (params_span, MonoObject*, i) + sizeof (MonoObject));
if (m_class_get_rank (m->klass) == 1 && sig->param_count == 2 && m_class_get_rank (m_class_get_element_class (m->klass))) {
/* This is a ctor for jagged arrays. MS creates an array of arrays. */
arr = mono_array_new_full_checked (m->klass, lengths, NULL, error);
goto_if_nok (error, return_null);
MonoArrayHandle subarray_handle = MONO_HANDLE_NEW (MonoArray, NULL);
for (i = 0; i < mono_array_length_internal (arr); ++i) {
MonoArray *subarray = mono_array_new_full_checked (m_class_get_element_class (m->klass), &lengths [1], NULL, error);
goto_if_nok (error, return_null);
MONO_HANDLE_ASSIGN_RAW (subarray_handle, subarray); // FIXME? Overkill?
mono_array_setref_fast (arr, i, subarray);
}
goto exit;
}
if (m_class_get_rank (m->klass) == pcount) {
/* Only lengths provided. */
arr = mono_array_new_full_checked (m->klass, lengths, NULL, error);
goto_if_nok (error, return_null);
goto exit;
} else {
g_assert (pcount == (m_class_get_rank (m->klass) * 2));
/* The arguments are lower-bound-length pairs */
intptr_t * const lower_bounds = (intptr_t *)g_alloca (sizeof (intptr_t) * pcount);
for (i = 0; i < pcount / 2; ++i) {
lower_bounds [i] = *(int32_t*) ((char*)mono_span_get (params_span, MonoObject*, (i * 2)) + sizeof (MonoObject));
lengths [i] = *(int32_t*) ((char*)mono_span_get (params_span, MonoObject*, (i * 2) + 1) + sizeof (MonoObject));
}
arr = mono_array_new_full_checked (m->klass, lengths, lower_bounds, error);
goto_if_nok (error, return_null);
goto exit;
}
}
result = mono_runtime_invoke_span_checked (m, obj, params_span, error);
goto exit;
return_null:
result = NULL;
arr = NULL;
exit:
if (exception) {
MONO_HANDLE_NEW (MonoException, exception); // FIXME? overkill?
mono_gc_wbarrier_generic_store_internal (MONO_HANDLE_REF (exception_out), (MonoObject*)exception);
}
g_assert (!result || !arr); // only one, or neither, should be set
return result ? MONO_HANDLE_NEW (MonoObject, result) : arr ? MONO_HANDLE_NEW (MonoObject, (MonoObject*)arr) : NULL_HANDLE;
}
static guint64
read_enum_value (const char *mem, int type)
{
switch (type) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_U1:
return *(guint8*)mem;
case MONO_TYPE_I1:
return *(gint8*)mem;
case MONO_TYPE_CHAR:
case MONO_TYPE_U2:
return read16 (mem);
case MONO_TYPE_I2:
return (gint16) read16 (mem);
case MONO_TYPE_U4:
case MONO_TYPE_R4:
return read32 (mem);
case MONO_TYPE_I4:
return (gint32) read32 (mem);
case MONO_TYPE_U8:
case MONO_TYPE_I8:
case MONO_TYPE_R8:
return read64 (mem);
case MONO_TYPE_U:
case MONO_TYPE_I:
#if SIZEOF_REGISTER == 8
return read64 (mem);
#else
return read32 (mem);
#endif
default:
g_assert_not_reached ();
}
return 0;
}
static void
write_enum_value (void *mem, int type, guint64 value)
{
switch (type) {
case MONO_TYPE_U1:
case MONO_TYPE_I1:
case MONO_TYPE_BOOLEAN: {
guint8 *p = (guint8*)mem;
*p = value;
break;
}
case MONO_TYPE_U2:
case MONO_TYPE_I2:
case MONO_TYPE_CHAR: {
guint16 *p = (guint16 *)mem;
*p = value;
break;
}
case MONO_TYPE_U4:
case MONO_TYPE_I4:
case MONO_TYPE_R4: {
guint32 *p = (guint32 *)mem;
*p = value;
break;
}
case MONO_TYPE_U8:
case MONO_TYPE_I8:
case MONO_TYPE_R8: {
guint64 *p = (guint64 *)mem;
*p = value;
break;
}
case MONO_TYPE_U:
case MONO_TYPE_I: {
#if SIZEOF_REGISTER == 8
guint64 *p = (guint64 *)mem;
*p = value;
#else
guint32 *p = (guint32 *)mem;
*p = value;
break;
#endif
break;
}
default:
g_assert_not_reached ();
}
return;
}
void
ves_icall_System_Enum_InternalBoxEnum (MonoQCallTypeHandle enum_handle, MonoObjectHandleOnStack res, guint64 value, MonoError *error)
{
MonoClass *enumc;
MonoObjectHandle resultHandle;
MonoType *etype;
enumc = mono_class_from_mono_type_internal (enum_handle.type);
mono_class_init_checked (enumc, error);
return_if_nok (error);
etype = mono_class_enum_basetype_internal (enumc);
resultHandle = mono_object_new_handle (enumc, error);
return_if_nok (error);
write_enum_value (mono_handle_unbox_unsafe (resultHandle), etype->type, value);
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (resultHandle));
}
void
ves_icall_System_Enum_InternalGetUnderlyingType (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *etype;
MonoClass *klass;
klass = mono_class_from_mono_type_internal (type_handle.type);
mono_class_init_checked (klass, error);
return_if_nok (error);
etype = mono_class_enum_basetype_internal (klass);
if (!etype) {
mono_error_set_argument (error, "enumType", "Type provided must be an Enum.");
return;
}
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (etype, error));
}
int
ves_icall_System_Enum_InternalGetCorElementType (MonoQCallTypeHandle type_handle)
{
MonoClass *klass = mono_class_from_mono_type_internal (type_handle.type);
return (int)m_class_get_byval_arg (m_class_get_element_class (klass))->type;
}
static void
get_enum_field (MonoArrayHandle names, MonoArrayHandle values, int base_type, MonoClassField *field, guint* j, guint64 *previous_value, gboolean *sorted, MonoError *error)
{
HANDLE_FUNCTION_ENTER();
guint64 field_value;
const char *p;
MonoTypeEnum def_type;
if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
goto leave;
if (strcmp ("value__", mono_field_get_name (field)) == 0)
goto leave;
if (mono_field_is_deleted (field))
goto leave;
MonoStringHandle name;
name = mono_string_new_handle (mono_field_get_name (field), error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (names, *j, name);
p = mono_class_get_field_default_value (field, &def_type);
/* len = */ mono_metadata_decode_blob_size (p, &p);
field_value = read_enum_value (p, base_type);
MONO_HANDLE_ARRAY_SETVAL (values, guint64, *j, field_value);
if (*previous_value > field_value)
*sorted = FALSE;
*previous_value = field_value;
(*j)++;
leave:
HANDLE_FUNCTION_RETURN();
}
MonoBoolean
ves_icall_System_Enum_GetEnumValuesAndNames (MonoQCallTypeHandle type_handle, MonoArrayHandleOut values, MonoArrayHandleOut names, MonoError *error)
{
MonoClass *enumc = mono_class_from_mono_type_internal (type_handle.type);
guint j = 0, nvalues;
gpointer iter;
MonoClassField *field;
int base_type;
guint64 previous_value = 0;
gboolean sorted = TRUE;
mono_class_init_checked (enumc, error);
return_val_if_nok (error, FALSE);
if (!m_class_is_enumtype (enumc)) {
mono_error_set_argument (error, NULL, "Type provided must be an Enum.");
return TRUE;
}
base_type = mono_class_enum_basetype_internal (enumc)->type;
nvalues = mono_class_num_fields (enumc) > 0 ? mono_class_num_fields (enumc) - 1 : 0;
MONO_HANDLE_ASSIGN(names, mono_array_new_handle (mono_defaults.string_class, nvalues, error));
return_val_if_nok (error, FALSE);
MONO_HANDLE_ASSIGN(values, mono_array_new_handle (mono_defaults.uint64_class, nvalues, error));
return_val_if_nok (error, FALSE);
iter = NULL;
while ((field = mono_class_get_fields_internal (enumc, &iter))) {
get_enum_field (names, values, base_type, field, &j, &previous_value, &sorted, error);
if (!is_ok (error))
break;
}
return_val_if_nok (error, FALSE);
return sorted || base_type == MONO_TYPE_R4 || base_type == MONO_TYPE_R8;
}
enum {
BFLAGS_IgnoreCase = 1,
BFLAGS_DeclaredOnly = 2,
BFLAGS_Instance = 4,
BFLAGS_Static = 8,
BFLAGS_Public = 0x10,
BFLAGS_NonPublic = 0x20,
BFLAGS_FlattenHierarchy = 0x40,
BFLAGS_InvokeMethod = 0x100,
BFLAGS_CreateInstance = 0x200,
BFLAGS_GetField = 0x400,
BFLAGS_SetField = 0x800,
BFLAGS_GetProperty = 0x1000,
BFLAGS_SetProperty = 0x2000,
BFLAGS_ExactBinding = 0x10000,
BFLAGS_SuppressChangeType = 0x20000,
BFLAGS_OptionalParamBinding = 0x40000
};
enum {
MLISTTYPE_All = 0,
MLISTTYPE_CaseSensitive = 1,
MLISTTYPE_CaseInsensitive = 2,
MLISTTYPE_HandleToInfo = 3
};
GPtrArray*
ves_icall_RuntimeType_GetFields_native (MonoQCallTypeHandle type_handle, char *utf8_name, guint32 bflags, guint32 mlisttype, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return g_ptr_array_new ();
int (*compare_func) (const char *s1, const char *s2) = NULL;
compare_func = ((bflags & BFLAGS_IgnoreCase) || (mlisttype == MLISTTYPE_CaseInsensitive)) ? mono_utf8_strcasecmp : strcmp;
MonoClass *startklass, *klass;
klass = startklass = mono_class_from_mono_type_internal (type);
GPtrArray *ptr_array = g_ptr_array_sized_new (16);
handle_parent:
if (mono_class_has_failure (klass)) {
mono_error_set_for_class_failure (error, klass);
goto fail;
}
MonoClassField *field;
gpointer iter;
iter = NULL;
while ((field = mono_class_get_fields_lazy (klass, &iter))) {
guint32 flags = mono_field_get_flags (field);
int match = 0;
if (mono_field_is_deleted_with_flags (field, flags))
continue;
if ((flags & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
if (bflags & BFLAGS_Public)
match++;
} else if ((klass == startklass) || (flags & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) != FIELD_ATTRIBUTE_PRIVATE) {
if (bflags & BFLAGS_NonPublic) {
match++;
}
}
if (!match)
continue;
match = 0;
if (flags & FIELD_ATTRIBUTE_STATIC) {
if (bflags & BFLAGS_Static)
if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
match++;
} else {
if (bflags & BFLAGS_Instance)
match++;
}
if (!match)
continue;
if (((mlisttype != MLISTTYPE_All) && (utf8_name != NULL)) && compare_func (mono_field_get_name (field), utf8_name))
continue;
g_ptr_array_add (ptr_array, field);
}
if (!(bflags & BFLAGS_DeclaredOnly) && (klass = m_class_get_parent (klass)))
goto handle_parent;
return ptr_array;
fail:
g_ptr_array_free (ptr_array, TRUE);
return NULL;
}
static gboolean
method_nonpublic (MonoMethod* method, gboolean start_klass)
{
switch (method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) {
case METHOD_ATTRIBUTE_ASSEM:
return TRUE;
case METHOD_ATTRIBUTE_PRIVATE:
return start_klass;
case METHOD_ATTRIBUTE_PUBLIC:
return FALSE;
default:
return TRUE;
}
}
GPtrArray*
mono_class_get_methods_by_name (MonoClass *klass, const char *name, guint32 bflags, guint32 mlisttype, gboolean allow_ctors, MonoError *error)
{
GPtrArray *array;
MonoClass *startklass;
MonoMethod *method;
gpointer iter;
int match, nslots;
/*FIXME, use MonoBitSet*/
guint32 method_slots_default [8];
guint32 *method_slots = NULL;
int (*compare_func) (const char *s1, const char *s2) = NULL;
array = g_ptr_array_new ();
startklass = klass;
compare_func = ((bflags & BFLAGS_IgnoreCase) || (mlisttype == MLISTTYPE_CaseInsensitive)) ? mono_utf8_strcasecmp : strcmp;
/* An optimization for calls made from Delegate:CreateDelegate () */
if (m_class_is_delegate (klass) && klass != mono_defaults.delegate_class && klass != mono_defaults.multicastdelegate_class && name && !strcmp (name, "Invoke") && (bflags == (BFLAGS_Public | BFLAGS_Static | BFLAGS_Instance))) {
method = mono_get_delegate_invoke_internal (klass);
g_assert (method);
g_ptr_array_add (array, method);
return array;
}
mono_class_setup_methods (klass);
mono_class_setup_vtable (klass);
if (mono_class_has_failure (klass))
goto loader_error;
if (is_generic_parameter (m_class_get_byval_arg (klass)))
nslots = mono_class_get_vtable_size (m_class_get_parent (klass));
else
nslots = MONO_CLASS_IS_INTERFACE_INTERNAL (klass) ? mono_class_num_methods (klass) : mono_class_get_vtable_size (klass);
if (nslots >= sizeof (method_slots_default) * 8) {
method_slots = g_new0 (guint32, nslots / 32 + 1);
} else {
method_slots = method_slots_default;
memset (method_slots, 0, sizeof (method_slots_default));
}
handle_parent:
mono_class_setup_methods (klass);
mono_class_setup_vtable (klass);
if (mono_class_has_failure (klass))
goto loader_error;
iter = NULL;
while ((method = mono_class_get_methods (klass, &iter))) {
match = 0;
if (method->slot != -1) {
g_assert (method->slot < nslots);
if (method_slots [method->slot >> 5] & (1 << (method->slot & 0x1f)))
continue;
if (!(method->flags & METHOD_ATTRIBUTE_NEW_SLOT))
method_slots [method->slot >> 5] |= 1 << (method->slot & 0x1f);
}
if (!allow_ctors && method->name [0] == '.' && (strcmp (method->name, ".ctor") == 0 || strcmp (method->name, ".cctor") == 0))
continue;
if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
if (bflags & BFLAGS_Public)
match++;
} else if ((bflags & BFLAGS_NonPublic) && method_nonpublic (method, (klass == startklass))) {
match++;
}
if (!match)
continue;
match = 0;
if (method->flags & METHOD_ATTRIBUTE_STATIC) {
if (bflags & BFLAGS_Static)
if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
match++;
} else {
if (bflags & BFLAGS_Instance)
match++;
}
if (!match)
continue;
if ((mlisttype != MLISTTYPE_All) && (name != NULL)) {
if (compare_func (name, method->name))
continue;
}
match = 0;
g_ptr_array_add (array, method);
}
if (!(bflags & BFLAGS_DeclaredOnly) && (klass = m_class_get_parent (klass)))
goto handle_parent;
if (method_slots != method_slots_default)
g_free (method_slots);
return array;
loader_error:
if (method_slots != method_slots_default)
g_free (method_slots);
g_ptr_array_free (array, TRUE);
g_assert (mono_class_has_failure (klass));
mono_error_set_for_class_failure (error, klass);
return NULL;
}
GPtrArray*
ves_icall_RuntimeType_GetMethodsByName_native (MonoQCallTypeHandle type_handle, const char *mname, guint32 bflags, guint32 mlisttype, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
if (m_type_is_byref (type))
return g_ptr_array_new ();
return mono_class_get_methods_by_name (klass, mname, bflags, mlisttype, FALSE, error);
}
GPtrArray*
ves_icall_RuntimeType_GetConstructors_native (MonoQCallTypeHandle type_handle, guint32 bflags, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type)) {
return g_ptr_array_new ();
}
MonoClass *startklass, *klass;
klass = startklass = mono_class_from_mono_type_internal (type);
mono_class_setup_methods (klass);
if (mono_class_has_failure (klass)) {
mono_error_set_for_class_failure (error, klass);
return NULL;
}
GPtrArray *res_array = g_ptr_array_sized_new (4); /* FIXME, guestimating */
MonoMethod *method;
gpointer iter = NULL;
while ((method = mono_class_get_methods (klass, &iter))) {
int match = 0;
if (strcmp (method->name, ".ctor") && strcmp (method->name, ".cctor"))
continue;
if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
if (bflags & BFLAGS_Public)
match++;
} else {
if (bflags & BFLAGS_NonPublic)
match++;
}
if (!match)
continue;
match = 0;
if (method->flags & METHOD_ATTRIBUTE_STATIC) {
if (bflags & BFLAGS_Static)
if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
match++;
} else {
if (bflags & BFLAGS_Instance)
match++;
}
if (!match)
continue;
g_ptr_array_add (res_array, method);
}
return res_array;
}
static guint
property_hash (gconstpointer data)
{
MonoProperty *prop = (MonoProperty*)data;
return g_str_hash (prop->name);
}
static gboolean
property_accessor_override (MonoMethod *method1, MonoMethod *method2)
{
if (method1->slot != -1 && method1->slot == method2->slot)
return TRUE;
if (mono_class_get_generic_type_definition (method1->klass) == mono_class_get_generic_type_definition (method2->klass)) {
if (method1->is_inflated)
method1 = ((MonoMethodInflated*) method1)->declaring;
if (method2->is_inflated)
method2 = ((MonoMethodInflated*) method2)->declaring;
}
return mono_metadata_signature_equal (mono_method_signature_internal (method1), mono_method_signature_internal (method2));
}
static gboolean
property_equal (MonoProperty *prop1, MonoProperty *prop2)
{
// Properties are hide-by-name-and-signature
if (!g_str_equal (prop1->name, prop2->name))
return FALSE;
/* If we see a property in a generic method, we want to
compare the generic signatures, not the inflated signatures
because we might conflate two properties that were
distinct:
class Foo<T,U> {
public T this[T t] { getter { return t; } } // method 1
public U this[U u] { getter { return u; } } // method 2
}
If we see int Foo<int,int>::Item[int] we need to know if
the indexer came from method 1 or from method 2, and we
shouldn't conflate them. (Bugzilla 36283)
*/
if (prop1->get && prop2->get && !property_accessor_override (prop1->get, prop2->get))
return FALSE;
if (prop1->set && prop2->set && !property_accessor_override (prop1->set, prop2->set))
return FALSE;
return TRUE;
}
static gboolean
property_accessor_nonpublic (MonoMethod* accessor, gboolean start_klass)
{
if (!accessor)
return FALSE;
return method_nonpublic (accessor, start_klass);
}
GPtrArray*
ves_icall_RuntimeType_GetPropertiesByName_native (MonoQCallTypeHandle type_handle, gchar *propname, guint32 bflags, guint32 mlisttype, MonoError *error)
{
// Fetch non-public properties as well because they can hide public properties with the same name in base classes
bflags |= BFLAGS_NonPublic;
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return g_ptr_array_new ();
MonoClass *startklass, *klass;
klass = startklass = mono_class_from_mono_type_internal (type);
int (*compare_func) (const char *s1, const char *s2) = (mlisttype == MLISTTYPE_CaseInsensitive) ? mono_utf8_strcasecmp : strcmp;
GPtrArray *res_array = g_ptr_array_sized_new (8); /*This the average for ASP.NET types*/
GHashTable *properties = g_hash_table_new (property_hash, (GEqualFunc)property_equal);
handle_parent:
mono_class_setup_methods (klass);
mono_class_setup_vtable (klass);
if (mono_class_has_failure (klass)) {
mono_error_set_for_class_failure (error, klass);
goto loader_error;
}
MonoProperty *prop;
gpointer iter;
iter = NULL;
while ((prop = mono_class_get_properties (klass, &iter))) {
int match = 0;
MonoMethod *method = prop->get;
if (!method)
method = prop->set;
guint32 flags = 0;
if (method)
flags = method->flags;
if ((prop->get && ((prop->get->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC)) ||
(prop->set && ((prop->set->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC))) {
if (bflags & BFLAGS_Public)
match++;
} else if (bflags & BFLAGS_NonPublic) {
if (property_accessor_nonpublic(prop->get, startklass == klass) ||
property_accessor_nonpublic(prop->set, startklass == klass)) {
match++;
}
}
if (!match)
continue;
match = 0;
if (flags & METHOD_ATTRIBUTE_STATIC) {
if (bflags & BFLAGS_Static)
if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
match++;
} else {
if (bflags & BFLAGS_Instance)
match++;
}
if (!match)
continue;
match = 0;
if ((mlisttype != MLISTTYPE_All) && (propname != NULL) && compare_func (propname, prop->name))
continue;
if (g_hash_table_lookup (properties, prop))
continue;
g_ptr_array_add (res_array, prop);
g_hash_table_insert (properties, prop, prop);
}
if (!(bflags & BFLAGS_DeclaredOnly) && (klass = m_class_get_parent (klass))) {
// BFLAGS_NonPublic should be excluded for base classes
bflags &= ~BFLAGS_NonPublic;
goto handle_parent;
}
g_hash_table_destroy (properties);
return res_array;
loader_error:
if (properties)
g_hash_table_destroy (properties);
g_ptr_array_free (res_array, TRUE);
return NULL;
}
static guint
event_hash (gconstpointer data)
{
MonoEvent *event = (MonoEvent*)data;
return g_str_hash (event->name);
}
static gboolean
event_equal (MonoEvent *event1, MonoEvent *event2)
{
// Events are hide-by-name
return g_str_equal (event1->name, event2->name);
}
GPtrArray*
ves_icall_RuntimeType_GetEvents_native (MonoQCallTypeHandle type_handle, char *utf8_name, guint32 mlisttype, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return g_ptr_array_new ();
int (*compare_func) (const char *s1, const char *s2) = (mlisttype == MLISTTYPE_CaseInsensitive) ? mono_utf8_strcasecmp : strcmp;
GPtrArray *res_array = g_ptr_array_sized_new (4);
MonoClass *startklass, *klass;
klass = startklass = mono_class_from_mono_type_internal (type);
GHashTable *events = g_hash_table_new (event_hash, (GEqualFunc)event_equal);
handle_parent:
mono_class_setup_methods (klass);
mono_class_setup_vtable (klass);
if (mono_class_has_failure (klass)) {
mono_error_set_for_class_failure (error, klass);
goto failure;
}
MonoEvent *event;
gpointer iter;
iter = NULL;
while ((event = mono_class_get_events (klass, &iter))) {
// Remove inherited privates and inherited
// without add/remove/raise methods
if (klass != startklass)
{
MonoMethod *method = event->add;
if (!method)
method = event->remove;
if (!method)
method = event->raise;
if (!method)
continue;
if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PRIVATE)
continue;
}
if ((mlisttype != MLISTTYPE_All) && (utf8_name != NULL) && compare_func (event->name, utf8_name))
continue;
if (g_hash_table_lookup (events, event))
continue;
g_ptr_array_add (res_array, event);
g_hash_table_insert (events, event, event);
}
if ((klass = m_class_get_parent (klass)))
goto handle_parent;
g_hash_table_destroy (events);
return res_array;
failure:
if (events != NULL)
g_hash_table_destroy (events);
g_ptr_array_free (res_array, TRUE);
return NULL;
}
GPtrArray *
ves_icall_RuntimeType_GetNestedTypes_native (MonoQCallTypeHandle type_handle, char *str, guint32 bflags, guint32 mlisttype, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return g_ptr_array_new ();
int (*compare_func) (const char *s1, const char *s2) = ((bflags & BFLAGS_IgnoreCase) || (mlisttype == MLISTTYPE_CaseInsensitive)) ? mono_utf8_strcasecmp : strcmp;
MonoClass *klass = mono_class_from_mono_type_internal (type);
/*
* If a nested type is generic, return its generic type definition.
* Note that this means that the return value is essentially the set
* of nested types of the generic type definition of @klass.
*
* A note in MSDN claims that a generic type definition can have
* nested types that aren't generic. In any case, the container of that
* nested type would be the generic type definition.
*/
if (mono_class_is_ginst (klass))
klass = mono_class_get_generic_class (klass)->container_class;
GPtrArray *res_array = g_ptr_array_new ();
MonoClass *nested;
gpointer iter = NULL;
while ((nested = mono_class_get_nested_types (klass, &iter))) {
int match = 0;
if ((mono_class_get_flags (nested) & TYPE_ATTRIBUTE_VISIBILITY_MASK) == TYPE_ATTRIBUTE_NESTED_PUBLIC) {
if (bflags & BFLAGS_Public)
match++;
} else {
if (bflags & BFLAGS_NonPublic)
match++;
}
if (!match)
continue;
if ((mlisttype != MLISTTYPE_All) && (str != NULL) && compare_func (m_class_get_name (nested), str))
continue;
g_ptr_array_add (res_array, m_class_get_byval_arg (nested));
}
return res_array;
}
static MonoType*
get_type_from_module_builder_module (MonoAssemblyLoadContext *alc, MonoArrayHandle modules, int i, MonoTypeNameParse *info, MonoBoolean ignoreCase, gboolean *type_resolve, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoType *type = NULL;
MonoReflectionModuleBuilderHandle mb = MONO_HANDLE_NEW (MonoReflectionModuleBuilder, NULL);
MONO_HANDLE_ARRAY_GETREF (mb, modules, i);
MonoDynamicImage *dynamic_image = MONO_HANDLE_GETVAL (mb, dynamic_image);
type = mono_reflection_get_type_checked (alc, &dynamic_image->image, &dynamic_image->image, info, ignoreCase, FALSE, type_resolve, error);
HANDLE_FUNCTION_RETURN_VAL (type);
}
static MonoType*
get_type_from_module_builder_loaded_modules (MonoAssemblyLoadContext *alc, MonoArrayHandle loaded_modules, int i, MonoTypeNameParse *info, MonoBoolean ignoreCase, gboolean *type_resolve, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoType *type = NULL;
MonoReflectionModuleHandle mod = MONO_HANDLE_NEW (MonoReflectionModule, NULL);
MONO_HANDLE_ARRAY_GETREF (mod, loaded_modules, i);
MonoImage *image = MONO_HANDLE_GETVAL (mod, image);
type = mono_reflection_get_type_checked (alc, image, image, info, ignoreCase, FALSE, type_resolve, error);
HANDLE_FUNCTION_RETURN_VAL (type);
}
MonoReflectionTypeHandle
ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssemblyHandle assembly_h, MonoReflectionModuleHandle module, MonoStringHandle name, MonoBoolean throwOnError, MonoBoolean ignoreCase, MonoError *error)
{
ERROR_DECL (parse_error);
MonoTypeNameParse info;
gboolean type_resolve;
MonoAssemblyLoadContext *alc = mono_alc_get_ambient ();
/* On MS.NET, this does not fire a TypeResolve event */
type_resolve = TRUE;
char *str = mono_string_handle_to_utf8 (name, error);
goto_if_nok (error, fail);
/*g_print ("requested type %s in %s\n", str, assembly->assembly->aname.name);*/
if (!mono_reflection_parse_type_checked (str, &info, parse_error)) {
g_free (str);
mono_reflection_free_type_info (&info);
mono_error_cleanup (parse_error);
if (throwOnError) {
mono_error_set_argument (error, "typeName@0", "failed to parse the type");
goto fail;
}
/*g_print ("failed parse\n");*/
return MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
}
if (info.assembly.name) {
g_free (str);
mono_reflection_free_type_info (&info);
if (throwOnError) {
mono_error_set_argument (error, NULL, "Type names passed to Assembly.GetType() must not specify an assembly.");
goto fail;
}
return MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
}
MonoType *type;
type = NULL;
if (!MONO_HANDLE_IS_NULL (module)) {
MonoImage *image = MONO_HANDLE_GETVAL (module, image);
if (image) {
type = mono_reflection_get_type_checked (alc, image, image, &info, ignoreCase, FALSE, &type_resolve, error);
if (!is_ok (error)) {
g_free (str);
mono_reflection_free_type_info (&info);
goto fail;
}
}
}
else {
MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_h, assembly);
if (assembly_is_dynamic (assembly)) {
/* Enumerate all modules */
MonoReflectionAssemblyBuilderHandle abuilder = MONO_HANDLE_NEW (MonoReflectionAssemblyBuilder, NULL);
MONO_HANDLE_ASSIGN (abuilder, assembly_h);
int i;
MonoArrayHandle modules = MONO_HANDLE_NEW (MonoArray, NULL);
MONO_HANDLE_GET (modules, abuilder, modules);
if (!MONO_HANDLE_IS_NULL (modules)) {
int n = mono_array_handle_length (modules);
for (i = 0; i < n; ++i) {
type = get_type_from_module_builder_module (alc, modules, i, &info, ignoreCase, &type_resolve, error);
if (!is_ok (error)) {
g_free (str);
mono_reflection_free_type_info (&info);
goto fail;
}
if (type)
break;
}
}
MonoArrayHandle loaded_modules = MONO_HANDLE_NEW (MonoArray, NULL);
MONO_HANDLE_GET (loaded_modules, abuilder, loaded_modules);
if (!type && !MONO_HANDLE_IS_NULL (loaded_modules)) {
int n = mono_array_handle_length (loaded_modules);
for (i = 0; i < n; ++i) {
type = get_type_from_module_builder_loaded_modules (alc, loaded_modules, i, &info, ignoreCase, &type_resolve, error);
if (!is_ok (error)) {
g_free (str);
mono_reflection_free_type_info (&info);
goto fail;
}
if (type)
break;
}
}
}
else {
type = mono_reflection_get_type_checked (alc, assembly->image, assembly->image, &info, ignoreCase, FALSE, &type_resolve, error);
if (!is_ok (error)) {
g_free (str);
mono_reflection_free_type_info (&info);
goto fail;
}
}
}
g_free (str);
mono_reflection_free_type_info (&info);
if (!type) {
if (throwOnError) {
ERROR_DECL (inner_error);
char *type_name = mono_string_handle_to_utf8 (name, inner_error);
mono_error_assert_ok (inner_error);
MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_h, assembly);
char *assmname = mono_stringify_assembly_name (&assembly->aname);
mono_error_set_type_load_name (error, type_name, assmname, "%s", "");
goto fail;
}
return MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
}
if (type->type == MONO_TYPE_CLASS) {
MonoClass *klass = mono_type_get_class_internal (type);
/* need to report exceptions ? */
if (throwOnError && mono_class_has_failure (klass)) {
/* report SecurityException (or others) that occured when loading the assembly */
mono_error_set_for_class_failure (error, klass);
goto fail;
}
}
/* g_print ("got it\n"); */
return mono_type_get_object_handle (type, error);
fail:
g_assert (!is_ok (error));
return MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
}
/* This corresponds to RuntimeAssembly.AssemblyInfoKind */
typedef enum {
ASSEMBLY_INFO_KIND_LOCATION = 1,
ASSEMBLY_INFO_KIND_CODEBASE = 2,
ASSEMBLY_INFO_KIND_FULLNAME = 3,
ASSEMBLY_INFO_KIND_VERSION = 4
} MonoAssemblyInfoKind;
void
ves_icall_System_Reflection_RuntimeAssembly_GetInfo (MonoQCallAssemblyHandle assembly_h, MonoObjectHandleOnStack res, guint32 int_kind, MonoError *error)
{
MonoAssembly *assembly = assembly_h.assembly;
MonoAssemblyInfoKind kind = (MonoAssemblyInfoKind)int_kind;
switch (kind) {
case ASSEMBLY_INFO_KIND_LOCATION: {
const char *image_name = m_image_get_filename (assembly->image);
HANDLE_ON_STACK_SET (res, mono_string_new_checked (image_name != NULL ? image_name : "", error));
break;
}
case ASSEMBLY_INFO_KIND_CODEBASE: {
/* return NULL for bundled assemblies in single-file scenarios */
const char* filename = m_image_get_filename (assembly->image);
if (!filename)
break;
gchar *absolute;
if (g_path_is_absolute (filename))
absolute = g_strdup (filename);
else
absolute = g_build_filename (assembly->basedir, filename, (const char*)NULL);
mono_icall_make_platform_path (absolute);
const gchar *prepend = mono_icall_get_file_path_prefix (absolute);
gchar *uri = g_strconcat (prepend, absolute, (const char*)NULL);
g_free (absolute);
if (uri) {
HANDLE_ON_STACK_SET (res, mono_string_new_checked (uri, error));
g_free (uri);
return_if_nok (error);
}
break;
}
case ASSEMBLY_INFO_KIND_FULLNAME: {
char *name = mono_stringify_assembly_name (&assembly->aname);
HANDLE_ON_STACK_SET (res, mono_string_new_checked (name, error));
g_free (name);
return_if_nok (error);
break;
}
case ASSEMBLY_INFO_KIND_VERSION: {
HANDLE_ON_STACK_SET (res, mono_string_new_checked (assembly->image->version, error));
return_if_nok (error);
break;
}
default:
g_assert_not_reached ();
}
}
void
ves_icall_System_Reflection_RuntimeAssembly_GetEntryPoint (MonoQCallAssemblyHandle assembly_h, MonoObjectHandleOnStack res, MonoError *error)
{
MonoAssembly *assembly = assembly_h.assembly;
MonoMethod *method;
guint32 token = mono_image_get_entry_point (assembly->image);
if (!token)
return;
method = mono_get_method_checked (assembly->image, token, NULL, NULL, error);
return_if_nok (error);
HANDLE_ON_STACK_SET (res, mono_method_get_object_checked (method, NULL, error));
}
void
ves_icall_System_Reflection_Assembly_GetManifestModuleInternal (MonoQCallAssemblyHandle assembly_h, MonoObjectHandleOnStack res, MonoError *error)
{
MonoAssembly *a = assembly_h.assembly;
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (mono_module_get_object_handle (a->image, error)));
}
static gboolean
add_manifest_resource_name_to_array (MonoImage *image, MonoTableInfo *table, int i, MonoArrayHandle dest, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
const char *val = mono_metadata_string_heap (image, mono_metadata_decode_row_col (table, i, MONO_MANIFEST_NAME));
MonoStringHandle str = mono_string_new_handle (val, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, i, str);
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
void
ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceNames (MonoQCallAssemblyHandle assembly_h, MonoObjectHandleOnStack res, MonoError *error)
{
MonoAssembly *assembly = assembly_h.assembly;
MonoTableInfo *table = &assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
/* FIXME: metadata-update */
int rows = table_info_get_rows (table);
MonoArrayHandle result = mono_array_new_handle (mono_defaults.string_class, rows, error);
return_if_nok (error);
for (int i = 0; i < rows; ++i) {
if (!add_manifest_resource_name_to_array (assembly->image, table, i, result, error))
return;
}
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (result));
}
static MonoAssemblyName*
create_referenced_assembly_name (MonoImage *image, int i, MonoError *error)
{
MonoAssemblyName *aname = g_new0 (MonoAssemblyName, 1);
mono_assembly_get_assemblyref_checked (image, i, aname, error);
return_val_if_nok (error, NULL);
aname->hash_alg = ASSEMBLY_HASH_SHA1 /* SHA1 (default) */;
/* name and culture are pointers into the image tables, but we need
* real malloc'd strings (so that we can g_free() them later from
* Mono.RuntimeMarshal.FreeAssemblyName) */
aname->name = g_strdup (aname->name);
aname->culture = g_strdup (aname->culture);
/* Don't need the hash value in managed */
aname->hash_value = NULL;
aname->hash_len = 0;
g_assert (aname->public_key == NULL);
/* note: this function doesn't return the codebase on purpose (i.e. it can
be used under partial trust as path information isn't present). */
return aname;
}
GPtrArray*
ves_icall_System_Reflection_Assembly_InternalGetReferencedAssemblies (MonoReflectionAssemblyHandle assembly_h, MonoError *error)
{
MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_h, assembly);
MonoImage *image = assembly->image;
int count;
/* FIXME: metadata-update */
if (image_is_dynamic (assembly->image)) {
MonoDynamicTable *t = &(((MonoDynamicImage*) image)->tables [MONO_TABLE_ASSEMBLYREF]);
count = t->rows;
}
else {
MonoTableInfo *t = &image->tables [MONO_TABLE_ASSEMBLYREF];
count = table_info_get_rows (t);
}
GPtrArray *result = g_ptr_array_sized_new (count);
for (int i = 0; i < count; i++) {
MonoAssemblyName *aname = create_referenced_assembly_name (image, i, error);
if (!is_ok (error))
break;
g_ptr_array_add (result, aname);
}
return result;
}
/* move this in some file in mono/util/ */
static char *
g_concat_dir_and_file (const char *dir, const char *file)
{
g_return_val_if_fail (dir != NULL, NULL);
g_return_val_if_fail (file != NULL, NULL);
/*
* If the directory name doesn't have a / on the end, we need
* to add one so we get a proper path to the file
*/
if (dir [strlen(dir) - 1] != G_DIR_SEPARATOR)
return g_strconcat (dir, G_DIR_SEPARATOR_S, file, (const char*)NULL);
else
return g_strconcat (dir, file, (const char*)NULL);
}
static MonoReflectionAssemblyHandle
try_resource_resolve_name (MonoReflectionAssemblyHandle assembly_handle, MonoStringHandle name_handle)
{
MonoObjectHandle ret;
ERROR_DECL (error);
HANDLE_FUNCTION_ENTER ();
if (mono_runtime_get_no_exec ())
goto return_null;
MONO_STATIC_POINTER_INIT (MonoMethod, resolve_method)
static gboolean inited;
if (!inited) {
MonoClass *alc_class = mono_class_get_assembly_load_context_class ();
g_assert (alc_class);
resolve_method = mono_class_get_method_from_name_checked (alc_class, "OnResourceResolve", -1, 0, error);
inited = TRUE;
}
mono_error_cleanup (error);
error_init_reuse (error);
MONO_STATIC_POINTER_INIT_END (MonoMethod, resolve_method)
if (!resolve_method)
goto return_null;
gpointer args [2];
args [0] = MONO_HANDLE_RAW (assembly_handle);
args [1] = MONO_HANDLE_RAW (name_handle);
ret = mono_runtime_try_invoke_handle (resolve_method, NULL_HANDLE, args, error);
goto_if_nok (error, return_null);
goto exit;
return_null:
ret = NULL_HANDLE;
exit:
HANDLE_FUNCTION_RETURN_REF (MonoReflectionAssembly, MONO_HANDLE_CAST (MonoReflectionAssembly, ret));
}
void *
ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceInternal (MonoQCallAssemblyHandle assembly_h, MonoStringHandle name, gint32 *size, MonoObjectHandleOnStack ref_module, MonoError *error)
{
MonoAssembly *assembly = assembly_h.assembly;
MonoTableInfo *table = &assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
guint32 i;
guint32 cols [MONO_MANIFEST_SIZE];
guint32 impl, file_idx;
const char *val;
MonoImage *module;
char *n = mono_string_handle_to_utf8 (name, error);
return_val_if_nok (error, NULL);
/* FIXME: metadata update */
int rows = table_info_get_rows (table);
for (i = 0; i < rows; ++i) {
mono_metadata_decode_row (table, i, cols, MONO_MANIFEST_SIZE);
val = mono_metadata_string_heap (assembly->image, cols [MONO_MANIFEST_NAME]);
if (strcmp (val, n) == 0)
break;
}
g_free (n);
if (i == rows)
return NULL;
/* FIXME */
impl = cols [MONO_MANIFEST_IMPLEMENTATION];
if (impl) {
/*
* this code should only be called after obtaining the
* ResourceInfo and handling the other cases.
*/
g_assert ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_FILE);
file_idx = impl >> MONO_IMPLEMENTATION_BITS;
module = mono_image_load_file_for_image_checked (assembly->image, file_idx, error);
if (!is_ok (error) || !module)
return NULL;
} else {
module = assembly->image;
}
MonoReflectionModuleHandle rm = mono_module_get_object_handle (module, error);
return_val_if_nok (error, NULL);
HANDLE_ON_STACK_SET (ref_module, MONO_HANDLE_RAW (rm));
return (void*)mono_image_get_resource (module, cols [MONO_MANIFEST_OFFSET], (guint32*)size);
}
static gboolean
get_manifest_resource_info_internal (MonoAssembly *assembly, MonoStringHandle name, MonoManifestResourceInfoHandle info, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoTableInfo *table = &assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
int i;
guint32 cols [MONO_MANIFEST_SIZE];
guint32 file_cols [MONO_FILE_SIZE];
const char *val;
char *n;
gboolean result = FALSE;
n = mono_string_handle_to_utf8 (name, error);
goto_if_nok (error, leave);
int rows = table_info_get_rows (table);
for (i = 0; i < rows; ++i) {
mono_metadata_decode_row (table, i, cols, MONO_MANIFEST_SIZE);
val = mono_metadata_string_heap (assembly->image, cols [MONO_MANIFEST_NAME]);
if (strcmp (val, n) == 0)
break;
}
g_free (n);
if (i == rows)
goto leave;
if (!cols [MONO_MANIFEST_IMPLEMENTATION]) {
MONO_HANDLE_SETVAL (info, location, guint32, RESOURCE_LOCATION_EMBEDDED | RESOURCE_LOCATION_IN_MANIFEST);
}
else {
switch (cols [MONO_MANIFEST_IMPLEMENTATION] & MONO_IMPLEMENTATION_MASK) {
case MONO_IMPLEMENTATION_FILE:
i = cols [MONO_MANIFEST_IMPLEMENTATION] >> MONO_IMPLEMENTATION_BITS;
table = &assembly->image->tables [MONO_TABLE_FILE];
mono_metadata_decode_row (table, i - 1, file_cols, MONO_FILE_SIZE);
val = mono_metadata_string_heap (assembly->image, file_cols [MONO_FILE_NAME]);
MONO_HANDLE_SET (info, filename, mono_string_new_handle (val, error));
if (file_cols [MONO_FILE_FLAGS] & FILE_CONTAINS_NO_METADATA)
MONO_HANDLE_SETVAL (info, location, guint32, 0);
else
MONO_HANDLE_SETVAL (info, location, guint32, RESOURCE_LOCATION_EMBEDDED);
break;
case MONO_IMPLEMENTATION_ASSEMBLYREF:
i = cols [MONO_MANIFEST_IMPLEMENTATION] >> MONO_IMPLEMENTATION_BITS;
mono_assembly_load_reference (assembly->image, i - 1);
if (assembly->image->references [i - 1] == REFERENCE_MISSING) {
mono_error_set_file_not_found (error, NULL, "Assembly %d referenced from assembly %s not found ", i - 1, assembly->image->name);
goto leave;
}
MonoReflectionAssemblyHandle assm_obj;
assm_obj = mono_assembly_get_object_handle (assembly->image->references [i - 1], error);
goto_if_nok (error, leave);
MONO_HANDLE_SET (info, assembly, assm_obj);
/* Obtain info recursively */
get_manifest_resource_info_internal (MONO_HANDLE_GETVAL (assm_obj, assembly), name, info, error);
goto_if_nok (error, leave);
guint32 location;
location = MONO_HANDLE_GETVAL (info, location);
location |= RESOURCE_LOCATION_ANOTHER_ASSEMBLY;
MONO_HANDLE_SETVAL (info, location, guint32, location);
break;
case MONO_IMPLEMENTATION_EXP_TYPE:
g_assert_not_reached ();
break;
}
}
result = TRUE;
leave:
HANDLE_FUNCTION_RETURN_VAL (result);
}
MonoBoolean
ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceInfoInternal (MonoQCallAssemblyHandle assembly_h, MonoStringHandle name, MonoManifestResourceInfoHandle info_h, MonoError *error)
{
return get_manifest_resource_info_internal (assembly_h.assembly, name, info_h, error);
}
static gboolean
add_module_to_modules_array (MonoArrayHandle dest, int *dest_idx, MonoImage* module, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
if (module) {
MonoReflectionModuleHandle rm = mono_module_get_object_handle (module, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, *dest_idx, rm);
++(*dest_idx);
}
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
static gboolean
add_file_to_modules_array (MonoArrayHandle dest, int dest_idx, MonoImage *image, MonoTableInfo *table, int table_idx, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
guint32 cols [MONO_FILE_SIZE];
mono_metadata_decode_row (table, table_idx, cols, MONO_FILE_SIZE);
if (cols [MONO_FILE_FLAGS] & FILE_CONTAINS_NO_METADATA) {
MonoReflectionModuleHandle rm = mono_module_file_get_object_handle (image, table_idx, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, dest_idx, rm);
} else {
MonoImage *m = mono_image_load_file_for_image_checked (image, table_idx + 1, error);
goto_if_nok (error, leave);
if (!m) {
const char *filename = mono_metadata_string_heap (image, cols [MONO_FILE_NAME]);
mono_error_set_simple_file_not_found (error, filename);
goto leave;
}
MonoReflectionModuleHandle rm = mono_module_get_object_handle (m, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, dest_idx, rm);
}
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
void
ves_icall_System_Reflection_RuntimeAssembly_GetModulesInternal (MonoQCallAssemblyHandle assembly_h, MonoObjectHandleOnStack res_h, MonoError *error)
{
MonoAssembly *assembly = assembly_h.assembly;
MonoClass *klass;
int i, j, file_count = 0;
MonoImage **modules;
guint32 module_count, real_module_count;
MonoTableInfo *table;
MonoImage *image = assembly->image;
g_assert (image != NULL);
g_assert (!assembly_is_dynamic (assembly));
table = &image->tables [MONO_TABLE_FILE];
file_count = table_info_get_rows (table);
modules = image->modules;
module_count = image->module_count;
real_module_count = 0;
for (i = 0; i < module_count; ++i)
if (modules [i])
real_module_count ++;
klass = mono_class_get_module_class ();
MonoArrayHandle res = mono_array_new_handle (klass, 1 + real_module_count + file_count, error);
return_if_nok (error);
MonoReflectionModuleHandle image_obj = mono_module_get_object_handle (image, error);
return_if_nok (error);
MONO_HANDLE_ARRAY_SETREF (res, 0, image_obj);
j = 1;
for (i = 0; i < module_count; ++i)
if (!add_module_to_modules_array (res, &j, modules[i], error))
return;
for (i = 0; i < file_count; ++i, ++j) {
if (!add_file_to_modules_array (res, j, image, table, i, error))
return;
}
HANDLE_ON_STACK_SET (res_h, MONO_HANDLE_RAW (res));
}
MonoReflectionMethodHandle
ves_icall_GetCurrentMethod (MonoError *error)
{
MonoMethod *m = mono_method_get_last_managed ();
if (!m) {
mono_error_set_not_supported (error, "Stack walks are not supported on this platform.");
return MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
}
while (m->is_inflated)
m = ((MonoMethodInflated*)m)->declaring;
return mono_method_get_object_handle (m, NULL, error);
}
static MonoMethod*
mono_method_get_equivalent_method (MonoMethod *method, MonoClass *klass)
{
int offset = -1, i;
if (method->is_inflated && ((MonoMethodInflated*)method)->context.method_inst) {
ERROR_DECL (error);
MonoMethod *result;
MonoMethodInflated *inflated = (MonoMethodInflated*)method;
//method is inflated, we should inflate it on the other class
MonoGenericContext ctx;
ctx.method_inst = inflated->context.method_inst;
ctx.class_inst = inflated->context.class_inst;
if (mono_class_is_ginst (klass))
ctx.class_inst = mono_class_get_generic_class (klass)->context.class_inst;
else if (mono_class_is_gtd (klass))
ctx.class_inst = mono_class_get_generic_container (klass)->context.class_inst;
result = mono_class_inflate_generic_method_full_checked (inflated->declaring, klass, &ctx, error);
g_assert (is_ok (error)); /* FIXME don't swallow the error */
return result;
}
mono_class_setup_methods (method->klass);
if (mono_class_has_failure (method->klass))
return NULL;
int mcount = mono_class_get_method_count (method->klass);
MonoMethod **method_klass_methods = m_class_get_methods (method->klass);
for (i = 0; i < mcount; ++i) {
if (method_klass_methods [i] == method) {
offset = i;
break;
}
}
mono_class_setup_methods (klass);
if (mono_class_has_failure (klass))
return NULL;
g_assert (offset >= 0 && offset < mono_class_get_method_count (klass));
return m_class_get_methods (klass) [offset];
}
MonoReflectionMethodHandle
ves_icall_System_Reflection_RuntimeMethodInfo_GetMethodFromHandleInternalType_native (MonoMethod *method, MonoType *type, MonoBoolean generic_check, MonoError *error)
{
MonoClass *klass;
if (type && generic_check) {
klass = mono_class_from_mono_type_internal (type);
if (mono_class_get_generic_type_definition (method->klass) != mono_class_get_generic_type_definition (klass))
return MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
if (method->klass != klass) {
method = mono_method_get_equivalent_method (method, klass);
if (!method)
return MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
}
} else if (type)
klass = mono_class_from_mono_type_internal (type);
else
klass = method->klass;
return mono_method_get_object_handle (method, klass, error);
}
MonoReflectionMethodBodyHandle
ves_icall_System_Reflection_RuntimeMethodInfo_GetMethodBodyInternal (MonoMethod *method, MonoError *error)
{
return mono_method_body_get_object_handle (method, error);
}
MonoReflectionAssemblyHandle
ves_icall_System_Reflection_Assembly_GetExecutingAssembly (MonoStackCrawlMark *stack_mark, MonoError *error)
{
MonoAssembly *assembly;
assembly = mono_runtime_get_caller_from_stack_mark (stack_mark);
g_assert (assembly);
return mono_assembly_get_object_handle (assembly, error);
}
MonoReflectionAssemblyHandle
ves_icall_System_Reflection_Assembly_GetEntryAssembly (MonoError *error)
{
MonoAssembly *assembly = mono_runtime_get_entry_assembly ();
if (!assembly)
return MONO_HANDLE_CAST (MonoReflectionAssembly, NULL_HANDLE);
return mono_assembly_get_object_handle (assembly, error);
}
MonoReflectionAssemblyHandle
ves_icall_System_Reflection_Assembly_GetCallingAssembly (MonoError *error)
{
MonoMethod *m;
MonoMethod *dest;
dest = NULL;
mono_stack_walk_no_il (get_executing, &dest);
m = dest;
mono_stack_walk_no_il (get_caller_no_reflection, &dest);
if (!dest)
dest = m;
if (!m) {
mono_error_set_not_supported (error, "Stack walks are not supported on this platform.");
return MONO_HANDLE_CAST (MonoReflectionAssembly, NULL_HANDLE);
}
return mono_assembly_get_object_handle (m_class_get_image (dest->klass)->assembly, error);
}
void
ves_icall_System_RuntimeType_getFullName (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoBoolean full_name,
MonoBoolean assembly_qualified, MonoError *error)
{
MonoType *type = type_handle.type;
MonoTypeNameFormat format;
gchar *name;
if (full_name)
format = assembly_qualified ?
MONO_TYPE_NAME_FORMAT_ASSEMBLY_QUALIFIED :
MONO_TYPE_NAME_FORMAT_FULL_NAME;
else
format = MONO_TYPE_NAME_FORMAT_REFLECTION;
name = mono_type_get_name_full (type, format);
if (!name)
return;
if (full_name && (type->type == MONO_TYPE_VAR || type->type == MONO_TYPE_MVAR)) {
g_free (name);
return;
}
HANDLE_ON_STACK_SET (res, mono_string_new_checked (name, error));
g_free (name);
}
MonoAssemblyName *
ves_icall_System_Reflection_AssemblyName_GetNativeName (MonoAssembly *mass)
{
return &mass->aname;
}
static gboolean
mono_module_type_is_visible (MonoTableInfo *tdef, MonoImage *image, int type)
{
guint32 attrs, visibility;
do {
attrs = mono_metadata_decode_row_col (tdef, type - 1, MONO_TYPEDEF_FLAGS);
visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
if (visibility != TYPE_ATTRIBUTE_PUBLIC && visibility != TYPE_ATTRIBUTE_NESTED_PUBLIC)
return FALSE;
} while ((type = mono_metadata_token_index (mono_metadata_nested_in_typedef (image, type))));
return TRUE;
}
static void
image_get_type (MonoImage *image, MonoTableInfo *tdef, int table_idx, int count, MonoArrayHandle res, MonoArrayHandle exceptions, MonoBoolean exportedOnly, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
ERROR_DECL (klass_error);
MonoClass *klass = mono_class_get_checked (image, table_idx | MONO_TOKEN_TYPE_DEF, klass_error);
if (klass) {
MonoReflectionTypeHandle rt = mono_type_get_object_handle (m_class_get_byval_arg (klass), error);
return_if_nok (error);
MONO_HANDLE_ARRAY_SETREF (res, count, rt);
} else {
MonoExceptionHandle ex = mono_error_convert_to_exception_handle (klass_error);
MONO_HANDLE_ARRAY_SETREF (exceptions, count, ex);
}
HANDLE_FUNCTION_RETURN ();
}
static MonoArrayHandle
mono_module_get_types (MonoImage *image, MonoArrayHandleOut exceptions, MonoBoolean exportedOnly, MonoError *error)
{
/* FIXME: metadata-update */
MonoTableInfo *tdef = &image->tables [MONO_TABLE_TYPEDEF];
int rows = table_info_get_rows (tdef);
int i, count;
/* we start the count from 1 because we skip the special type <Module> */
if (exportedOnly) {
count = 0;
for (i = 1; i < rows; ++i) {
if (mono_module_type_is_visible (tdef, image, i + 1))
count++;
}
} else {
count = rows - 1;
}
MonoArrayHandle res = mono_array_new_handle (mono_defaults.runtimetype_class, count, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
MONO_HANDLE_ASSIGN (exceptions, mono_array_new_handle (mono_defaults.exception_class, count, error));
return_val_if_nok (error, NULL_HANDLE_ARRAY);
count = 0;
for (i = 1; i < rows; ++i) {
if (!exportedOnly || mono_module_type_is_visible (tdef, image, i+1)) {
image_get_type (image, tdef, i + 1, count, res, exceptions, exportedOnly, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
count++;
}
}
return res;
}
static void
append_module_types (MonoArrayHandleOut res, MonoArrayHandleOut exceptions, MonoImage *image, MonoBoolean exportedOnly, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoArrayHandle ex2 = MONO_HANDLE_NEW (MonoArray, NULL);
MonoArrayHandle res2 = mono_module_get_types (image, ex2, exportedOnly, error);
goto_if_nok (error, leave);
/* Append the new types to the end of the array */
if (mono_array_handle_length (res2) > 0) {
guint32 len1, len2;
len1 = mono_array_handle_length (res);
len2 = mono_array_handle_length (res2);
MonoArrayHandle res3 = mono_array_new_handle (mono_defaults.runtimetype_class, len1 + len2, error);
goto_if_nok (error, leave);
mono_array_handle_memcpy_refs (res3, 0, res, 0, len1);
mono_array_handle_memcpy_refs (res3, len1, res2, 0, len2);
MONO_HANDLE_ASSIGN (res, res3);
MonoArrayHandle ex3 = mono_array_new_handle (mono_defaults.runtimetype_class, len1 + len2, error);
goto_if_nok (error, leave);
mono_array_handle_memcpy_refs (ex3, 0, exceptions, 0, len1);
mono_array_handle_memcpy_refs (ex3, len1, ex2, 0, len2);
MONO_HANDLE_ASSIGN (exceptions, ex3);
}
leave:
HANDLE_FUNCTION_RETURN ();
}
static void
set_class_failure_in_array (MonoArrayHandle exl, int i, MonoClass *klass)
{
HANDLE_FUNCTION_ENTER ();
ERROR_DECL (unboxed_error);
mono_error_set_for_class_failure (unboxed_error, klass);
MonoExceptionHandle exc = MONO_HANDLE_NEW (MonoException, mono_error_convert_to_exception (unboxed_error));
MONO_HANDLE_ARRAY_SETREF (exl, i, exc);
HANDLE_FUNCTION_RETURN ();
}
void
ves_icall_System_Reflection_RuntimeAssembly_GetExportedTypes (MonoQCallAssemblyHandle assembly_handle, MonoObjectHandleOnStack res_h,
MonoError *error)
{
MonoArrayHandle exceptions = MONO_HANDLE_NEW(MonoArray, NULL);
MonoAssembly *assembly = assembly_handle.assembly;
int i;
g_assert (!assembly_is_dynamic (assembly));
MonoImage *image = assembly->image;
MonoTableInfo *table = &image->tables [MONO_TABLE_FILE];
MonoArrayHandle res = mono_module_get_types (image, exceptions, TRUE, error);
return_if_nok (error);
/* Append data from all modules in the assembly */
int rows = table_info_get_rows (table);
for (i = 0; i < rows; ++i) {
if (!(mono_metadata_decode_row_col (table, i, MONO_FILE_FLAGS) & FILE_CONTAINS_NO_METADATA)) {
MonoImage *loaded_image = mono_assembly_load_module_checked (image->assembly, i + 1, error);
return_if_nok (error);
if (loaded_image) {
append_module_types (res, exceptions, loaded_image, TRUE, error);
return_if_nok (error);
}
}
}
/* the ReflectionTypeLoadException must have all the types (Types property),
* NULL replacing types which throws an exception. The LoaderException must
* contain all exceptions for NULL items.
*/
int len = mono_array_handle_length (res);
int ex_count = 0;
GList *list = NULL;
MonoReflectionTypeHandle t = MONO_HANDLE_NEW (MonoReflectionType, NULL);
for (i = 0; i < len; i++) {
MONO_HANDLE_ARRAY_GETREF (t, res, i);
if (!MONO_HANDLE_IS_NULL (t)) {
MonoClass *klass = mono_type_get_class_internal (MONO_HANDLE_GETVAL (t, type));
if ((klass != NULL) && mono_class_has_failure (klass)) {
/* keep the class in the list */
list = g_list_append (list, klass);
/* and replace Type with NULL */
MONO_HANDLE_ARRAY_SETREF (res, i, NULL_HANDLE);
}
} else {
ex_count ++;
}
}
if (list || ex_count) {
GList *tmp = NULL;
int j, length = g_list_length (list) + ex_count;
MonoArrayHandle exl = mono_array_new_handle (mono_defaults.exception_class, length, error);
if (!is_ok (error)) {
g_list_free (list);
return;
}
/* Types for which mono_class_get_checked () succeeded */
MonoExceptionHandle exc = MONO_HANDLE_NEW (MonoException, NULL);
for (i = 0, tmp = list; tmp; i++, tmp = tmp->next) {
set_class_failure_in_array (exl, i, (MonoClass*)tmp->data);
}
/* Types for which it don't */
for (j = 0; j < mono_array_handle_length (exceptions); ++j) {
MONO_HANDLE_ARRAY_GETREF (exc, exceptions, j);
if (!MONO_HANDLE_IS_NULL (exc)) {
g_assert (i < length);
MONO_HANDLE_ARRAY_SETREF (exl, i, exc);
i ++;
}
}
g_list_free (list);
list = NULL;
MONO_HANDLE_ASSIGN (exc, mono_get_exception_reflection_type_load_checked (res, exl, error));
return_if_nok (error);
mono_error_set_exception_handle (error, exc);
return;
}
HANDLE_ON_STACK_SET (res_h, MONO_HANDLE_RAW (res));
}
static void
get_top_level_forwarded_type (MonoImage *image, MonoTableInfo *table, int i, MonoArrayHandle types, MonoArrayHandle exceptions, int *aindex, int *exception_count)
{
ERROR_DECL (local_error);
guint32 cols [MONO_EXP_TYPE_SIZE];
MonoClass *klass;
MonoReflectionTypeHandle rt;
mono_metadata_decode_row (table, i, cols, MONO_EXP_TYPE_SIZE);
if (!(cols [MONO_EXP_TYPE_FLAGS] & TYPE_ATTRIBUTE_FORWARDER))
return;
guint32 impl = cols [MONO_EXP_TYPE_IMPLEMENTATION];
const char *name = mono_metadata_string_heap (image, cols [MONO_EXP_TYPE_NAME]);
const char *nspace = mono_metadata_string_heap (image, cols [MONO_EXP_TYPE_NAMESPACE]);
g_assert ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_ASSEMBLYREF);
guint32 assembly_idx = impl >> MONO_IMPLEMENTATION_BITS;
mono_assembly_load_reference (image, assembly_idx - 1);
g_assert (image->references [assembly_idx - 1]);
HANDLE_FUNCTION_ENTER ();
if (image->references [assembly_idx - 1] == REFERENCE_MISSING) {
MonoExceptionHandle ex = MONO_HANDLE_NEW (MonoException, mono_get_exception_bad_image_format ("Invalid image"));
MONO_HANDLE_ARRAY_SETREF (types, *aindex, NULL_HANDLE);
MONO_HANDLE_ARRAY_SETREF (exceptions, *aindex, ex);
(*exception_count)++; (*aindex)++;
goto exit;
}
klass = mono_class_from_name_checked (image->references [assembly_idx - 1]->image, nspace, name, local_error);
if (!is_ok (local_error)) {
MonoExceptionHandle ex = mono_error_convert_to_exception_handle (local_error);
MONO_HANDLE_ARRAY_SETREF (types, *aindex, NULL_HANDLE);
MONO_HANDLE_ARRAY_SETREF (exceptions, *aindex, ex);
mono_error_cleanup (local_error);
(*exception_count)++; (*aindex)++;
goto exit;
}
rt = mono_type_get_object_handle (m_class_get_byval_arg (klass), local_error);
if (!is_ok (local_error)) {
MonoExceptionHandle ex = mono_error_convert_to_exception_handle (local_error);
MONO_HANDLE_ARRAY_SETREF (types, *aindex, NULL_HANDLE);
MONO_HANDLE_ARRAY_SETREF (exceptions, *aindex, ex);
mono_error_cleanup (local_error);
(*exception_count)++; (*aindex)++;
goto exit;
}
MONO_HANDLE_ARRAY_SETREF (types, *aindex, rt);
MONO_HANDLE_ARRAY_SETREF (exceptions, *aindex, NULL_HANDLE);
(*aindex)++;
exit:
HANDLE_FUNCTION_RETURN ();
}
void
ves_icall_System_Reflection_RuntimeAssembly_GetTopLevelForwardedTypes (MonoQCallAssemblyHandle assembly_h, MonoObjectHandleOnStack res,
MonoError *error)
{
MonoAssembly *assembly = assembly_h.assembly;
MonoImage *image = assembly->image;
int count = 0;
g_assert (!assembly_is_dynamic (assembly));
MonoTableInfo *table = &image->tables [MONO_TABLE_EXPORTEDTYPE];
int rows = table_info_get_rows (table);
for (int i = 0; i < rows; ++i) {
if (mono_metadata_decode_row_col (table, i, MONO_EXP_TYPE_FLAGS) & TYPE_ATTRIBUTE_FORWARDER)
count ++;
}
MonoArrayHandle types = mono_array_new_handle (mono_defaults.runtimetype_class, count, error);
return_if_nok (error);
MonoArrayHandle exceptions = mono_array_new_handle (mono_defaults.exception_class, count, error);
return_if_nok (error);
int aindex = 0;
int exception_count = 0;
for (int i = 0; i < rows; ++i)
get_top_level_forwarded_type (image, table, i, types, exceptions, &aindex, &exception_count);
if (exception_count > 0) {
MonoExceptionHandle exc = MONO_HANDLE_NEW (MonoException, NULL);
MONO_HANDLE_ASSIGN (exc, mono_get_exception_reflection_type_load_checked (types, exceptions, error));
return_if_nok (error);
mono_error_set_exception_handle (error, exc);
return;
}
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (types));
}
void
ves_icall_Mono_RuntimeMarshal_FreeAssemblyName (MonoAssemblyName *aname, MonoBoolean free_struct)
{
mono_assembly_name_free_internal (aname);
if (free_struct)
g_free (aname);
}
void
ves_icall_AssemblyExtensions_ApplyUpdate (MonoAssembly *assm,
gconstpointer dmeta_bytes, int32_t dmeta_len,
gconstpointer dil_bytes, int32_t dil_len,
gconstpointer dpdb_bytes, int32_t dpdb_len)
{
ERROR_DECL (error);
g_assert (assm);
g_assert (dmeta_len >= 0);
MonoImage *image_base = assm->image;
g_assert (image_base);
#ifndef HOST_WASM
if (mono_is_debugger_attached ()) {
mono_error_set_not_supported (error, "Cannot use System.Reflection.Metadata.MetadataUpdater.ApplyChanges while debugger is attached");
mono_error_set_pending_exception (error);
return;
}
#endif
mono_image_load_enc_delta (MONO_ENC_DELTA_API, image_base, dmeta_bytes, dmeta_len, dil_bytes, dil_len, dpdb_bytes, dpdb_len, error);
mono_error_set_pending_exception (error);
}
gint32 ves_icall_AssemblyExtensions_ApplyUpdateEnabled (gint32 just_component_check)
{
// if just_component_check is true, we only care whether the hot_reload component is enabled,
// not whether the environment is appropriately setup to apply updates.
return mono_metadata_update_available () && (just_component_check || mono_metadata_update_enabled (NULL));
}
MonoReflectionTypeHandle
ves_icall_System_Reflection_RuntimeModule_GetGlobalType (MonoImage *image, MonoError *error)
{
MonoClass *klass;
g_assert (image);
MonoReflectionTypeHandle ret = MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
if (image_is_dynamic (image) && ((MonoDynamicImage*)image)->initial_image)
/* These images do not have a global type */
goto leave;
klass = mono_class_get_checked (image, 1 | MONO_TOKEN_TYPE_DEF, error);
goto_if_nok (error, leave);
ret = mono_type_get_object_handle (m_class_get_byval_arg (klass), error);
leave:
return ret;
}
void
ves_icall_System_Reflection_RuntimeModule_GetGuidInternal (MonoImage *image, MonoArrayHandle guid_h, MonoError *error)
{
g_assert (mono_array_handle_length (guid_h) == 16);
if (!image->metadata_only) {
g_assert (image->heap_guid.data);
g_assert (image->heap_guid.size >= 16);
MONO_ENTER_NO_SAFEPOINTS;
guint8 *data = (guint8*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (guid_h), 1, 0);
memcpy (data, (guint8*)image->heap_guid.data, 16);
MONO_EXIT_NO_SAFEPOINTS;
} else {
MONO_ENTER_NO_SAFEPOINTS;
guint8 *data = (guint8*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (guid_h), 1, 0);
memset (data, 0, 16);
MONO_EXIT_NO_SAFEPOINTS;
}
}
void
ves_icall_System_Reflection_RuntimeModule_GetPEKind (MonoImage *image, gint32 *pe_kind, gint32 *machine, MonoError *error)
{
if (image_is_dynamic (image)) {
MonoDynamicImage *dyn = (MonoDynamicImage*)image;
*pe_kind = dyn->pe_kind;
*machine = dyn->machine;
}
else {
*pe_kind = (image->image_info->cli_cli_header.ch_flags & 0x3);
*machine = image->image_info->cli_header.coff.coff_machine;
}
}
gint32
ves_icall_System_Reflection_RuntimeModule_GetMDStreamVersion (MonoImage *image, MonoError *error)
{
return (image->md_version_major << 16) | (image->md_version_minor);
}
MonoArrayHandle
ves_icall_System_Reflection_RuntimeModule_InternalGetTypes (MonoImage *image, MonoError *error)
{
if (!image) {
MonoArrayHandle arr = mono_array_new_handle (mono_defaults.runtimetype_class, 0, error);
return arr;
} else {
MonoArrayHandle exceptions = MONO_HANDLE_NEW (MonoArray, NULL);
MonoArrayHandle res = mono_module_get_types (image, exceptions, FALSE, error);
return_val_if_nok (error, MONO_HANDLE_CAST(MonoArray, NULL_HANDLE));
int n = mono_array_handle_length (exceptions);
MonoExceptionHandle ex = MONO_HANDLE_NEW (MonoException, NULL);
for (int i = 0; i < n; ++i) {
MONO_HANDLE_ARRAY_GETREF(ex, exceptions, i);
if (!MONO_HANDLE_IS_NULL (ex)) {
mono_error_set_exception_handle (error, ex);
return MONO_HANDLE_CAST(MonoArray, NULL_HANDLE);
}
}
return res;
}
}
static gboolean
mono_memberref_is_method (MonoImage *image, guint32 token)
{
if (!image_is_dynamic (image)) {
int idx = mono_metadata_token_index (token);
if (idx <= 0 || mono_metadata_table_bounds_check (image, MONO_TABLE_MEMBERREF, idx)) {
return FALSE;
}
guint32 cols [MONO_MEMBERREF_SIZE];
const MonoTableInfo *table = &image->tables [MONO_TABLE_MEMBERREF];
mono_metadata_decode_row (table, idx - 1, cols, MONO_MEMBERREF_SIZE);
const char *sig = mono_metadata_blob_heap (image, cols [MONO_MEMBERREF_SIGNATURE]);
mono_metadata_decode_blob_size (sig, &sig);
return (*sig != 0x6);
} else {
ERROR_DECL (error);
MonoClass *handle_class;
if (!mono_lookup_dynamic_token_class (image, token, FALSE, &handle_class, NULL, error)) {
mono_error_cleanup (error); /* just probing, ignore error */
return FALSE;
}
return mono_defaults.methodhandle_class == handle_class;
}
}
static MonoGenericInst *
get_generic_inst_from_array_handle (MonoArrayHandle type_args)
{
int type_argc = mono_array_handle_length (type_args);
int size = MONO_SIZEOF_GENERIC_INST + type_argc * sizeof (MonoType *);
MonoGenericInst *ginst = (MonoGenericInst *)g_alloca (size);
memset (ginst, 0, MONO_SIZEOF_GENERIC_INST);
ginst->type_argc = type_argc;
for (int i = 0; i < type_argc; i++) {
MONO_HANDLE_ARRAY_GETVAL (ginst->type_argv[i], type_args, MonoType*, i);
}
ginst->is_open = FALSE;
for (int i = 0; i < type_argc; i++) {
if (mono_class_is_open_constructed_type (ginst->type_argv[i])) {
ginst->is_open = TRUE;
break;
}
}
return mono_metadata_get_canonical_generic_inst (ginst);
}
static void
init_generic_context_from_args_handles (MonoGenericContext *context, MonoArrayHandle type_args, MonoArrayHandle method_args)
{
if (!MONO_HANDLE_IS_NULL (type_args)) {
context->class_inst = get_generic_inst_from_array_handle (type_args);
} else {
context->class_inst = NULL;
}
if (!MONO_HANDLE_IS_NULL (method_args)) {
context->method_inst = get_generic_inst_from_array_handle (method_args);
} else {
context->method_inst = NULL;
}
}
static MonoType*
module_resolve_type_token (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *resolve_error, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoType *result = NULL;
MonoClass *klass;
int table = mono_metadata_token_table (token);
int index = mono_metadata_token_index (token);
MonoGenericContext context;
*resolve_error = ResolveTokenError_Other;
/* Validate token */
if ((table != MONO_TABLE_TYPEDEF) && (table != MONO_TABLE_TYPEREF) &&
(table != MONO_TABLE_TYPESPEC)) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
if (image_is_dynamic (image)) {
if ((table == MONO_TABLE_TYPEDEF) || (table == MONO_TABLE_TYPEREF)) {
ERROR_DECL (inner_error);
klass = (MonoClass *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL, inner_error);
mono_error_cleanup (inner_error);
result = klass ? m_class_get_byval_arg (klass) : NULL;
goto leave;
}
init_generic_context_from_args_handles (&context, type_args, method_args);
ERROR_DECL (inner_error);
klass = (MonoClass *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context, inner_error);
mono_error_cleanup (inner_error);
result = klass ? m_class_get_byval_arg (klass) : NULL;
goto leave;
}
if ((index <= 0) || mono_metadata_table_bounds_check (image, table, index)) {
*resolve_error = ResolveTokenError_OutOfRange;
goto leave;
}
init_generic_context_from_args_handles (&context, type_args, method_args);
klass = mono_class_get_checked (image, token, error);
if (klass)
klass = mono_class_inflate_generic_class_checked (klass, &context, error);
goto_if_nok (error, leave);
if (klass)
result = m_class_get_byval_arg (klass);
leave:
HANDLE_FUNCTION_RETURN_VAL (result);
}
MonoType*
ves_icall_System_Reflection_RuntimeModule_ResolveTypeToken (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *resolve_error, MonoError *error)
{
return module_resolve_type_token (image, token, type_args, method_args, resolve_error, error);
}
static MonoMethod*
module_resolve_method_token (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *resolve_error, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoMethod *method = NULL;
int table = mono_metadata_token_table (token);
int index = mono_metadata_token_index (token);
MonoGenericContext context;
*resolve_error = ResolveTokenError_Other;
/* Validate token */
if ((table != MONO_TABLE_METHOD) && (table != MONO_TABLE_METHODSPEC) &&
(table != MONO_TABLE_MEMBERREF)) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
if (image_is_dynamic (image)) {
if (table == MONO_TABLE_METHOD) {
ERROR_DECL (inner_error);
method = (MonoMethod *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL, inner_error);
mono_error_cleanup (inner_error);
goto leave;
}
if ((table == MONO_TABLE_MEMBERREF) && !(mono_memberref_is_method (image, token))) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
init_generic_context_from_args_handles (&context, type_args, method_args);
ERROR_DECL (inner_error);
method = (MonoMethod *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context, inner_error);
mono_error_cleanup (inner_error);
goto leave;
}
if ((index <= 0) || mono_metadata_table_bounds_check (image, table, index)) {
*resolve_error = ResolveTokenError_OutOfRange;
goto leave;
}
if ((table == MONO_TABLE_MEMBERREF) && (!mono_memberref_is_method (image, token))) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
init_generic_context_from_args_handles (&context, type_args, method_args);
method = mono_get_method_checked (image, token, NULL, &context, error);
leave:
HANDLE_FUNCTION_RETURN_VAL (method);
}
MonoMethod*
ves_icall_System_Reflection_RuntimeModule_ResolveMethodToken (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *resolve_error, MonoError *error)
{
return module_resolve_method_token (image, token, type_args, method_args, resolve_error, error);
}
MonoStringHandle
ves_icall_System_Reflection_RuntimeModule_ResolveStringToken (MonoImage *image, guint32 token, MonoResolveTokenError *resolve_error, MonoError *error)
{
int index = mono_metadata_token_index (token);
*resolve_error = ResolveTokenError_Other;
/* Validate token */
if (mono_metadata_token_code (token) != MONO_TOKEN_STRING) {
*resolve_error = ResolveTokenError_BadTable;
return NULL_HANDLE_STRING;
}
if (image_is_dynamic (image)) {
ERROR_DECL (ignore_inner_error);
// FIXME ignoring error
// FIXME Push MONO_HANDLE_NEW to lower layers.
MonoStringHandle result = MONO_HANDLE_NEW (MonoString, (MonoString*)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL, ignore_inner_error));
mono_error_cleanup (ignore_inner_error);
return result;
}
if ((index <= 0) || (index >= image->heap_us.size)) {
*resolve_error = ResolveTokenError_OutOfRange;
return NULL_HANDLE_STRING;
}
/* FIXME: What to do if the index points into the middle of a string ? */
return mono_ldstr_handle (image, index, error);
}
static MonoClassField*
module_resolve_field_token (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *resolve_error, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoClass *klass;
int table = mono_metadata_token_table (token);
int index = mono_metadata_token_index (token);
MonoGenericContext context;
MonoClassField *field = NULL;
*resolve_error = ResolveTokenError_Other;
/* Validate token */
if ((table != MONO_TABLE_FIELD) && (table != MONO_TABLE_MEMBERREF)) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
if (image_is_dynamic (image)) {
if (table == MONO_TABLE_FIELD) {
ERROR_DECL (inner_error);
field = (MonoClassField *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL, inner_error);
mono_error_cleanup (inner_error);
goto leave;
}
if (mono_memberref_is_method (image, token)) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
init_generic_context_from_args_handles (&context, type_args, method_args);
ERROR_DECL (inner_error);
field = (MonoClassField *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context, inner_error);
mono_error_cleanup (inner_error);
goto leave;
}
if ((index <= 0) || mono_metadata_table_bounds_check (image, table, index)) {
*resolve_error = ResolveTokenError_OutOfRange;
goto leave;
}
if ((table == MONO_TABLE_MEMBERREF) && (mono_memberref_is_method (image, token))) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
init_generic_context_from_args_handles (&context, type_args, method_args);
field = mono_field_from_token_checked (image, token, &klass, &context, error);
leave:
HANDLE_FUNCTION_RETURN_VAL (field);
}
MonoClassField*
ves_icall_System_Reflection_RuntimeModule_ResolveFieldToken (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *resolve_error, MonoError *error)
{
return module_resolve_field_token (image, token, type_args, method_args, resolve_error, error);
}
MonoObjectHandle
ves_icall_System_Reflection_RuntimeModule_ResolveMemberToken (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *error, MonoError *merror)
{
int table = mono_metadata_token_table (token);
*error = ResolveTokenError_Other;
switch (table) {
case MONO_TABLE_TYPEDEF:
case MONO_TABLE_TYPEREF:
case MONO_TABLE_TYPESPEC: {
MonoType *t = module_resolve_type_token (image, token, type_args, method_args, error, merror);
if (t) {
return MONO_HANDLE_CAST (MonoObject, mono_type_get_object_handle (t, merror));
}
else
return NULL_HANDLE;
}
case MONO_TABLE_METHOD:
case MONO_TABLE_METHODSPEC: {
MonoMethod *m = module_resolve_method_token (image, token, type_args, method_args, error, merror);
if (m) {
return MONO_HANDLE_CAST (MonoObject, mono_method_get_object_handle (m, m->klass, merror));
} else
return NULL_HANDLE;
}
case MONO_TABLE_FIELD: {
MonoClassField *f = module_resolve_field_token (image, token, type_args, method_args, error, merror);
if (f) {
return MONO_HANDLE_CAST (MonoObject, mono_field_get_object_handle (m_field_get_parent (f), f, merror));
}
else
return NULL_HANDLE;
}
case MONO_TABLE_MEMBERREF:
if (mono_memberref_is_method (image, token)) {
MonoMethod *m = module_resolve_method_token (image, token, type_args, method_args, error, merror);
if (m) {
return MONO_HANDLE_CAST (MonoObject, mono_method_get_object_handle (m, m->klass, merror));
} else
return NULL_HANDLE;
}
else {
MonoClassField *f = module_resolve_field_token (image, token, type_args, method_args, error, merror);
if (f) {
return MONO_HANDLE_CAST (MonoObject, mono_field_get_object_handle (m_field_get_parent (f), f, merror));
}
else
return NULL_HANDLE;
}
break;
default:
*error = ResolveTokenError_BadTable;
}
return NULL_HANDLE;
}
MonoArrayHandle
ves_icall_System_Reflection_RuntimeModule_ResolveSignature (MonoImage *image, guint32 token, MonoResolveTokenError *resolve_error, MonoError *error)
{
int table = mono_metadata_token_table (token);
int idx = mono_metadata_token_index (token);
MonoTableInfo *tables = image->tables;
guint32 sig, len;
const char *ptr;
*resolve_error = ResolveTokenError_OutOfRange;
/* FIXME: Support other tables ? */
if (table != MONO_TABLE_STANDALONESIG)
return NULL_HANDLE_ARRAY;
if (image_is_dynamic (image))
return NULL_HANDLE_ARRAY;
if ((idx == 0) || mono_metadata_table_bounds_check (image, MONO_TABLE_STANDALONESIG, idx))
return NULL_HANDLE_ARRAY;
sig = mono_metadata_decode_row_col (&tables [MONO_TABLE_STANDALONESIG], idx - 1, 0);
ptr = mono_metadata_blob_heap (image, sig);
len = mono_metadata_decode_blob_size (ptr, &ptr);
MonoArrayHandle res = mono_array_new_handle (mono_defaults.byte_class, len, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
// FIXME MONO_ENTER_NO_SAFEPOINTS instead of pin/gchandle.
MonoGCHandle h;
gpointer array_base = MONO_ARRAY_HANDLE_PIN (res, guint8, 0, &h);
memcpy (array_base, ptr, len);
mono_gchandle_free_internal (h);
return res;
}
static void
check_for_invalid_array_type (MonoType *type, MonoError *error)
{
gboolean allowed = TRUE;
char *name;
if (m_type_is_byref (type))
allowed = FALSE;
else if (type->type == MONO_TYPE_TYPEDBYREF)
allowed = FALSE;
MonoClass *klass = mono_class_from_mono_type_internal (type);
if (m_class_is_byreflike (klass))
allowed = FALSE;
if (allowed)
return;
name = mono_type_get_full_name (klass);
mono_error_set_type_load_name (error, name, g_strdup (""), "");
}
static void
check_for_invalid_byref_or_pointer_type (MonoClass *klass, MonoError *error)
{
return;
}
void
ves_icall_RuntimeType_make_array_type (MonoQCallTypeHandle type_handle, int rank, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
check_for_invalid_array_type (type, error);
return_if_nok (error);
MonoClass *klass = mono_class_from_mono_type_internal (type);
MonoClass *aklass;
if (rank == 0) //single dimension array
aklass = mono_class_create_array (klass, 1);
else
aklass = mono_class_create_bounded_array (klass, rank, TRUE);
if (mono_class_has_failure (aklass)) {
mono_error_set_for_class_failure (error, aklass);
return;
}
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (aklass), error));
}
void
ves_icall_RuntimeType_make_byref_type (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_if_nok (error);
check_for_invalid_byref_or_pointer_type (klass, error);
return_if_nok (error);
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_this_arg (klass), error));
}
void
ves_icall_RuntimeType_make_pointer_type (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_if_nok (error);
check_for_invalid_byref_or_pointer_type (klass, error);
return_if_nok (error);
MonoClass *pklass = mono_class_create_ptr (type);
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (pklass), error));
}
MonoObjectHandle
ves_icall_System_Delegate_CreateDelegate_internal (MonoQCallTypeHandle type_handle, MonoObjectHandle target,
MonoReflectionMethodHandle info, MonoBoolean throwOnBindFailure, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *delegate_class = mono_class_from_mono_type_internal (type);
MonoMethod *method = MONO_HANDLE_GETVAL (info, method);
MonoMethodSignature *sig = mono_method_signature_internal (method);
mono_class_init_checked (delegate_class, error);
return_val_if_nok (error, NULL_HANDLE);
if (!(m_class_get_parent (delegate_class) == mono_defaults.multicastdelegate_class)) {
/* FIXME improve this exception message */
mono_error_set_execution_engine (error, "file %s: line %d (%s): assertion failed: (%s)", __FILE__, __LINE__,
__func__,
"delegate_class->parent == mono_defaults.multicastdelegate_class");
return NULL_HANDLE;
}
if (sig->generic_param_count && method->wrapper_type == MONO_WRAPPER_NONE) {
if (!method->is_inflated) {
mono_error_set_argument (error, "method", " Cannot bind to the target method because its signature differs from that of the delegate type");
return NULL_HANDLE;
}
}
MonoObjectHandle delegate = mono_object_new_handle (delegate_class, error);
return_val_if_nok (error, NULL_HANDLE);
if (!method_is_dynamic (method) && (!MONO_HANDLE_IS_NULL (target) && method->flags & METHOD_ATTRIBUTE_VIRTUAL && method->klass != mono_handle_class (target))) {
method = mono_object_handle_get_virtual_method (target, method, error);
return_val_if_nok (error, NULL_HANDLE);
}
mono_delegate_ctor (delegate, target, NULL, method, error);
return_val_if_nok (error, NULL_HANDLE);
return delegate;
}
MonoMulticastDelegateHandle
ves_icall_System_Delegate_AllocDelegateLike_internal (MonoDelegateHandle delegate, MonoError *error)
{
MonoClass *klass = mono_handle_class (delegate);
g_assert (mono_class_has_parent (klass, mono_defaults.multicastdelegate_class));
MonoMulticastDelegateHandle ret = MONO_HANDLE_CAST (MonoMulticastDelegate, mono_object_new_handle (klass, error));
return_val_if_nok (error, MONO_HANDLE_CAST (MonoMulticastDelegate, NULL_HANDLE));
mono_get_runtime_callbacks ()->init_delegate (MONO_HANDLE_CAST (MonoDelegate, ret), NULL_HANDLE, NULL, NULL, error);
return ret;
}
MonoReflectionMethodHandle
ves_icall_System_Delegate_GetVirtualMethod_internal (MonoDelegateHandle delegate, MonoError *error)
{
MonoObjectHandle delegate_target = MONO_HANDLE_NEW_GET (MonoObject, delegate, target);
MonoMethod *m = mono_object_handle_get_virtual_method (delegate_target, MONO_HANDLE_GETVAL (delegate, method), error);
return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
return mono_method_get_object_handle (m, m->klass, error);
}
/* System.Buffer */
static gint32
mono_array_get_byte_length (MonoArrayHandle array)
{
int length;
MonoClass * const klass = mono_handle_class (array);
// This resembles mono_array_get_length, but adds the loop.
if (mono_handle_array_has_bounds (array)) {
length = 1;
const int klass_rank = m_class_get_rank (klass);
for (int i = 0; i < klass_rank; ++ i)
length *= MONO_HANDLE_GETVAL (array, bounds [i].length);
} else {
length = mono_array_handle_length (array);
}
switch (m_class_get_byval_arg (m_class_get_element_class (klass))->type) {
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_BOOLEAN:
return length;
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_CHAR:
return length << 1;
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_R4:
return length << 2;
case MONO_TYPE_I:
case MONO_TYPE_U:
return length * sizeof (gpointer);
case MONO_TYPE_I8:
case MONO_TYPE_U8:
case MONO_TYPE_R8:
return length << 3;
default:
return -1;
}
}
/* System.Environment */
MonoArrayHandle
ves_icall_System_Environment_GetCommandLineArgs (MonoError *error)
{
MonoArrayHandle result = mono_runtime_get_main_args_handle (error);
return result;
}
void
ves_icall_System_Environment_Exit (int result)
{
mono_environment_exitcode_set (result);
if (!mono_runtime_try_shutdown ())
mono_thread_exit ();
mono_runtime_quit_internal ();
/* we may need to do some cleanup here... */
exit (result);
}
void
ves_icall_System_Environment_FailFast (MonoStringHandle message, MonoExceptionHandle exception, MonoStringHandle errorSource, MonoError *error)
{
if (MONO_HANDLE_IS_NULL (message)) {
g_warning ("Process terminated.");
} else {
char *msg = mono_string_handle_to_utf8 (message, error);
g_warning ("Process terminated due to \"%s\"", msg);
g_free (msg);
}
if (!MONO_HANDLE_IS_NULL (exception)) {
mono_print_unhandled_exception_internal ((MonoObject *) MONO_HANDLE_RAW (exception));
}
// NOTE: While this does trigger WER on Windows it doesn't quite provide all the
// information in the error dump that CoreCLR would. On Windows 7+ we should call
// RaiseFailFastException directly instead of relying on the C runtime doing it
// for us and pass it as much information as possible. On Windows 8+ we can also
// use the __fastfail intrinsic.
abort ();
}
gint32
ves_icall_System_Environment_get_TickCount (void)
{
/* this will overflow after ~24 days */
return (gint32) (mono_msec_boottime () & 0xffffffff);
}
gint64
ves_icall_System_Environment_get_TickCount64 (void)
{
return mono_msec_boottime ();
}
gpointer
ves_icall_RuntimeMethodHandle_GetFunctionPointer (MonoMethod *method, MonoError *error)
{
return mono_method_get_unmanaged_wrapper_ftnptr_internal (method, FALSE, error);
}
void*
mono_method_get_unmanaged_wrapper_ftnptr_internal (MonoMethod *method, gboolean only_unmanaged_callers_only, MonoError *error)
{
/* WISH: we should do this in managed */
if (G_UNLIKELY (mono_method_has_unmanaged_callers_only_attribute (method))) {
method = mono_marshal_get_managed_wrapper (method, NULL, (MonoGCHandle)0, error);
return_val_if_nok (error, NULL);
} else {
g_assert (!only_unmanaged_callers_only);
}
return mono_get_runtime_callbacks ()->get_ftnptr (method, error);
}
MonoBoolean
ves_icall_System_Diagnostics_Debugger_IsAttached_internal (void)
{
return mono_is_debugger_attached ();
}
MonoBoolean
ves_icall_System_Diagnostics_Debugger_IsLogging (void)
{
return mono_get_runtime_callbacks ()->debug_log_is_enabled
&& mono_get_runtime_callbacks ()->debug_log_is_enabled ();
}
void
ves_icall_System_Diagnostics_Debugger_Log (int level, MonoString *volatile* category, MonoString *volatile* message)
{
if (mono_get_runtime_callbacks ()->debug_log)
mono_get_runtime_callbacks ()->debug_log (level, *category, *message);
}
/* Only used for value types */
MonoObjectHandle
ves_icall_System_RuntimeType_CreateInstanceInternal (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
(void)klass;
mono_class_init_checked (klass, error);
return_val_if_nok (error, NULL_HANDLE);
if (mono_class_is_nullable (klass))
/* No arguments -> null */
return NULL_HANDLE;
return mono_object_new_handle (klass, error);
}
MonoReflectionMethodHandle
ves_icall_RuntimeMethodInfo_get_base_method (MonoReflectionMethodHandle m, MonoBoolean definition, MonoError *error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (m, method);
MonoMethod *base = mono_method_get_base_method (method, definition, error);
return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
if (base == method) {
/* we want to short-circuit and return 'm' here. But we should
return the same method object that
mono_method_get_object_handle, below would return. Since
that call takes NULL for the reftype argument, it will take
base->klass as the reflected type for the MonoMethod. So we
need to check that m also has base->klass as the reflected
type. */
MonoReflectionTypeHandle orig_reftype = MONO_HANDLE_NEW_GET (MonoReflectionType, m, reftype);
MonoClass *orig_klass = mono_class_from_mono_type_internal (MONO_HANDLE_GETVAL (orig_reftype, type));
if (base->klass == orig_klass)
return m;
}
return mono_method_get_object_handle (base, NULL, error);
}
MonoStringHandle
ves_icall_RuntimeMethodInfo_get_name (MonoReflectionMethodHandle m, MonoError *error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (m, method);
MonoStringHandle s = mono_string_new_handle (method->name, error);
return_val_if_nok (error, NULL_HANDLE_STRING);
MONO_HANDLE_SET (m, name, s);
return s;
}
void
ves_icall_System_ArgIterator_Setup (MonoArgIterator *iter, char* argsp, char* start)
{
iter->sig = *(MonoMethodSignature**)argsp;
g_assert (iter->sig->sentinelpos <= iter->sig->param_count);
g_assert (iter->sig->call_convention == MONO_CALL_VARARG);
iter->next_arg = 0;
/* FIXME: it's not documented what start is exactly... */
if (start) {
iter->args = start;
} else {
iter->args = argsp + sizeof (gpointer);
}
iter->num_args = iter->sig->param_count - iter->sig->sentinelpos;
/* g_print ("sig %p, param_count: %d, sent: %d\n", iter->sig, iter->sig->param_count, iter->sig->sentinelpos); */
}
void
ves_icall_System_ArgIterator_IntGetNextArg (MonoArgIterator *iter, MonoTypedRef *res)
{
guint32 i, arg_size;
gint32 align;
i = iter->sig->sentinelpos + iter->next_arg;
g_assert (i < iter->sig->param_count);
res->type = iter->sig->params [i];
res->klass = mono_class_from_mono_type_internal (res->type);
arg_size = mono_type_stack_size (res->type, &align);
#if defined(__arm__) || defined(__mips__)
iter->args = (guint8*)(((gsize)iter->args + (align) - 1) & ~(align - 1));
#endif
res->value = iter->args;
#if G_BYTE_ORDER != G_LITTLE_ENDIAN
if (arg_size <= sizeof (gpointer)) {
int dummy;
int padding = arg_size - mono_type_size (res->type, &dummy);
res->value = (guint8*)res->value + padding;
}
#endif
iter->args = (char*)iter->args + arg_size;
iter->next_arg++;
/* g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res->type->type, arg_size, res->value); */
}
void
ves_icall_System_ArgIterator_IntGetNextArgWithType (MonoArgIterator *iter, MonoTypedRef *res, MonoType *type)
{
guint32 i, arg_size;
gint32 align;
i = iter->sig->sentinelpos + iter->next_arg;
g_assert (i < iter->sig->param_count);
while (i < iter->sig->param_count) {
if (!mono_metadata_type_equal (type, iter->sig->params [i]))
continue;
res->type = iter->sig->params [i];
res->klass = mono_class_from_mono_type_internal (res->type);
/* FIXME: endianess issue... */
arg_size = mono_type_stack_size (res->type, &align);
#if defined(__arm__) || defined(__mips__)
iter->args = (guint8*)(((gsize)iter->args + (align) - 1) & ~(align - 1));
#endif
res->value = iter->args;
iter->args = (char*)iter->args + arg_size;
iter->next_arg++;
/* g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value); */
return;
}
/* g_print ("arg type 0x%02x not found\n", res.type->type); */
memset (res, 0, sizeof (MonoTypedRef));
}
MonoType*
ves_icall_System_ArgIterator_IntGetNextArgType (MonoArgIterator *iter)
{
gint i;
i = iter->sig->sentinelpos + iter->next_arg;
g_assert (i < iter->sig->param_count);
return iter->sig->params [i];
}
MonoObjectHandle
ves_icall_System_TypedReference_ToObject (MonoTypedRef* tref, MonoError *error)
{
return typed_reference_to_object (tref, error);
}
void
ves_icall_System_TypedReference_InternalMakeTypedReference (MonoTypedRef *res, MonoObjectHandle target, MonoArrayHandle fields, MonoReflectionTypeHandle last_field, MonoError *error)
{
MonoType *ftype = NULL;
int i;
memset (res, 0, sizeof (MonoTypedRef));
g_assert (mono_array_handle_length (fields) > 0);
(void)mono_handle_class (target);
int offset = 0;
for (i = 0; i < mono_array_handle_length (fields); ++i) {
MonoClassField *f;
MONO_HANDLE_ARRAY_GETVAL (f, fields, MonoClassField*, i);
g_assert (f);
if (i == 0)
offset = f->offset;
else
offset += f->offset - sizeof (MonoObject);
(void)mono_class_from_mono_type_internal (f->type);
ftype = f->type;
}
res->type = ftype;
res->klass = mono_class_from_mono_type_internal (ftype);
res->value = (guint8*)MONO_HANDLE_RAW (target) + offset;
}
void
ves_icall_System_Runtime_InteropServices_Marshal_Prelink (MonoReflectionMethodHandle method_h, MonoError *error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (method_h, method);
if (!(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
return;
mono_lookup_pinvoke_call_internal (method, error);
/* create the wrapper, too? */
}
int
ves_icall_Interop_Sys_DoubleToString(double value, char *format, char *buffer, int bufferLength)
{
#if defined(TARGET_ARM)
/* workaround for faulty vcmp.f64 implementation on some 32bit ARM CPUs */
guint64 bits = *(guint64 *) &value;
if (bits == 0x1) { /* 4.9406564584124654E-324 */
g_assert (!strcmp (format, "%.40e"));
return snprintf (buffer, bufferLength, "%s", "4.9406564584124654417656879286822137236506e-324");
} else if (bits == 0x4) { /* 2E-323 */
g_assert (!strcmp (format, "%.40e"));
return snprintf (buffer, bufferLength, "%s", "1.9762625833649861767062751714728854894602e-323");
}
#endif
return snprintf(buffer, bufferLength, format, value);
}
static gboolean
add_modifier_to_array (MonoType *type, MonoArrayHandle dest, int dest_idx, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoClass *klass = mono_class_from_mono_type_internal (type);
MonoReflectionTypeHandle rt;
rt = mono_type_get_object_handle (m_class_get_byval_arg (klass), error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, dest_idx, rt);
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
/*
* We return NULL for no modifiers so the corlib code can return Type.EmptyTypes
* and avoid useless allocations.
*/
static MonoArrayHandle
type_array_from_modifiers (MonoType *type, int optional, MonoError *error)
{
int i, count = 0;
int cmod_count = mono_type_custom_modifier_count (type);
if (cmod_count == 0)
goto fail;
for (i = 0; i < cmod_count; ++i) {
gboolean required;
(void) mono_type_get_custom_modifier (type, i, &required, error);
goto_if_nok (error, fail);
if ((optional && !required) || (!optional && required))
count++;
}
if (!count)
goto fail;
MonoArrayHandle res;
res = mono_array_new_handle (mono_defaults.systemtype_class, count, error);
goto_if_nok (error, fail);
count = 0;
for (i = 0; i < cmod_count; ++i) {
gboolean required;
MonoType *cmod_type = mono_type_get_custom_modifier (type, i, &required, error);
goto_if_nok (error, fail);
if ((optional && !required) || (!optional && required)) {
if (!add_modifier_to_array (cmod_type, res, count, error))
goto fail;
count++;
}
}
return res;
fail:
return MONO_HANDLE_NEW (MonoArray, NULL);
}
MonoArrayHandle
ves_icall_RuntimeParameterInfo_GetTypeModifiers (MonoReflectionTypeHandle rt, MonoObjectHandle member, int pos, MonoBoolean optional, MonoError *error)
{
MonoType *type = MONO_HANDLE_GETVAL (rt, type);
MonoClass *member_class = mono_handle_class (member);
MonoMethod *method = NULL;
MonoMethodSignature *sig;
if (mono_class_is_reflection_method_or_constructor (member_class)) {
method = MONO_HANDLE_GETVAL (MONO_HANDLE_CAST (MonoReflectionMethod, member), method);
} else if (m_class_get_image (member_class) == mono_defaults.corlib && !strcmp ("RuntimePropertyInfo", m_class_get_name (member_class))) {
MonoProperty *prop = MONO_HANDLE_GETVAL (MONO_HANDLE_CAST (MonoReflectionProperty, member), property);
if (!(method = prop->get))
method = prop->set;
g_assert (method);
} else if (strcmp (m_class_get_name (member_class), "DynamicMethod") == 0 && strcmp (m_class_get_name_space (member_class), "System.Reflection.Emit") == 0) {
MonoArrayHandle params = MONO_HANDLE_NEW_GET (MonoArray, MONO_HANDLE_CAST (MonoReflectionDynamicMethod, member), parameters);
MonoReflectionTypeHandle t = MONO_HANDLE_NEW (MonoReflectionType, NULL);
MONO_HANDLE_ARRAY_GETREF (t, params, pos);
type = mono_reflection_type_handle_mono_type (t, error);
return type_array_from_modifiers (type, optional, error);
} else {
char *type_name = mono_type_get_full_name (member_class);
mono_error_set_not_supported (error, "Custom modifiers on a ParamInfo with member %s are not supported", type_name);
g_free (type_name);
return NULL_HANDLE_ARRAY;
}
sig = mono_method_signature_internal (method);
if (pos == -1)
type = sig->ret;
else
type = sig->params [pos];
return type_array_from_modifiers (type, optional, error);
}
static MonoType*
get_property_type (MonoProperty *prop)
{
MonoMethodSignature *sig;
if (prop->get) {
sig = mono_method_signature_internal (prop->get);
return sig->ret;
} else if (prop->set) {
sig = mono_method_signature_internal (prop->set);
return sig->params [sig->param_count - 1];
}
return NULL;
}
MonoArrayHandle
ves_icall_RuntimePropertyInfo_GetTypeModifiers (MonoReflectionPropertyHandle property, MonoBoolean optional, MonoError *error)
{
MonoProperty *prop = MONO_HANDLE_GETVAL (property, property);
MonoType *type = get_property_type (prop);
if (!type)
return NULL_HANDLE_ARRAY;
return type_array_from_modifiers (type, optional, error);
}
/*
*Construct a MonoType suited to be used to decode a constant blob object.
*
* @type is the target type which will be constructed
* @blob_type is the blob type, for example, that comes from the constant table
* @real_type is the expected constructed type.
*/
static void
mono_type_from_blob_type (MonoType *type, MonoTypeEnum blob_type, MonoType *real_type)
{
type->type = blob_type;
type->data.klass = NULL;
if (blob_type == MONO_TYPE_CLASS)
type->data.klass = mono_defaults.object_class;
else if (real_type->type == MONO_TYPE_VALUETYPE && m_class_is_enumtype (real_type->data.klass)) {
/* For enums, we need to use the base type */
type->type = MONO_TYPE_VALUETYPE;
type->data.klass = mono_class_from_mono_type_internal (real_type);
} else
type->data.klass = mono_class_from_mono_type_internal (real_type);
}
MonoObjectHandle
ves_icall_property_info_get_default_value (MonoReflectionPropertyHandle property_handle, MonoError* error)
{
MonoReflectionProperty* property = MONO_HANDLE_RAW (property_handle);
MonoType blob_type;
MonoProperty *prop = property->property;
MonoType *type = get_property_type (prop);
MonoTypeEnum def_type;
const char *def_value;
mono_class_init_internal (prop->parent);
if (!(prop->attrs & PROPERTY_ATTRIBUTE_HAS_DEFAULT)) {
mono_error_set_invalid_operation (error, NULL);
return NULL_HANDLE;
}
def_value = mono_class_get_property_default_value (prop, &def_type);
mono_type_from_blob_type (&blob_type, def_type, type);
return mono_get_object_from_blob (&blob_type, def_value, MONO_HANDLE_NEW (MonoString, NULL), error);
}
MonoBoolean
ves_icall_MonoCustomAttrs_IsDefinedInternal (MonoObjectHandle obj, MonoReflectionTypeHandle attr_type, MonoError *error)
{
MonoClass *attr_class = mono_class_from_mono_type_internal (MONO_HANDLE_GETVAL (attr_type, type));
mono_class_init_checked (attr_class, error);
return_val_if_nok (error, FALSE);
MonoCustomAttrInfo *cinfo = mono_reflection_get_custom_attrs_info_checked (obj, error);
return_val_if_nok (error, FALSE);
if (!cinfo)
return FALSE;
gboolean found = mono_custom_attrs_has_attr (cinfo, attr_class);
if (!cinfo->cached)
mono_custom_attrs_free (cinfo);
return found;
}
MonoArrayHandle
ves_icall_MonoCustomAttrs_GetCustomAttributesInternal (MonoObjectHandle obj, MonoReflectionTypeHandle attr_type, MonoBoolean pseudoattrs, MonoError *error)
{
MonoClass *attr_class;
if (MONO_HANDLE_IS_NULL (attr_type))
attr_class = NULL;
else
attr_class = mono_class_from_mono_type_internal (MONO_HANDLE_GETVAL (attr_type, type));
if (attr_class) {
mono_class_init_checked (attr_class, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
}
return mono_reflection_get_custom_attrs_by_type_handle (obj, attr_class, error);
}
MonoArrayHandle
ves_icall_MonoCustomAttrs_GetCustomAttributesDataInternal (MonoObjectHandle obj, MonoError *error)
{
return mono_reflection_get_custom_attrs_data_checked (obj, error);
}
#ifndef DISABLE_COM
int
ves_icall_System_Runtime_InteropServices_Marshal_GetHRForException_WinRT(MonoExceptionHandle ex, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.Marshal.GetHRForException_WinRT internal call is not implemented.");
return 0;
}
MonoObjectHandle
ves_icall_System_Runtime_InteropServices_Marshal_GetNativeActivationFactory(MonoObjectHandle type, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.Marshal.GetNativeActivationFactory internal call is not implemented.");
return NULL_HANDLE;
}
void*
ves_icall_System_Runtime_InteropServices_Marshal_GetRawIUnknownForComObjectNoAddRef(MonoObjectHandle obj, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.Marshal.GetRawIUnknownForComObjectNoAddRef internal call is not implemented.");
return NULL;
}
MonoObjectHandle
ves_icall_System_Runtime_InteropServices_WindowsRuntime_UnsafeNativeMethods_GetRestrictedErrorInfo(MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.WindowsRuntime.UnsafeNativeMethods.GetRestrictedErrorInfo internal call is not implemented.");
return NULL_HANDLE;
}
MonoBoolean
ves_icall_System_Runtime_InteropServices_WindowsRuntime_UnsafeNativeMethods_RoOriginateLanguageException (int ierr, MonoStringHandle message, void* languageException, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.WindowsRuntime.UnsafeNativeMethods.RoOriginateLanguageException internal call is not implemented.");
return FALSE;
}
void
ves_icall_System_Runtime_InteropServices_WindowsRuntime_UnsafeNativeMethods_RoReportUnhandledError (MonoObjectHandle oerr, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.WindowsRuntime.UnsafeNativeMethods.RoReportUnhandledError internal call is not implemented.");
}
int
ves_icall_System_Runtime_InteropServices_WindowsRuntime_UnsafeNativeMethods_WindowsCreateString(MonoStringHandle sourceString, int length, void** hstring, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.WindowsRuntime.UnsafeNativeMethods.WindowsCreateString internal call is not implemented.");
return 0;
}
int
ves_icall_System_Runtime_InteropServices_WindowsRuntime_UnsafeNativeMethods_WindowsDeleteString(void* hstring, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.WindowsRuntime.UnsafeNativeMethods.WindowsDeleteString internal call is not implemented.");
return 0;
}
mono_unichar2*
ves_icall_System_Runtime_InteropServices_WindowsRuntime_UnsafeNativeMethods_WindowsGetStringRawBuffer(void* hstring, unsigned* length, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.WindowsRuntime.UnsafeNativeMethods.WindowsGetStringRawBuffer internal call is not implemented.");
return NULL;
}
#endif
static const MonoIcallTableCallbacks *icall_table;
static mono_mutex_t icall_mutex;
static GHashTable *icall_hash = NULL;
typedef struct _MonoIcallHashTableValue {
gconstpointer method;
guint32 flags;
} MonoIcallHashTableValue;
void
mono_install_icall_table_callbacks (const MonoIcallTableCallbacks *cb)
{
g_assert (cb->version == MONO_ICALL_TABLE_CALLBACKS_VERSION);
icall_table = cb;
}
void
mono_icall_init (void)
{
#ifndef DISABLE_ICALL_TABLES
mono_icall_table_init ();
#endif
icall_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
mono_os_mutex_init (&icall_mutex);
}
static void
mono_icall_lock (void)
{
mono_locks_os_acquire (&icall_mutex, IcallLock);
}
static void
mono_icall_unlock (void)
{
mono_locks_os_release (&icall_mutex, IcallLock);
}
static void
add_internal_call_with_flags (const char *name, gconstpointer method, guint32 flags)
{
char *key = g_strdup (name);
MonoIcallHashTableValue *value = g_new (MonoIcallHashTableValue, 1);
if (key && value) {
value->method = method;
value->flags = flags;
mono_icall_lock ();
g_hash_table_insert (icall_hash, key, (gpointer)value);
mono_icall_unlock ();
}
}
/**
* mono_dangerous_add_internal_call_coop:
* \param name method specification to surface to the managed world
* \param method pointer to a C method to invoke when the method is called
*
* Similar to \c mono_dangerous_add_raw_internal_call.
*
*/
void
mono_dangerous_add_internal_call_coop (const char *name, gconstpointer method)
{
add_internal_call_with_flags (name, method, MONO_ICALL_FLAGS_COOPERATIVE);
}
/**
* mono_dangerous_add_internal_call_no_wrapper:
* \param name method specification to surface to the managed world
* \param method pointer to a C method to invoke when the method is called
*
* Similar to \c mono_dangerous_add_raw_internal_call but with more requirements for correct
* operation.
*
* The \p method must NOT:
*
* Run for an unbounded amount of time without calling the mono runtime.
* Additionally, the method must switch to GC Safe mode to perform all blocking
* operations: performing blocking I/O, taking locks, etc. The method can't throw or raise
* exceptions or call other methods that will throw or raise exceptions since the runtime won't
* be able to detect exeptions and unwinder won't be able to correctly find last managed frame in callstack.
* This registration method is for icalls that needs very low overhead and follow all rules in their implementation.
*
*/
void
mono_dangerous_add_internal_call_no_wrapper (const char *name, gconstpointer method)
{
add_internal_call_with_flags (name, method, MONO_ICALL_FLAGS_NO_WRAPPER);
}
/**
* mono_add_internal_call:
* \param name method specification to surface to the managed world
* \param method pointer to a C method to invoke when the method is called
*
* This method surfaces the C function pointed by \p method as a method
* that has been surfaced in managed code with the method specified in
* \p name as an internal call.
*
* Internal calls are surfaced to all app domains loaded and they are
* accessibly by a type with the specified name.
*
* You must provide a fully qualified type name, that is namespaces
* and type name, followed by a colon and the method name, with an
* optional signature to bind.
*
* For example, the following are all valid declarations:
*
* \c MyApp.Services.ScriptService:Accelerate
*
* \c MyApp.Services.ScriptService:Slowdown(int,bool)
*
* You use method parameters in cases where there might be more than
* one surface method to managed code. That way you can register different
* internal calls for different method overloads.
*
* The internal calls are invoked with no marshalling. This means that .NET
* types like \c System.String are exposed as \c MonoString* parameters. This is
* different than the way that strings are surfaced in P/Invoke.
*
* For more information on how the parameters are marshalled, see the
* <a href="http://www.mono-project.com/docs/advanced/embedding/">Mono Embedding</a>
* page.
*
* See the <a href="mono-api-methods.html#method-desc">Method Description</a>
* reference for more information on the format of method descriptions.
*/
void
mono_add_internal_call (const char *name, gconstpointer method)
{
add_internal_call_with_flags (name, method, MONO_ICALL_FLAGS_FOREIGN);
}
/**
* mono_dangerous_add_raw_internal_call:
* \param name method specification to surface to the managed world
* \param method pointer to a C method to invoke when the method is called
*
* Similar to \c mono_add_internal_call but with more requirements for correct
* operation.
*
* A thread running a dangerous raw internal call will avoid a thread state
* transition on entry and exit, but it must take responsiblity for cooperating
* with the Mono runtime.
*
* The \p method must NOT:
*
* Run for an unbounded amount of time without calling the mono runtime.
* Additionally, the method must switch to GC Safe mode to perform all blocking
* operations: performing blocking I/O, taking locks, etc.
*
*/
void
mono_dangerous_add_raw_internal_call (const char *name, gconstpointer method)
{
add_internal_call_with_flags (name, method, MONO_ICALL_FLAGS_COOPERATIVE);
}
/**
* mono_add_internal_call_with_flags:
* \param name method specification to surface to the managed world
* \param method pointer to a C method to invoke when the method is called
* \param cooperative if \c TRUE, run icall in GC Unsafe (cooperatively suspended) mode,
* otherwise GC Safe (blocking)
*
* Like \c mono_add_internal_call, but if \p cooperative is \c TRUE the added
* icall promises that it will use the coopertive API to inform the runtime
* when it is running blocking operations, that it will not run for unbounded
* amounts of time without safepointing, and that it will not hold managed
* object references across suspend safepoints.
*
* If \p cooperative is \c FALSE, run the icall in GC Safe mode - the icall may
* block. The icall must obey the GC Safe rules, e.g. it must not touch
* unpinned managed memory.
*
*/
void
mono_add_internal_call_with_flags (const char *name, gconstpointer method, gboolean cooperative)
{
add_internal_call_with_flags (name, method, cooperative ? MONO_ICALL_FLAGS_COOPERATIVE : MONO_ICALL_FLAGS_FOREIGN);
}
void
mono_add_internal_call_internal (const char *name, gconstpointer method)
{
add_internal_call_with_flags (name, method, MONO_ICALL_FLAGS_COOPERATIVE);
}
/*
* we should probably export this as an helper (handle nested types).
* Returns the number of chars written in buf.
*/
static int
concat_class_name (char *buf, int bufsize, MonoClass *klass)
{
int nspacelen, cnamelen;
nspacelen = strlen (m_class_get_name_space (klass));
cnamelen = strlen (m_class_get_name (klass));
if (nspacelen + cnamelen + 2 > bufsize)
return 0;
if (nspacelen) {
memcpy (buf, m_class_get_name_space (klass), nspacelen);
buf [nspacelen ++] = '.';
}
memcpy (buf + nspacelen, m_class_get_name (klass), cnamelen);
buf [nspacelen + cnamelen] = 0;
return nspacelen + cnamelen;
}
static void
no_icall_table (void)
{
g_assert_not_reached ();
}
gboolean
mono_is_missing_icall_addr (gconstpointer addr)
{
return addr == NULL || addr == no_icall_table;
}
/*
* Returns either NULL or no_icall_table for missing icalls.
*/
gconstpointer
mono_lookup_internal_call_full_with_flags (MonoMethod *method, gboolean warn_on_missing, guint32 *flags)
{
char *sigstart = NULL;
char *tmpsig = NULL;
char mname [2048];
char *classname = NULL;
int typelen = 0, mlen, siglen;
gconstpointer res = NULL;
gboolean locked = FALSE;
g_assert (method != NULL);
if (method->is_inflated)
method = ((MonoMethodInflated *) method)->declaring;
if (m_class_get_nested_in (method->klass)) {
int pos = concat_class_name (mname, sizeof (mname)-2, m_class_get_nested_in (method->klass));
if (!pos)
goto exit;
mname [pos++] = '/';
mname [pos] = 0;
typelen = concat_class_name (mname+pos, sizeof (mname)-pos-1, method->klass);
if (!typelen)
goto exit;
typelen += pos;
} else {
typelen = concat_class_name (mname, sizeof (mname), method->klass);
if (!typelen)
goto exit;
}
classname = g_strdup (mname);
mname [typelen] = ':';
mname [typelen + 1] = ':';
mlen = strlen (method->name);
memcpy (mname + typelen + 2, method->name, mlen);
sigstart = mname + typelen + 2 + mlen;
*sigstart = 0;
tmpsig = mono_signature_get_desc (mono_method_signature_internal (method), TRUE);
siglen = strlen (tmpsig);
if (typelen + mlen + siglen + 6 > sizeof (mname))
goto exit;
sigstart [0] = '(';
memcpy (sigstart + 1, tmpsig, siglen);
sigstart [siglen + 1] = ')';
sigstart [siglen + 2] = 0;
/* mono_marshal_get_native_wrapper () depends on this */
if (method->klass == mono_defaults.string_class && !strcmp (method->name, ".ctor")) {
res = (gconstpointer)ves_icall_System_String_ctor_RedirectToCreateString;
goto exit;
}
mono_icall_lock ();
locked = TRUE;
res = g_hash_table_lookup (icall_hash, mname);
if (res) {
MonoIcallHashTableValue *value = (MonoIcallHashTableValue *)res;
if (flags)
*flags = value->flags;
res = value->method;
goto exit;
}
/* try without signature */
*sigstart = 0;
res = g_hash_table_lookup (icall_hash, mname);
if (res) {
MonoIcallHashTableValue *value = (MonoIcallHashTableValue *)res;
if (flags)
*flags = value->flags;
res = value->method;
goto exit;
}
if (!icall_table) {
/* Fail only when the result is actually used */
res = (gconstpointer)no_icall_table;
goto exit;
} else {
gboolean uses_handles = FALSE;
g_assert (icall_table->lookup);
res = icall_table->lookup (method, classname, sigstart - mlen, sigstart, &uses_handles);
if (res && flags && uses_handles)
*flags = *flags | MONO_ICALL_FLAGS_USES_HANDLES;
mono_icall_unlock ();
locked = FALSE;
if (res)
goto exit;
if (warn_on_missing) {
g_warning ("cant resolve internal call to \"%s\" (tested without signature also)", mname);
g_print ("\nYour mono runtime and class libraries are out of sync.\n");
g_print ("The out of sync library is: %s\n", m_class_get_image (method->klass)->name);
g_print ("\nWhen you update one from git you need to update, compile and install\nthe other too.\n");
g_print ("Do not report this as a bug unless you're sure you have updated correctly:\nyou probably have a broken mono install.\n");
g_print ("If you see other errors or faults after this message they are probably related\n");
g_print ("and you need to fix your mono install first.\n");
}
res = NULL;
}
exit:
if (locked)
mono_icall_unlock ();
g_free (classname);
g_free (tmpsig);
return res;
}
/**
* mono_lookup_internal_call_full:
* \param method the method to look up
* \param uses_handles out argument if method needs handles around managed objects.
* \returns a pointer to the icall code for the given method. If
* \p uses_handles is not NULL, it will be set to TRUE if the method
* needs managed objects wrapped using the infrastructure in handle.h
*
* If the method is not found, warns and returns NULL.
*/
gconstpointer
mono_lookup_internal_call_full (MonoMethod *method, gboolean warn_on_missing, mono_bool *uses_handles, mono_bool *foreign)
{
if (uses_handles)
*uses_handles = FALSE;
if (foreign)
*foreign = FALSE;
guint32 flags = MONO_ICALL_FLAGS_NONE;
gconstpointer addr = mono_lookup_internal_call_full_with_flags (method, warn_on_missing, &flags);
if (uses_handles && (flags & MONO_ICALL_FLAGS_USES_HANDLES))
*uses_handles = TRUE;
if (foreign && (flags & MONO_ICALL_FLAGS_FOREIGN))
*foreign = TRUE;
return addr;
}
/**
* mono_lookup_internal_call:
*/
gpointer
mono_lookup_internal_call (MonoMethod *method)
{
return (gpointer)mono_lookup_internal_call_full (method, TRUE, NULL, NULL);
}
/*
* mono_lookup_icall_symbol:
*
* Given the icall METHOD, returns its C symbol.
*/
const char*
mono_lookup_icall_symbol (MonoMethod *m)
{
if (!icall_table)
return NULL;
g_assert (icall_table->lookup_icall_symbol);
gpointer func;
func = (gpointer)mono_lookup_internal_call_full (m, FALSE, NULL, NULL);
if (!func)
return NULL;
return icall_table->lookup_icall_symbol (func);
}
#if defined(TARGET_WIN32) && defined(TARGET_X86)
/*
* Under windows, the default pinvoke calling convention is STDCALL but
* we need CDECL.
*/
#define MONO_ICALL_SIGNATURE_CALL_CONVENTION MONO_CALL_C
#else
#define MONO_ICALL_SIGNATURE_CALL_CONVENTION 0
#endif
// Storage for these enums is pointer-sized as it gets replaced with MonoType*.
//
// mono_create_icall_signatures depends on this order. Handle with care.
typedef enum ICallSigType {
ICALL_SIG_TYPE_bool = 0x00,
ICALL_SIG_TYPE_boolean = ICALL_SIG_TYPE_bool,
ICALL_SIG_TYPE_double = 0x01,
ICALL_SIG_TYPE_float = 0x02,
ICALL_SIG_TYPE_int = 0x03,
ICALL_SIG_TYPE_int16 = 0x04,
ICALL_SIG_TYPE_int32 = ICALL_SIG_TYPE_int,
ICALL_SIG_TYPE_int8 = 0x05,
ICALL_SIG_TYPE_long = 0x06,
ICALL_SIG_TYPE_obj = 0x07,
ICALL_SIG_TYPE_object = ICALL_SIG_TYPE_obj,
ICALL_SIG_TYPE_ptr = 0x08,
ICALL_SIG_TYPE_ptrref = 0x09,
ICALL_SIG_TYPE_string = 0x0A,
ICALL_SIG_TYPE_uint16 = 0x0B,
ICALL_SIG_TYPE_uint32 = 0x0C,
ICALL_SIG_TYPE_uint8 = 0x0D,
ICALL_SIG_TYPE_ulong = 0x0E,
ICALL_SIG_TYPE_void = 0x0F,
ICALL_SIG_TYPE_sizet = 0x10
} ICallSigType;
#define ICALL_SIG_TYPES_1(a) ICALL_SIG_TYPE_ ## a,
#define ICALL_SIG_TYPES_2(a, b) ICALL_SIG_TYPES_1 (a ) ICALL_SIG_TYPES_1 (b)
#define ICALL_SIG_TYPES_3(a, b, c) ICALL_SIG_TYPES_2 (a, b ) ICALL_SIG_TYPES_1 (c)
#define ICALL_SIG_TYPES_4(a, b, c, d) ICALL_SIG_TYPES_3 (a, b, c ) ICALL_SIG_TYPES_1 (d)
#define ICALL_SIG_TYPES_5(a, b, c, d, e) ICALL_SIG_TYPES_4 (a, b, c, d ) ICALL_SIG_TYPES_1 (e)
#define ICALL_SIG_TYPES_6(a, b, c, d, e, f) ICALL_SIG_TYPES_5 (a, b, c, d, e) ICALL_SIG_TYPES_1 (f)
#define ICALL_SIG_TYPES_7(a, b, c, d, e, f, g) ICALL_SIG_TYPES_6 (a, b, c, d, e, f) ICALL_SIG_TYPES_1 (g)
#define ICALL_SIG_TYPES_8(a, b, c, d, e, f, g, h) ICALL_SIG_TYPES_7 (a, b, c, d, e, f, g) ICALL_SIG_TYPES_1 (h)
#define ICALL_SIG_TYPES(n, types) ICALL_SIG_TYPES_ ## n types
// A scheme to make these const would be nice.
static struct {
#define ICALL_SIG(n, xtypes) \
struct { \
MonoMethodSignature sig; \
gsize types [n]; \
} ICALL_SIG_NAME (n, xtypes);
ICALL_SIGS
MonoMethodSignature end; // terminal zeroed element
} mono_icall_signatures = {
#undef ICALL_SIG
#define ICALL_SIG(n, types) { { \
0, /* ret */ \
n, /* param_count */ \
-1, /* sentinelpos */ \
0, /* generic_param_count */ \
MONO_ICALL_SIGNATURE_CALL_CONVENTION, \
0, /* hasthis */ \
0, /* explicit_this */ \
1, /* pinvoke */ \
0, /* is_inflated */ \
0, /* has_type_parameters */ \
}, /* possible gap here, depending on MONO_ZERO_LEN_ARRAY */ \
{ ICALL_SIG_TYPES (n, types) } }, /* params and ret */
ICALL_SIGS
};
#undef ICALL_SIG
#define ICALL_SIG(n, types) MonoMethodSignature * const ICALL_SIG_NAME (n, types) = &mono_icall_signatures.ICALL_SIG_NAME (n, types).sig;
ICALL_SIGS
#undef ICALL_SIG
void
mono_create_icall_signatures (void)
{
// Fixup the mostly statically initialized icall signatures.
// x = m_class_get_byval_arg (x)
// Initialize ret with params [0] and params [i] with params [i + 1].
// ptrref is special
//
// FIXME This is a bit obscure.
typedef MonoMethodSignature G_MAY_ALIAS MonoMethodSignature_a;
typedef gsize G_MAY_ALIAS gsize_a;
MonoType * const lookup [ ] = {
m_class_get_byval_arg (mono_defaults.boolean_class), // ICALL_SIG_TYPE_bool
m_class_get_byval_arg (mono_defaults.double_class), // ICALL_SIG_TYPE_double
m_class_get_byval_arg (mono_defaults.single_class), // ICALL_SIG_TYPE_float
m_class_get_byval_arg (mono_defaults.int32_class), // ICALL_SIG_TYPE_int
m_class_get_byval_arg (mono_defaults.int16_class), // ICALL_SIG_TYPE_int16
m_class_get_byval_arg (mono_defaults.sbyte_class), // ICALL_SIG_TYPE_int8
m_class_get_byval_arg (mono_defaults.int64_class), // ICALL_SIG_TYPE_long
m_class_get_byval_arg (mono_defaults.object_class), // ICALL_SIG_TYPE_obj
m_class_get_byval_arg (mono_defaults.int_class), // ICALL_SIG_TYPE_ptr
mono_class_get_byref_type (mono_defaults.int_class), // ICALL_SIG_TYPE_ptrref
m_class_get_byval_arg (mono_defaults.string_class), // ICALL_SIG_TYPE_string
m_class_get_byval_arg (mono_defaults.uint16_class), // ICALL_SIG_TYPE_uint16
m_class_get_byval_arg (mono_defaults.uint32_class), // ICALL_SIG_TYPE_uint32
m_class_get_byval_arg (mono_defaults.byte_class), // ICALL_SIG_TYPE_uint8
m_class_get_byval_arg (mono_defaults.uint64_class), // ICALL_SIG_TYPE_ulong
m_class_get_byval_arg (mono_defaults.void_class), // ICALL_SIG_TYPE_void
m_class_get_byval_arg (mono_defaults.int_class), // ICALL_SIG_TYPE_sizet
};
MonoMethodSignature_a *sig = (MonoMethodSignature*)&mono_icall_signatures;
int n;
while ((n = sig->param_count)) {
--sig->param_count; // remove ret
gsize_a *types = (gsize_a*)(sig + 1);
for (int i = 0; i < n; ++i) {
gsize index = *types++;
g_assert (index < G_N_ELEMENTS (lookup));
// Casts on next line are attempt to follow strict aliasing rules,
// to ensure reading from *types precedes writing
// to params [].
*(gsize*)(i ? &sig->params [i - 1] : &sig->ret) = (gsize)lookup [index];
}
sig = (MonoMethodSignature*)types;
}
}
void
mono_register_jit_icall_info (MonoJitICallInfo *info, gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean avoid_wrapper, const char *c_symbol)
{
// Duplicate initialization is allowed and racy, assuming it is equivalent.
info->name = name;
info->func = func;
info->sig = sig;
info->c_symbol = c_symbol;
// Fill in wrapper ahead of time, to just be func, to avoid
// later initializing it to anything else. So therefore, no wrapper.
if (avoid_wrapper) {
info->wrapper = func;
} else {
// Leave it alone in case of a race.
}
}
int
ves_icall_System_GC_GetCollectionCount (int generation)
{
return mono_gc_collection_count (generation);
}
int
ves_icall_System_GC_GetGeneration (MonoObjectHandle object, MonoError *error)
{
return mono_gc_get_generation (MONO_HANDLE_RAW (object));
}
int
ves_icall_System_GC_GetMaxGeneration (void)
{
return mono_gc_max_generation ();
}
gint64
ves_icall_System_GC_GetAllocatedBytesForCurrentThread (void)
{
return mono_gc_get_allocated_bytes_for_current_thread ();
}
guint64
ves_icall_System_GC_GetTotalAllocatedBytes (MonoBoolean precise, MonoError* error)
{
return mono_gc_get_total_allocated_bytes (precise);
}
void
ves_icall_System_GC_RecordPressure (gint64 value)
{
mono_gc_add_memory_pressure (value);
}
MonoBoolean
ves_icall_System_Threading_Thread_YieldInternal (void)
{
mono_threads_platform_yield ();
return TRUE;
}
gint32
ves_icall_System_Environment_get_ProcessorCount (void)
{
return mono_cpu_count ();
}
// Generate wrappers.
#define ICALL_TYPE(id,name,first) /* nothing */
#define ICALL(id,name,func) /* nothing */
#define NOHANDLES(inner) /* nothing */
#define MONO_HANDLE_REGISTER_ICALL(func, ret, nargs, argtypes) MONO_HANDLE_REGISTER_ICALL_IMPLEMENT (func, ret, nargs, argtypes)
// Some native functions are exposed via multiple managed names.
// Producing a wrapper for these results in duplicate wrappers with the same names,
// which fails to compile. Do not produce such duplicate wrappers. Alternatively,
// a one line native function with a different name that calls the main one could be used.
// i.e. the wrapper would also have a different name.
#define HANDLES_REUSE_WRAPPER(...) /* nothing */
#define HANDLES(id, name, func, ret, nargs, argtypes) \
MONO_HANDLE_DECLARE (id, name, func, ret, nargs, argtypes); \
MONO_HANDLE_IMPLEMENT (id, name, func, ret, nargs, argtypes)
#include "metadata/icall-def.h"
#undef HANDLES
#undef HANDLES_REUSE_WRAPPER
#undef ICALL_TYPE
#undef ICALL
#undef NOHANDLES
#undef MONO_HANDLE_REGISTER_ICALL
| /**
* \file
*
* Authors:
* Dietmar Maurer ([email protected])
* Paolo Molaro ([email protected])
* Patrik Torstensson ([email protected])
* Marek Safar ([email protected])
* Aleksey Kliger ([email protected])
*
* Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
* Copyright 2004-2009 Novell, Inc (http://www.novell.com)
* Copyright 2011-2015 Xamarin Inc (http://www.xamarin.com).
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#if defined(TARGET_WIN32) || defined(HOST_WIN32)
#include <stdio.h>
#endif
#include <glib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#if defined (HAVE_WCHAR_H)
#include <wchar.h>
#endif
#include "mono/metadata/icall-internals.h"
#include "mono/utils/mono-membar.h"
#include <mono/metadata/object.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/monitor.h>
#include <mono/metadata/reflection.h>
#include <mono/metadata/image-internals.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/assembly-internals.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/exception-internals.h>
#include <mono/metadata/w32file.h>
#include <mono/metadata/mono-endian.h>
#include <mono/metadata/tokentype.h>
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/metadata-update.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/class-init.h>
#include <mono/metadata/reflection-internals.h>
#include <mono/metadata/marshal.h>
#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mono-gc.h>
#include <mono/metadata/appdomain-icalls.h>
#include <mono/metadata/string-icalls.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/cil-coff.h>
#include <mono/metadata/mono-perfcounters.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/mono-ptr-array.h>
#include <mono/metadata/verify-internals.h>
#include <mono/metadata/runtime.h>
#include <mono/metadata/seq-points-data.h>
#include <mono/metadata/icall-table.h>
#include <mono/metadata/handle.h>
#include <mono/metadata/w32event.h>
#include <mono/metadata/abi-details.h>
#include <mono/metadata/loader-internals.h>
#include <mono/utils/monobitset.h>
#include <mono/utils/mono-time.h>
#include <mono/utils/mono-proclib.h>
#include <mono/utils/mono-string.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-digest.h>
#include <mono/utils/bsearch.h>
#include <mono/utils/mono-os-mutex.h>
#include <mono/utils/mono-threads.h>
#include <mono/metadata/w32error.h>
#include <mono/utils/w32api.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-math.h>
#if !defined(HOST_WIN32) && defined(HAVE_SYS_UTSNAME_H)
#include <sys/utsname.h>
#endif
#if defined(HOST_WIN32)
#include <windows.h>
#endif
#include "icall-decl.h"
#include "mono/utils/mono-threads-coop.h"
#include "mono/metadata/icall-signatures.h"
#include "mono/utils/mono-signal-handler.h"
#if _MSC_VER
#pragma warning(disable:4047) // FIXME differs in levels of indirection
#endif
//#define MONO_DEBUG_ICALLARRAY
// Inline with CoreCLR heuristics, https://github.com/dotnet/runtime/blob/69e114c1abf91241a0eeecf1ecceab4711b8aa62/src/coreclr/vm/threads.cpp#L6408.
// Minimum stack size should be sufficient to allow a typical non-recursive call chain to execute,
// including potential exception handling and garbage collection. Used for probing for available
// stack space through RuntimeHelpers.EnsureSufficientExecutionStack.
#if TARGET_SIZEOF_VOID_P == 8
#define MONO_MIN_EXECUTION_STACK_SIZE (128 * 1024)
#else
#define MONO_MIN_EXECUTION_STACK_SIZE (64 * 1024)
#endif
#ifdef MONO_DEBUG_ICALLARRAY
static char debug_icallarray; // 0:uninitialized 1:true 2:false
static gboolean
icallarray_print_enabled (void)
{
if (!debug_icallarray)
debug_icallarray = MONO_TRACE_IS_TRACED (G_LOG_LEVEL_DEBUG, MONO_TRACE_ICALLARRAY) ? 1 : 2;
return debug_icallarray == 1;
}
static void
icallarray_print (const char *format, ...)
{
if (!icallarray_print_enabled ())
return;
va_list args;
va_start (args, format);
g_printv (format, args);
va_end (args);
}
#else
#define icallarray_print_enabled() (FALSE)
#define icallarray_print(...) /* nothing */
#endif
/* Lazy class loading functions */
static GENERATE_GET_CLASS_WITH_CACHE (module, "System.Reflection", "Module")
static void
array_set_value_impl (MonoArrayHandle arr, MonoObjectHandle value, guint32 pos, gboolean strict_enums, gboolean strict_signs, MonoError *error);
static MonoArrayHandle
type_array_from_modifiers (MonoType *type, int optional, MonoError *error);
static inline MonoBoolean
is_generic_parameter (MonoType *type)
{
return !m_type_is_byref (type) && (type->type == MONO_TYPE_VAR || type->type == MONO_TYPE_MVAR);
}
#ifdef HOST_WIN32
static void
mono_icall_make_platform_path (gchar *path)
{
for (size_t i = strlen (path); i > 0; i--)
if (path [i-1] == '\\')
path [i-1] = '/';
}
static const gchar *
mono_icall_get_file_path_prefix (const gchar *path)
{
if (*path == '/' && *(path + 1) == '/') {
return "file:";
} else {
return "file:///";
}
}
#else
static inline void
mono_icall_make_platform_path (gchar *path)
{
return;
}
static inline const gchar *
mono_icall_get_file_path_prefix (const gchar *path)
{
return "file://";
}
#endif /* HOST_WIN32 */
MonoJitICallInfos mono_jit_icall_info;
MonoObjectHandle
ves_icall_System_Array_GetValueImpl (MonoArrayHandle array, guint32 pos, MonoError *error)
{
MonoClass * const array_class = mono_handle_class (array);
MonoClass * const element_class = m_class_get_element_class (array_class);
if (m_class_is_native_pointer (element_class)) {
mono_error_set_not_supported (error, NULL);
return NULL_HANDLE;
}
if (m_class_is_valuetype (element_class)) {
gsize element_size = mono_array_element_size (array_class);
gpointer element_address = mono_array_addr_with_size_fast (MONO_HANDLE_RAW (array), element_size, (gsize)pos);
return mono_value_box_handle (element_class, element_address, error);
}
MonoObjectHandle result = mono_new_null ();
mono_handle_array_getref (result, array, pos);
return result;
}
void
ves_icall_System_Array_SetValueImpl (MonoArrayHandle arr, MonoObjectHandle value, guint32 pos, MonoError *error)
{
array_set_value_impl (arr, value, pos, TRUE, TRUE, error);
}
static inline void
set_invalid_cast (MonoError *error, MonoClass *src_class, MonoClass *dst_class)
{
mono_get_runtime_callbacks ()->set_cast_details (src_class, dst_class);
mono_error_set_invalid_cast (error);
}
void
ves_icall_System_Array_SetValueRelaxedImpl (MonoArrayHandle arr, MonoObjectHandle value, guint32 pos, MonoError *error)
{
array_set_value_impl (arr, value, pos, FALSE, FALSE, error);
}
// Copied from CoreCLR: https://github.com/dotnet/coreclr/blob/d3e39bc2f81e3dbf9e4b96347f62b49d8700336c/src/vm/invokeutil.cpp#L33
#define PT_Primitive 0x01000000
static const guint32 primitive_conversions [] = {
0x00, // MONO_TYPE_END
0x00, // MONO_TYPE_VOID
PT_Primitive | 0x0004, // MONO_TYPE_BOOLEAN
PT_Primitive | 0x3F88, // MONO_TYPE_CHAR (W = U2, CHAR, I4, U4, I8, U8, R4, R8)
PT_Primitive | 0x3550, // MONO_TYPE_I1 (W = I1, I2, I4, I8, R4, R8)
PT_Primitive | 0x3FE8, // MONO_TYPE_U1 (W = CHAR, U1, I2, U2, I4, U4, I8, U8, R4, R8)
PT_Primitive | 0x3540, // MONO_TYPE_I2 (W = I2, I4, I8, R4, R8)
PT_Primitive | 0x3F88, // MONO_TYPE_U2 (W = U2, CHAR, I4, U4, I8, U8, R4, R8)
PT_Primitive | 0x3500, // MONO_TYPE_I4 (W = I4, I8, R4, R8)
PT_Primitive | 0x3E00, // MONO_TYPE_U4 (W = U4, I8, R4, R8)
PT_Primitive | 0x3400, // MONO_TYPE_I8 (W = I8, R4, R8)
PT_Primitive | 0x3800, // MONO_TYPE_U8 (W = U8, R4, R8)
PT_Primitive | 0x3000, // MONO_TYPE_R4 (W = R4, R8)
PT_Primitive | 0x2000, // MONO_TYPE_R8 (W = R8)
};
// Copied from CoreCLR: https://github.com/dotnet/coreclr/blob/030a3ea9b8dbeae89c90d34441d4d9a1cf4a7de6/src/vm/invokeutil.h#L176
static
gboolean can_primitive_widen (MonoTypeEnum src_type, MonoTypeEnum dest_type)
{
if (dest_type > MONO_TYPE_R8 || src_type > MONO_TYPE_R8) {
return (MONO_TYPE_I == dest_type && MONO_TYPE_I == src_type) || (MONO_TYPE_U == dest_type && MONO_TYPE_U == src_type);
}
return ((1 << dest_type) & primitive_conversions [src_type]) != 0;
}
// Copied from CoreCLR: https://github.com/dotnet/coreclr/blob/eafa8648ebee92de1380278b15cd5c2b6ef11218/src/vm/array.cpp#L1406
static MonoTypeEnum
get_normalized_integral_array_element_type (MonoTypeEnum elementType)
{
// Array Primitive types such as E_T_I4 and E_T_U4 are interchangeable
// Enums with interchangeable underlying types are interchangable
// BOOL is NOT interchangeable with I1/U1, neither CHAR -- with I2/U2
switch (elementType) {
case MONO_TYPE_U1:
case MONO_TYPE_U2:
case MONO_TYPE_U4:
case MONO_TYPE_U8:
case MONO_TYPE_U:
return (MonoTypeEnum) (elementType - 1); // normalize to signed type
}
return elementType;
}
MonoBoolean
ves_icall_System_Array_CanChangePrimitive (MonoReflectionType *volatile* ref_src_type_handle, MonoReflectionType *volatile* ref_dst_type_handle, MonoBoolean reliable)
{
MonoReflectionType* const ref_src_type = *ref_src_type_handle;
MonoReflectionType* const ref_dst_type = *ref_dst_type_handle;
MonoType *src_type = ref_src_type->type;
MonoType *dst_type = ref_dst_type->type;
g_assert (mono_type_is_primitive (src_type));
g_assert (mono_type_is_primitive (dst_type));
MonoTypeEnum normalized_src_type = get_normalized_integral_array_element_type (src_type->type);
MonoTypeEnum normalized_dst_type = get_normalized_integral_array_element_type (dst_type->type);
// Allow conversions like int <-> uint
if (normalized_src_type == normalized_dst_type) {
return TRUE;
}
// Widening is not allowed if reliable is true.
if (reliable) {
return FALSE;
}
// NOTE we don't use normalized types here so int -> ulong will be false
// see https://github.com/dotnet/coreclr/pull/25209#issuecomment-505952295
return can_primitive_widen (src_type->type, dst_type->type);
}
static void
array_set_value_impl (MonoArrayHandle arr_handle, MonoObjectHandle value_handle, guint32 pos, gboolean strict_enums, gboolean strict_signs, MonoError *error)
{
MonoClass *ac, *vc, *ec;
gint32 esize, vsize;
gpointer *ea = NULL, *va = NULL;
guint64 u64 = 0;
gint64 i64 = 0;
gdouble r64 = 0;
gboolean castOk = FALSE;
gboolean et_isenum = FALSE;
gboolean vt_isenum = FALSE;
if (!MONO_HANDLE_IS_NULL (value_handle))
vc = mono_handle_class (value_handle);
else
vc = NULL;
ac = mono_handle_class (arr_handle);
ec = m_class_get_element_class (ac);
esize = mono_array_element_size (ac);
if (mono_class_is_nullable (ec)) {
if (vc && m_class_is_primitive (vc) && vc != m_class_get_nullable_elem_class (ec)) {
// T -> Nullable<T> T must be exact
set_invalid_cast (error, vc, ec);
goto leave;
}
MONO_ENTER_NO_SAFEPOINTS;
ea = (gpointer*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (arr_handle), esize, pos);
if (!MONO_HANDLE_IS_NULL (value_handle))
va = (gpointer*) mono_object_unbox_internal (MONO_HANDLE_RAW (value_handle));
mono_nullable_init_unboxed ((guint8*)ea, va, ec);
MONO_EXIT_NO_SAFEPOINTS;
goto leave;
}
if (MONO_HANDLE_IS_NULL (value_handle)) {
MONO_ENTER_NO_SAFEPOINTS;
ea = (gpointer*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (arr_handle), esize, pos);
mono_gc_bzero_atomic (ea, esize);
MONO_EXIT_NO_SAFEPOINTS;
goto leave;
}
#define WIDENING_MSG NULL
#define WIDENING_ARG NULL
#define NO_WIDENING_CONVERSION G_STMT_START{ \
mono_error_set_argument (error, WIDENING_ARG, WIDENING_MSG); \
break; \
}G_STMT_END
#define CHECK_WIDENING_CONVERSION(extra) G_STMT_START{ \
if (esize < vsize + (extra)) { \
mono_error_set_argument (error, WIDENING_ARG, WIDENING_MSG); \
break; \
} \
}G_STMT_END
#define INVALID_CAST G_STMT_START{ \
mono_get_runtime_callbacks ()->set_cast_details (vc, ec); \
mono_error_set_invalid_cast (error); \
break; \
}G_STMT_END
MonoTypeEnum et;
et = m_class_get_byval_arg (ec)->type;
MonoTypeEnum vt;
vt = m_class_get_byval_arg (vc)->type;
/* Check element (destination) type. */
switch (et) {
case MONO_TYPE_STRING:
switch (vt) {
case MONO_TYPE_STRING:
break;
default:
INVALID_CAST;
}
break;
case MONO_TYPE_BOOLEAN:
switch (vt) {
case MONO_TYPE_BOOLEAN:
break;
case MONO_TYPE_CHAR:
case MONO_TYPE_U1:
case MONO_TYPE_U2:
case MONO_TYPE_U4:
case MONO_TYPE_U8:
case MONO_TYPE_I1:
case MONO_TYPE_I2:
case MONO_TYPE_I4:
case MONO_TYPE_I8:
case MONO_TYPE_R4:
case MONO_TYPE_R8:
NO_WIDENING_CONVERSION;
break;
default:
INVALID_CAST;
}
break;
default:
break;
}
if (!is_ok (error))
goto leave;
castOk = mono_object_handle_isinst_mbyref_raw (value_handle, ec, error);
if (!is_ok (error))
goto leave;
if (!m_class_is_valuetype (ec)) {
if (!castOk)
INVALID_CAST;
if (is_ok (error))
MONO_HANDLE_ARRAY_SETREF (arr_handle, pos, value_handle);
goto leave;
}
if (castOk) {
MONO_ENTER_NO_SAFEPOINTS;
ea = (gpointer*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (arr_handle), esize, pos);
va = (gpointer*) mono_object_unbox_internal (MONO_HANDLE_RAW (value_handle));
if (m_class_has_references (ec))
mono_value_copy_internal (ea, va, ec);
else
mono_gc_memmove_atomic (ea, va, esize);
MONO_EXIT_NO_SAFEPOINTS;
goto leave;
}
if (!m_class_is_valuetype (vc))
INVALID_CAST;
if (!is_ok (error))
goto leave;
vsize = mono_class_value_size (vc, NULL);
et_isenum = et == MONO_TYPE_VALUETYPE && m_class_is_enumtype (m_class_get_byval_arg (ec)->data.klass);
vt_isenum = vt == MONO_TYPE_VALUETYPE && m_class_is_enumtype (m_class_get_byval_arg (vc)->data.klass);
if (strict_enums && et_isenum && !vt_isenum) {
INVALID_CAST;
goto leave;
}
if (et_isenum)
et = mono_class_enum_basetype_internal (m_class_get_byval_arg (ec)->data.klass)->type;
if (vt_isenum)
vt = mono_class_enum_basetype_internal (m_class_get_byval_arg (vc)->data.klass)->type;
// Treat MONO_TYPE_U/I as MONO_TYPE_U8/I8/U4/I4
#if SIZEOF_VOID_P == 8
vt = vt == MONO_TYPE_U ? MONO_TYPE_U8 : (vt == MONO_TYPE_I ? MONO_TYPE_I8 : vt);
et = et == MONO_TYPE_U ? MONO_TYPE_U8 : (et == MONO_TYPE_I ? MONO_TYPE_I8 : et);
#else
vt = vt == MONO_TYPE_U ? MONO_TYPE_U4 : (vt == MONO_TYPE_I ? MONO_TYPE_I4 : vt);
et = et == MONO_TYPE_U ? MONO_TYPE_U4 : (et == MONO_TYPE_I ? MONO_TYPE_I4 : et);
#endif
#define ASSIGN_UNSIGNED(etype) G_STMT_START{\
switch (vt) { \
case MONO_TYPE_U1: \
case MONO_TYPE_U2: \
case MONO_TYPE_U4: \
case MONO_TYPE_U8: \
case MONO_TYPE_CHAR: \
CHECK_WIDENING_CONVERSION(0); \
*(etype *) ea = (etype) u64; \
break; \
/* You can't assign a signed value to an unsigned array. */ \
case MONO_TYPE_I1: \
case MONO_TYPE_I2: \
case MONO_TYPE_I4: \
case MONO_TYPE_I8: \
if (!strict_signs) { \
CHECK_WIDENING_CONVERSION(0); \
*(etype *) ea = (etype) i64; \
break; \
} \
/* You can't assign a floating point number to an integer array. */ \
case MONO_TYPE_R4: \
case MONO_TYPE_R8: \
NO_WIDENING_CONVERSION; \
break; \
default: \
INVALID_CAST; \
break; \
} \
}G_STMT_END
#define ASSIGN_SIGNED(etype) G_STMT_START{\
switch (vt) { \
case MONO_TYPE_I1: \
case MONO_TYPE_I2: \
case MONO_TYPE_I4: \
case MONO_TYPE_I8: \
CHECK_WIDENING_CONVERSION(0); \
*(etype *) ea = (etype) i64; \
break; \
/* You can assign an unsigned value to a signed array if the array's */ \
/* element size is larger than the value size. */ \
case MONO_TYPE_U1: \
case MONO_TYPE_U2: \
case MONO_TYPE_U4: \
case MONO_TYPE_U8: \
case MONO_TYPE_CHAR: \
CHECK_WIDENING_CONVERSION(strict_signs ? 1 : 0); \
*(etype *) ea = (etype) u64; \
break; \
/* You can't assign a floating point number to an integer array. */ \
case MONO_TYPE_R4: \
case MONO_TYPE_R8: \
NO_WIDENING_CONVERSION; \
break; \
default: \
INVALID_CAST; \
break; \
} \
}G_STMT_END
#define ASSIGN_REAL(etype) G_STMT_START{\
switch (vt) { \
case MONO_TYPE_R4: \
case MONO_TYPE_R8: \
CHECK_WIDENING_CONVERSION(0); \
*(etype *) ea = (etype) r64; \
break; \
/* All integer values fit into a floating point array, so we don't */ \
/* need to CHECK_WIDENING_CONVERSION here. */ \
case MONO_TYPE_I1: \
case MONO_TYPE_I2: \
case MONO_TYPE_I4: \
case MONO_TYPE_I8: \
*(etype *) ea = (etype) i64; \
break; \
case MONO_TYPE_U1: \
case MONO_TYPE_U2: \
case MONO_TYPE_U4: \
case MONO_TYPE_U8: \
case MONO_TYPE_CHAR: \
*(etype *) ea = (etype) u64; \
break; \
default: \
INVALID_CAST; \
break; \
} \
}G_STMT_END
MONO_ENTER_NO_SAFEPOINTS;
g_assert (!MONO_HANDLE_IS_NULL (value_handle));
g_assert (m_class_is_valuetype (vc));
va = (gpointer*) mono_object_unbox_internal (MONO_HANDLE_RAW (value_handle));
ea = (gpointer*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (arr_handle), esize, pos);
switch (vt) {
case MONO_TYPE_U1:
u64 = *(guint8 *) va;
break;
case MONO_TYPE_U2:
u64 = *(guint16 *) va;
break;
case MONO_TYPE_U4:
u64 = *(guint32 *) va;
break;
case MONO_TYPE_U8:
u64 = *(guint64 *) va;
break;
case MONO_TYPE_I1:
i64 = *(gint8 *) va;
break;
case MONO_TYPE_I2:
i64 = *(gint16 *) va;
break;
case MONO_TYPE_I4:
i64 = *(gint32 *) va;
break;
case MONO_TYPE_I8:
i64 = *(gint64 *) va;
break;
case MONO_TYPE_R4:
r64 = *(gfloat *) va;
break;
case MONO_TYPE_R8:
r64 = *(gdouble *) va;
break;
case MONO_TYPE_CHAR:
u64 = *(guint16 *) va;
break;
case MONO_TYPE_BOOLEAN:
/* Boolean is only compatible with itself. */
switch (et) {
case MONO_TYPE_CHAR:
case MONO_TYPE_U1:
case MONO_TYPE_U2:
case MONO_TYPE_U4:
case MONO_TYPE_U8:
case MONO_TYPE_I1:
case MONO_TYPE_I2:
case MONO_TYPE_I4:
case MONO_TYPE_I8:
case MONO_TYPE_R4:
case MONO_TYPE_R8:
NO_WIDENING_CONVERSION;
break;
default:
INVALID_CAST;
}
break;
default:
break;
}
/* If we can't do a direct copy, let's try a widening conversion. */
if (is_ok (error)) {
switch (et) {
case MONO_TYPE_CHAR:
ASSIGN_UNSIGNED (guint16);
break;
case MONO_TYPE_U1:
ASSIGN_UNSIGNED (guint8);
break;
case MONO_TYPE_U2:
ASSIGN_UNSIGNED (guint16);
break;
case MONO_TYPE_U4:
ASSIGN_UNSIGNED (guint32);
break;
case MONO_TYPE_U8:
ASSIGN_UNSIGNED (guint64);
break;
case MONO_TYPE_I1:
ASSIGN_SIGNED (gint8);
break;
case MONO_TYPE_I2:
ASSIGN_SIGNED (gint16);
break;
case MONO_TYPE_I4:
ASSIGN_SIGNED (gint32);
break;
case MONO_TYPE_I8:
ASSIGN_SIGNED (gint64);
break;
case MONO_TYPE_R4:
ASSIGN_REAL (gfloat);
break;
case MONO_TYPE_R8:
ASSIGN_REAL (gdouble);
break;
default:
INVALID_CAST;
}
}
MONO_EXIT_NO_SAFEPOINTS;
#undef INVALID_CAST
#undef NO_WIDENING_CONVERSION
#undef CHECK_WIDENING_CONVERSION
#undef ASSIGN_UNSIGNED
#undef ASSIGN_SIGNED
#undef ASSIGN_REAL
leave:
return;
}
void
ves_icall_System_Array_InternalCreate (MonoArray *volatile* result, MonoType* type, gint32 rank, gint32* pLengths, gint32* pLowerBounds)
{
ERROR_DECL (error);
MonoClass* klass = mono_class_from_mono_type_internal (type);
if (!mono_class_init_checked (klass, error))
goto exit;
if (m_class_get_byval_arg (m_class_get_element_class (klass))->type == MONO_TYPE_VOID) {
mono_error_set_not_supported (error, "Arrays of System.Void are not supported.");
goto exit;
}
if (m_type_is_byref (type) || m_class_is_byreflike (klass)) {
mono_error_set_not_supported (error, NULL);
goto exit;
}
MonoGenericClass *gklass;
gklass = mono_class_try_get_generic_class (klass);
if (is_generic_parameter (type) || mono_class_is_gtd (klass) || (gklass && gklass->context.class_inst->is_open)) {
mono_error_set_not_supported (error, NULL);
goto exit;
}
/* vectors are not the same as one dimensional arrays with non-zero bounds */
gboolean bounded;
bounded = pLowerBounds != NULL && rank == 1 && pLowerBounds [0] != 0;
MonoClass* aklass;
aklass = mono_class_create_bounded_array (klass, rank, bounded);
uintptr_t aklass_rank;
aklass_rank = m_class_get_rank (aklass);
uintptr_t* sizes;
sizes = g_newa (uintptr_t, aklass_rank * 2);
intptr_t* lower_bounds;
lower_bounds = (intptr_t*)(sizes + aklass_rank);
// Copy lengths and lower_bounds from gint32 to [u]intptr_t.
for (uintptr_t i = 0; i < aklass_rank; ++i) {
if (pLowerBounds != NULL) {
lower_bounds [i] = pLowerBounds [i];
if ((gint64) pLowerBounds [i] + (gint64) pLengths [i] > G_MAXINT32) {
mono_error_set_argument_out_of_range (error, NULL, "Length + bound must not exceed Int32.MaxValue.");
goto exit;
}
} else {
lower_bounds [i] = 0;
}
sizes [i] = pLengths [i];
}
*result = mono_array_new_full_checked (aklass, sizes, lower_bounds, error);
exit:
mono_error_set_pending_exception (error);
}
gint32
ves_icall_System_Array_GetCorElementTypeOfElementType (MonoArrayHandle arr, MonoError *error)
{
MonoType *type = mono_type_get_underlying_type (m_class_get_byval_arg (m_class_get_element_class (mono_handle_class (arr))));
return type->type;
}
gint32
ves_icall_System_Array_IsValueOfElementType (MonoArrayHandle arr, MonoObjectHandle obj, MonoError *error)
{
return m_class_get_element_class (mono_handle_class (arr)) == mono_handle_class (obj);
}
static mono_array_size_t
mono_array_get_length (MonoArrayHandle arr, gint32 dimension, MonoError *error)
{
if (dimension < 0 || dimension >= m_class_get_rank (mono_handle_class (arr))) {
mono_error_set_index_out_of_range (error);
return 0;
}
return MONO_HANDLE_GETVAL (arr, bounds) ? MONO_HANDLE_GETVAL (arr, bounds [dimension].length)
: MONO_HANDLE_GETVAL (arr, max_length);
}
gint32
ves_icall_System_Array_GetLength (MonoArrayHandle arr, gint32 dimension, MonoError *error)
{
icallarray_print ("%s arr:%p dimension:%d\n", __func__, MONO_HANDLE_RAW (arr), (int)dimension);
mono_array_size_t const length = mono_array_get_length (arr, dimension, error);
if (length > G_MAXINT32) {
mono_error_set_overflow (error);
return 0;
}
return (gint32)length;
}
gint32
ves_icall_System_Array_GetLowerBound (MonoArrayHandle arr, gint32 dimension, MonoError *error)
{
icallarray_print ("%s arr:%p dimension:%d\n", __func__, MONO_HANDLE_RAW (arr), (int)dimension);
if (dimension < 0 || dimension >= m_class_get_rank (mono_handle_class (arr))) {
mono_error_set_index_out_of_range (error);
return 0;
}
return MONO_HANDLE_GETVAL (arr, bounds) ? MONO_HANDLE_GETVAL (arr, bounds [dimension].lower_bound)
: 0;
}
MonoBoolean
ves_icall_System_Array_FastCopy (MonoArrayHandle source, int source_idx, MonoArrayHandle dest, int dest_idx, int length, MonoError *error)
{
MonoVTable * const src_vtable = MONO_HANDLE_GETVAL (source, obj.vtable);
MonoVTable * const dest_vtable = MONO_HANDLE_GETVAL (dest, obj.vtable);
if (src_vtable->rank != dest_vtable->rank)
return FALSE;
MonoArrayBounds *source_bounds = MONO_HANDLE_GETVAL (source, bounds);
MonoArrayBounds *dest_bounds = MONO_HANDLE_GETVAL (dest, bounds);
for (int i = 0; i < src_vtable->rank; i++) {
if ((source_bounds && source_bounds [i].lower_bound > 0) ||
(dest_bounds && dest_bounds [i].lower_bound > 0))
return FALSE;
}
/* there's no integer overflow since mono_array_length_internal returns an unsigned integer */
if ((dest_idx + length > mono_array_handle_length (dest)) ||
(source_idx + length > mono_array_handle_length (source)))
return FALSE;
MonoClass * const src_class = m_class_get_element_class (src_vtable->klass);
MonoClass * const dest_class = m_class_get_element_class (dest_vtable->klass);
/*
* Handle common cases.
*/
/* Case1: object[] -> valuetype[] (ArrayList::ToArray)
We fallback to managed here since we need to typecheck each boxed valuetype before storing them in the dest array.
*/
if (src_class == mono_defaults.object_class && m_class_is_valuetype (dest_class))
return FALSE;
/* Check if we're copying a char[] <==> (u)short[] */
if (src_class != dest_class) {
if (m_class_is_valuetype (dest_class) || m_class_is_enumtype (dest_class) ||
m_class_is_valuetype (src_class) || m_class_is_valuetype (src_class))
return FALSE;
/* It's only safe to copy between arrays if we can ensure the source will always have a subtype of the destination. We bail otherwise. */
if (!mono_class_is_subclass_of_internal (src_class, dest_class, FALSE))
return FALSE;
if (m_class_is_native_pointer (src_class) || m_class_is_native_pointer (dest_class))
return FALSE;
}
if (m_class_is_valuetype (dest_class)) {
gsize const element_size = mono_array_element_size (MONO_HANDLE_GETVAL (source, obj.vtable->klass));
MONO_ENTER_NO_SAFEPOINTS; // gchandle would also work here, is slow, breaks profiler tests.
gconstpointer const source_addr =
mono_array_addr_with_size_fast (MONO_HANDLE_RAW (source), element_size, source_idx);
if (m_class_has_references (dest_class)) {
mono_value_copy_array_handle (dest, dest_idx, source_addr, length);
} else {
gpointer const dest_addr =
mono_array_addr_with_size_fast (MONO_HANDLE_RAW (dest), element_size, dest_idx);
mono_gc_memmove_atomic (dest_addr, source_addr, element_size * length);
}
MONO_EXIT_NO_SAFEPOINTS;
} else {
mono_array_handle_memcpy_refs (dest, dest_idx, source, source_idx, length);
}
return TRUE;
}
void
ves_icall_System_Array_GetGenericValue_icall (MonoArray **arr, guint32 pos, gpointer value)
{
icallarray_print ("%s arr:%p pos:%u value:%p\n", __func__, *arr, pos, value);
MONO_REQ_GC_UNSAFE_MODE; // because of gpointer value
MonoClass * const ac = mono_object_class (*arr);
gsize const esize = mono_array_element_size (ac);
gconstpointer * const ea = (gconstpointer*)((char*)(*arr)->vector + (pos * esize));
mono_gc_memmove_atomic (value, ea, esize);
}
void
ves_icall_System_Array_SetGenericValue_icall (MonoArray **arr, guint32 pos, gpointer value)
{
icallarray_print ("%s arr:%p pos:%u value:%p\n", __func__, *arr, pos, value);
MONO_REQ_GC_UNSAFE_MODE; // because of gpointer value
MonoClass * const ac = mono_object_class (*arr);
MonoClass * const ec = m_class_get_element_class (ac);
gsize const esize = mono_array_element_size (ac);
gpointer * const ea = (gpointer*)((char*)(*arr)->vector + (pos * esize));
if (MONO_TYPE_IS_REFERENCE (m_class_get_byval_arg (ec))) {
g_assert (esize == sizeof (gpointer));
mono_gc_wbarrier_generic_store_internal (ea, *(MonoObject **)value);
} else {
g_assert (m_class_is_inited (ec));
g_assert (esize == mono_class_value_size (ec, NULL));
if (m_class_has_references (ec))
mono_gc_wbarrier_value_copy_internal (ea, value, 1, ec);
else
mono_gc_memmove_atomic (ea, value, esize);
}
}
void
ves_icall_System_Runtime_RuntimeImports_Memmove (guint8 *destination, guint8 *source, size_t byte_count)
{
mono_gc_memmove_atomic (destination, source, byte_count);
}
void
ves_icall_System_Buffer_BulkMoveWithWriteBarrier (guint8 *destination, guint8 *source, size_t len, MonoType *type)
{
if (MONO_TYPE_IS_REFERENCE (type))
mono_gc_wbarrier_arrayref_copy_internal (destination, source, (guint)len);
else
mono_gc_wbarrier_value_copy_internal (destination, source, (guint)len, mono_class_from_mono_type_internal (type));
}
void
ves_icall_System_Runtime_RuntimeImports_ZeroMemory (guint8 *p, size_t byte_length)
{
memset (p, 0, byte_length);
}
gpointer
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetSpanDataFrom (MonoClassField *field_handle, MonoType_ptr targetTypeHandle, gpointer countPtr, MonoError *error)
{
gint32* count = (gint32*)countPtr;
MonoType *field_type = mono_field_get_type_checked (field_handle, error);
if (!field_type) {
mono_error_set_argument (error, "fldHandle", "fldHandle invalid");
return NULL;
}
if (!(field_type->attrs & FIELD_ATTRIBUTE_HAS_FIELD_RVA)) {
mono_error_set_argument_format (error, "field_handle", "Field '%s' doesn't have an RVA", mono_field_get_name (field_handle));
return NULL;
}
MonoType *type = targetTypeHandle;
if (MONO_TYPE_IS_REFERENCE (type) || type->type == MONO_TYPE_VALUETYPE) {
mono_error_set_argument (error, "array", "Cannot initialize array of non-primitive type");
return NULL;
}
int swizzle = 1;
int align;
#if G_BYTE_ORDER != G_LITTLE_ENDIAN
swizzle = mono_type_size (type, &align);
#endif
int dummy;
*count = mono_type_size (field_type, &dummy)/mono_type_size (type, &align);
return (gpointer)mono_field_get_rva (field_handle, swizzle);
}
void
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoArrayHandle array, MonoClassField *field_handle, MonoError *error)
{
MonoClass *klass = mono_handle_class (array);
guint32 size = mono_array_element_size (klass);
MonoType *type = mono_type_get_underlying_type (m_class_get_byval_arg (m_class_get_element_class (klass)));
int align;
const char *field_data;
if (MONO_TYPE_IS_REFERENCE (type) || type->type == MONO_TYPE_VALUETYPE) {
mono_error_set_argument (error, "array", "Cannot initialize array of non-primitive type");
return;
}
MonoType *field_type = mono_field_get_type_checked (field_handle, error);
if (!field_type)
return;
if (!(field_type->attrs & FIELD_ATTRIBUTE_HAS_FIELD_RVA)) {
mono_error_set_argument_format (error, "field_handle", "Field '%s' doesn't have an RVA", mono_field_get_name (field_handle));
return;
}
size *= MONO_HANDLE_GETVAL(array, max_length);
field_data = mono_field_get_data (field_handle);
if (size > mono_type_size (field_handle->type, &align)) {
mono_error_set_argument (error, "field_handle", "Field not large enough to fill array");
return;
}
#if G_BYTE_ORDER != G_LITTLE_ENDIAN
#define SWAP(n) { \
guint ## n *data = (guint ## n *) mono_array_addr_internal (MONO_HANDLE_RAW(array), char, 0); \
guint ## n *src = (guint ## n *) field_data; \
int i, \
nEnt = (size / sizeof(guint ## n)); \
\
for (i = 0; i < nEnt; i++) { \
data[i] = read ## n (&src[i]); \
} \
}
/* printf ("Initialize array with elements of %s type\n", klass->element_class->name); */
switch (type->type) {
case MONO_TYPE_CHAR:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
SWAP (16);
break;
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_R4:
SWAP (32);
break;
case MONO_TYPE_I8:
case MONO_TYPE_U8:
case MONO_TYPE_R8:
SWAP (64);
break;
default:
memcpy (mono_array_addr_internal (MONO_HANDLE_RAW(array), char, 0), field_data, size);
break;
}
#else
memcpy (mono_array_addr_internal (MONO_HANDLE_RAW(array), char, 0), field_data, size);
#endif
}
MonoObjectHandle
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue (MonoObjectHandle obj, MonoError *error)
{
if (MONO_HANDLE_IS_NULL (obj) || !m_class_is_valuetype (mono_handle_class (obj)))
return obj;
return mono_object_clone_handle (obj, error);
}
void
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor (MonoType *handle, MonoError *error)
{
MonoClass *klass;
MonoVTable *vtable;
MONO_CHECK_ARG_NULL (handle,);
klass = mono_class_from_mono_type_internal (handle);
MONO_CHECK_ARG (handle, klass,);
if (mono_class_is_gtd (klass))
return;
vtable = mono_class_vtable_checked (klass, error);
return_if_nok (error);
/* This will call the type constructor */
mono_runtime_class_init_full (vtable, error);
}
void
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunModuleConstructor (MonoImage *image, MonoError *error)
{
mono_image_check_for_module_cctor (image);
if (!image->has_module_cctor)
return;
MonoClass *module_klass = mono_class_get_checked (image, MONO_TOKEN_TYPE_DEF | 1, error);
return_if_nok (error);
MonoVTable * vtable = mono_class_vtable_checked (module_klass, error);
return_if_nok (error);
mono_runtime_class_init_full (vtable, error);
}
MonoBoolean
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStack (void)
{
MonoThreadInfo *thread = mono_thread_info_current ();
void *current = &thread;
// Stack upper/lower bound should have been calculated and set as part of register_thread.
// If not, we are optimistic and assume there is enough room.
if (!thread->stack_start_limit || !thread->stack_end)
return TRUE;
// Stack start limit is stack lower bound. Make sure there is enough room left.
void *limit = ((uint8_t *)thread->stack_start_limit) + ALIGN_TO (MONO_STACK_OVERFLOW_GUARD_SIZE + MONO_MIN_EXECUTION_STACK_SIZE, ((gssize)mono_pagesize ()));
if (current < limit)
return FALSE;
if (mono_get_runtime_callbacks ()->is_interpreter_enabled () &&
!mono_get_runtime_callbacks ()->interp_sufficient_stack (MONO_MIN_EXECUTION_STACK_SIZE))
return FALSE;
return TRUE;
}
MonoObjectHandle
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetUninitializedObjectInternal (MonoType *handle, MonoError *error)
{
MonoClass *klass;
MonoVTable *vtable;
g_assert (handle);
klass = mono_class_from_mono_type_internal (handle);
if (m_class_is_string (klass)) {
mono_error_set_argument (error, NULL, NULL);
return NULL_HANDLE;
}
if (mono_class_is_array (klass) || mono_class_is_pointer (klass) || m_type_is_byref (handle)) {
mono_error_set_argument (error, NULL, NULL);
return NULL_HANDLE;
}
if (MONO_TYPE_IS_VOID (handle)) {
mono_error_set_argument (error, NULL, NULL);
return NULL_HANDLE;
}
if (m_class_is_abstract (klass) || m_class_is_interface (klass) || m_class_is_gtd (klass)) {
mono_error_set_member_access (error, NULL);
return NULL_HANDLE;
}
if (m_class_is_byreflike (klass)) {
mono_error_set_not_supported (error, NULL);
return NULL_HANDLE;
}
if (!mono_class_is_before_field_init (klass)) {
vtable = mono_class_vtable_checked (klass, error);
return_val_if_nok (error, NULL_HANDLE);
mono_runtime_class_init_full (vtable, error);
return_val_if_nok (error, NULL_HANDLE);
}
if (m_class_is_nullable (klass))
return mono_object_new_handle (m_class_get_nullable_elem_class (klass), error);
else
return mono_object_new_handle (klass, error);
}
void
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_PrepareMethod (MonoMethod *method, gpointer inst_types, int n_inst_types, MonoError *error)
{
if (method->flags & METHOD_ATTRIBUTE_ABSTRACT) {
mono_error_set_argument (error, NULL, NULL);
return;
}
MonoGenericContainer *container = NULL;
if (method->is_generic)
container = mono_method_get_generic_container (method);
else if (m_class_is_gtd (method->klass))
container = mono_class_get_generic_container (method->klass);
if (container) {
int nparams = container->type_argc + (container->parent ? container->parent->type_argc : 0);
if (nparams != n_inst_types) {
mono_error_set_argument (error, NULL, NULL);
return;
}
}
// FIXME: Implement
}
MonoObjectHandle
ves_icall_System_Object_MemberwiseClone (MonoObjectHandle this_obj, MonoError *error)
{
return mono_object_clone_handle (this_obj, error);
}
gint32
ves_icall_System_ValueType_InternalGetHashCode (MonoObjectHandle this_obj, MonoArrayHandleOut fields, MonoError *error)
{
MonoClass *klass;
MonoClassField **unhandled = NULL;
int count = 0;
gint32 result = (int)(gsize)mono_defaults.int32_class;
MonoClassField* field;
gpointer iter;
klass = mono_handle_class (this_obj);
if (mono_class_num_fields (klass) == 0)
return result;
/*
* Compute the starting value of the hashcode for fields of primitive
* types, and return the remaining fields in an array to the managed side.
* This way, we can avoid costly reflection operations in managed code.
*/
iter = NULL;
while ((field = mono_class_get_fields_internal (klass, &iter))) {
if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
continue;
if (mono_field_is_deleted (field))
continue;
gpointer addr = (guint8*)MONO_HANDLE_RAW (this_obj) + field->offset;
/* FIXME: Add more types */
switch (field->type->type) {
case MONO_TYPE_I4:
result ^= *(gint32*)addr;
break;
case MONO_TYPE_PTR:
result ^= mono_aligned_addr_hash (*(gpointer*)addr);
break;
case MONO_TYPE_STRING: {
MonoString *s;
s = *(MonoString**)addr;
if (s != NULL)
result ^= mono_string_hash_internal (s);
break;
}
default:
if (!unhandled)
unhandled = g_newa (MonoClassField*, mono_class_num_fields (klass));
unhandled [count ++] = field;
}
}
if (unhandled) {
MonoArrayHandle fields_arr = mono_array_new_handle (mono_defaults.object_class, count, error);
return_val_if_nok (error, 0);
MONO_HANDLE_ASSIGN (fields, fields_arr);
MonoObjectHandle h = MONO_HANDLE_NEW (MonoObject, NULL);
for (int i = 0; i < count; ++i) {
MonoObject *o = mono_field_get_value_object_checked (unhandled [i], MONO_HANDLE_RAW (this_obj), error);
return_val_if_nok (error, 0);
MONO_HANDLE_ASSIGN_RAW (h, o);
mono_array_handle_setref (fields_arr, i, h);
}
} else {
MONO_HANDLE_ASSIGN (fields, NULL_HANDLE);
}
return result;
}
MonoBoolean
ves_icall_System_ValueType_Equals (MonoObjectHandle this_obj, MonoObjectHandle that, MonoArrayHandleOut fields, MonoError *error)
{
MonoClass *klass;
MonoClassField **unhandled = NULL;
MonoClassField* field;
gpointer iter;
int count = 0;
MONO_CHECK_ARG_NULL_HANDLE (that, FALSE);
MONO_HANDLE_ASSIGN (fields, NULL_HANDLE);
if (mono_handle_vtable (this_obj) != mono_handle_vtable (that))
return FALSE;
klass = mono_handle_class (this_obj);
if (m_class_is_enumtype (klass) && mono_class_enum_basetype_internal (klass) && mono_class_enum_basetype_internal (klass)->type == MONO_TYPE_I4)
return *(gint32*)mono_handle_get_data_unsafe (this_obj) == *(gint32*)mono_handle_get_data_unsafe (that);
/*
* Do the comparison for fields of primitive type and return a result if
* possible. Otherwise, return the remaining fields in an array to the
* managed side. This way, we can avoid costly reflection operations in
* managed code.
*/
iter = NULL;
while ((field = mono_class_get_fields_internal (klass, &iter))) {
if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
continue;
if (mono_field_is_deleted (field))
continue;
guint8 *this_field = (guint8 *)MONO_HANDLE_RAW (this_obj) + field->offset;
guint8 *that_field = (guint8 *)MONO_HANDLE_RAW (that) + field->offset;
#define UNALIGNED_COMPARE(type) \
do { \
type left, right; \
memcpy (&left, this_field, sizeof (type)); \
memcpy (&right, that_field, sizeof (type)); \
if (left != right) \
return FALSE; \
} while (0)
/* FIXME: Add more types */
switch (field->type->type) {
case MONO_TYPE_U1:
case MONO_TYPE_I1:
case MONO_TYPE_BOOLEAN:
if (*this_field != *that_field)
return FALSE;
break;
case MONO_TYPE_U2:
case MONO_TYPE_I2:
case MONO_TYPE_CHAR:
#ifdef NO_UNALIGNED_ACCESS
if (G_UNLIKELY ((intptr_t) this_field & 1 || (intptr_t) that_field & 1))
UNALIGNED_COMPARE (gint16);
else
#endif
if (*(gint16 *) this_field != *(gint16 *) that_field)
return FALSE;
break;
case MONO_TYPE_U4:
case MONO_TYPE_I4:
#ifdef NO_UNALIGNED_ACCESS
if (G_UNLIKELY ((intptr_t) this_field & 3 || (intptr_t) that_field & 3))
UNALIGNED_COMPARE (gint32);
else
#endif
if (*(gint32 *) this_field != *(gint32 *) that_field)
return FALSE;
break;
case MONO_TYPE_U8:
case MONO_TYPE_I8:
#ifdef NO_UNALIGNED_ACCESS
if (G_UNLIKELY ((intptr_t) this_field & 7 || (intptr_t) that_field & 7))
UNALIGNED_COMPARE (gint64);
else
#endif
if (*(gint64 *) this_field != *(gint64 *) that_field)
return FALSE;
break;
case MONO_TYPE_R4: {
float d1, d2;
#ifdef NO_UNALIGNED_ACCESS
memcpy (&d1, this_field, sizeof (float));
memcpy (&d2, that_field, sizeof (float));
#else
d1 = *(float *) this_field;
d2 = *(float *) that_field;
#endif
if (d1 != d2 && !(mono_isnan (d1) && mono_isnan (d2)))
return FALSE;
break;
}
case MONO_TYPE_R8: {
double d1, d2;
#ifdef NO_UNALIGNED_ACCESS
memcpy (&d1, this_field, sizeof (double));
memcpy (&d2, that_field, sizeof (double));
#else
d1 = *(double *) this_field;
d2 = *(double *) that_field;
#endif
if (d1 != d2 && !(mono_isnan (d1) && mono_isnan (d2)))
return FALSE;
break;
}
case MONO_TYPE_PTR:
#ifdef NO_UNALIGNED_ACCESS
if (G_UNLIKELY ((intptr_t) this_field & 7 || (intptr_t) that_field & 7))
UNALIGNED_COMPARE (gpointer);
else
#endif
if (*(gpointer *) this_field != *(gpointer *) that_field)
return FALSE;
break;
case MONO_TYPE_STRING: {
MonoString *s1, *s2;
guint32 s1len, s2len;
s1 = *(MonoString**)this_field;
s2 = *(MonoString**)that_field;
if (s1 == s2)
break;
if ((s1 == NULL) || (s2 == NULL))
return FALSE;
s1len = mono_string_length_internal (s1);
s2len = mono_string_length_internal (s2);
if (s1len != s2len)
return FALSE;
if (memcmp (mono_string_chars_internal (s1), mono_string_chars_internal (s2), s1len * sizeof (gunichar2)) != 0)
return FALSE;
break;
}
default:
if (!unhandled)
unhandled = g_newa (MonoClassField*, mono_class_num_fields (klass));
unhandled [count ++] = field;
}
#undef UNALIGNED_COMPARE
if (m_class_is_enumtype (klass))
/* enums only have one non-static field */
break;
}
if (unhandled) {
MonoArrayHandle fields_arr = mono_array_new_handle (mono_defaults.object_class, count * 2, error);
return_val_if_nok (error, 0);
MONO_HANDLE_ASSIGN (fields, fields_arr);
MonoObjectHandle h = MONO_HANDLE_NEW (MonoObject, NULL);
for (int i = 0; i < count; ++i) {
MonoObject *o = mono_field_get_value_object_checked (unhandled [i], MONO_HANDLE_RAW (this_obj), error);
return_val_if_nok (error, FALSE);
MONO_HANDLE_ASSIGN_RAW (h, o);
mono_array_handle_setref (fields_arr, i * 2, h);
o = mono_field_get_value_object_checked (unhandled [i], MONO_HANDLE_RAW (that), error);
return_val_if_nok (error, FALSE);
MONO_HANDLE_ASSIGN_RAW (h, o);
mono_array_handle_setref (fields_arr, (i * 2) + 1, h);
}
return FALSE;
} else {
return TRUE;
}
}
static gboolean
get_executing (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
{
MonoMethod **dest = (MonoMethod **)data;
/* skip unmanaged frames */
if (!managed)
return FALSE;
if (!(*dest)) {
if (!strcmp (m_class_get_name_space (m->klass), "System.Reflection"))
return FALSE;
*dest = m;
return TRUE;
}
return FALSE;
}
static gboolean
in_corlib_name_space (MonoClass *klass, const char *name_space)
{
return m_class_get_image (klass) == mono_defaults.corlib &&
!strcmp (m_class_get_name_space (klass), name_space);
}
static gboolean
get_caller_no_reflection (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
{
MonoMethod **dest = (MonoMethod **)data;
/* skip unmanaged frames */
if (!managed)
return FALSE;
if (m->wrapper_type != MONO_WRAPPER_NONE)
return FALSE;
if (m == *dest) {
*dest = NULL;
return FALSE;
}
if (in_corlib_name_space (m->klass, "System.Reflection"))
return FALSE;
if (!(*dest)) {
*dest = m;
return TRUE;
}
return FALSE;
}
static gboolean
get_caller_no_system_or_reflection (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
{
MonoMethod **dest = (MonoMethod **)data;
/* skip unmanaged frames */
if (!managed)
return FALSE;
if (m->wrapper_type != MONO_WRAPPER_NONE)
return FALSE;
if (m == *dest) {
*dest = NULL;
return FALSE;
}
if (in_corlib_name_space (m->klass, "System.Reflection") || in_corlib_name_space (m->klass, "System"))
return FALSE;
if (!(*dest)) {
*dest = m;
return TRUE;
}
return FALSE;
}
/**
* mono_runtime_get_caller_no_system_or_reflection:
*
* Walk the stack of the current thread and find the first managed method that
* is not in the mscorlib System or System.Reflection namespace. This skips
* unmanaged callers and wrapper methods.
*
* \returns a pointer to the \c MonoMethod or NULL if we walked past all the
* callers.
*/
MonoMethod*
mono_runtime_get_caller_no_system_or_reflection (void)
{
MonoMethod *dest = NULL;
mono_stack_walk_no_il (get_caller_no_system_or_reflection, &dest);
return dest;
}
/*
* mono_runtime_get_caller_from_stack_mark:
*
* Walk the stack and return the assembly of the method referenced
* by the stack mark STACK_MARK.
*/
MonoAssembly*
mono_runtime_get_caller_from_stack_mark (MonoStackCrawlMark *stack_mark)
{
// FIXME: Use the stack mark
MonoMethod *dest = NULL;
mono_stack_walk_no_il (get_caller_no_system_or_reflection, &dest);
if (dest)
return m_class_get_image (dest->klass)->assembly;
else
return NULL;
}
static MonoReflectionType*
type_from_parsed_name (MonoTypeNameParse *info, MonoStackCrawlMark *stack_mark, MonoBoolean ignoreCase, MonoAssembly **caller_assembly, MonoError *error)
{
MonoMethod *m;
MonoType *type = NULL;
MonoAssembly *assembly = NULL;
gboolean type_resolve = FALSE;
MonoImage *rootimage = NULL;
MonoAssemblyLoadContext *alc = mono_alc_get_ambient ();
/*
* We must compute the calling assembly as type loading must happen under a metadata context.
* For example. The main assembly is a.exe and Type.GetType is called from dir/b.dll. Without
* the metadata context (basedir currently) set to dir/b.dll we won't be able to load a dir/c.dll.
*/
m = mono_method_get_last_managed ();
if (m && m_class_get_image (m->klass) != mono_defaults.corlib) {
/* Happens with inlining */
assembly = m_class_get_image (m->klass)->assembly;
} else {
assembly = mono_runtime_get_caller_from_stack_mark (stack_mark);
}
if (assembly) {
type_resolve = TRUE;
rootimage = assembly->image;
} else {
// FIXME: once wasm can use stack marks, consider turning all this into an assert
g_warning (G_STRLOC);
}
*caller_assembly = assembly;
if (info->assembly.name) {
MonoAssemblyByNameRequest req;
mono_assembly_request_prepare_byname (&req, alc);
req.requesting_assembly = assembly;
req.basedir = assembly ? assembly->basedir : NULL;
assembly = mono_assembly_request_byname (&info->assembly, &req, NULL);
}
if (assembly) {
/* When loading from the current assembly, AppDomain.TypeResolve will not be called yet */
type = mono_reflection_get_type_checked (alc, rootimage, assembly->image, info, ignoreCase, TRUE, &type_resolve, error);
goto_if_nok (error, fail);
}
// XXXX - aleksey -
// Say we're looking for System.Generic.Dict<int, Local>
// we FAIL the get type above, because S.G.Dict isn't in assembly->image. So we drop down here.
// but then we FAIL AGAIN because now we pass null as the image and the rootimage and everything
// is messed up when we go to construct the Local as the type arg...
//
// By contrast, if we started with Mine<System.Generic.Dict<int, Local>> we'd go in with assembly->image
// as the root and then even the detour into generics would still not cause issues when we went to load Local.
if (!info->assembly.name && !type) {
/* try mscorlib */
type = mono_reflection_get_type_checked (alc, rootimage, NULL, info, ignoreCase, TRUE, &type_resolve, error);
goto_if_nok (error, fail);
}
if (assembly && !type && type_resolve) {
type_resolve = FALSE; /* This will invoke TypeResolve if not done in the first 'if' */
type = mono_reflection_get_type_checked (alc, rootimage, assembly->image, info, ignoreCase, TRUE, &type_resolve, error);
goto_if_nok (error, fail);
}
if (!type)
goto fail;
return mono_type_get_object_checked (type, error);
fail:
return NULL;
}
void
ves_icall_System_RuntimeTypeHandle_internal_from_name (char *name,
MonoStackCrawlMark *stack_mark,
MonoObjectHandleOnStack res,
MonoBoolean throwOnError,
MonoBoolean ignoreCase,
MonoError *error)
{
MonoTypeNameParse info;
gboolean free_info = FALSE;
MonoAssembly *caller_assembly;
free_info = TRUE;
if (!mono_reflection_parse_type_checked (name, &info, error))
goto leave;
/* mono_reflection_parse_type() mangles the string */
HANDLE_ON_STACK_SET (res, type_from_parsed_name (&info, (MonoStackCrawlMark*)stack_mark, ignoreCase, &caller_assembly, error));
goto_if_nok (error, leave);
if (!(*res)) {
if (throwOnError) {
char *tname = info.name_space ? g_strdup_printf ("%s.%s", info.name_space, info.name) : g_strdup (info.name);
char *aname;
if (info.assembly.name)
aname = mono_stringify_assembly_name (&info.assembly);
else if (caller_assembly)
aname = mono_stringify_assembly_name (mono_assembly_get_name_internal (caller_assembly));
else
aname = g_strdup ("");
mono_error_set_type_load_name (error, tname, aname, "");
}
goto leave;
}
leave:
if (free_info)
mono_reflection_free_type_info (&info);
if (!is_ok (error)) {
if (!throwOnError) {
mono_error_cleanup (error);
error_init (error);
}
}
}
MonoReflectionTypeHandle
ves_icall_System_Type_internal_from_handle (MonoType *handle, MonoError *error)
{
return mono_type_get_object_handle (handle, error);
}
MonoType*
ves_icall_Mono_RuntimeClassHandle_GetTypeFromClass (MonoClass *klass)
{
return m_class_get_byval_arg (klass);
}
void
ves_icall_Mono_RuntimeGPtrArrayHandle_GPtrArrayFree (GPtrArray *ptr_array)
{
g_ptr_array_free (ptr_array, TRUE);
}
void
ves_icall_Mono_SafeStringMarshal_GFree (void *c_str)
{
g_free (c_str);
}
char*
ves_icall_Mono_SafeStringMarshal_StringToUtf8 (MonoString *volatile* s)
{
ERROR_DECL (error);
char *result = mono_string_to_utf8_checked_internal (*s, error);
mono_error_set_pending_exception (error);
return result;
}
/* System.TypeCode */
typedef enum {
TYPECODE_EMPTY,
TYPECODE_OBJECT,
TYPECODE_DBNULL,
TYPECODE_BOOLEAN,
TYPECODE_CHAR,
TYPECODE_SBYTE,
TYPECODE_BYTE,
TYPECODE_INT16,
TYPECODE_UINT16,
TYPECODE_INT32,
TYPECODE_UINT32,
TYPECODE_INT64,
TYPECODE_UINT64,
TYPECODE_SINGLE,
TYPECODE_DOUBLE,
TYPECODE_DECIMAL,
TYPECODE_DATETIME,
TYPECODE_STRING = 18
} TypeCode;
MonoBoolean
ves_icall_RuntimeTypeHandle_type_is_assignable_from (MonoQCallTypeHandle type_handle, MonoQCallTypeHandle c_handle, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
MonoType *ctype = c_handle.type;
MonoClass *klassc = mono_class_from_mono_type_internal (ctype);
if (m_type_is_byref (type) ^ m_type_is_byref (ctype))
return FALSE;
if (m_type_is_byref (type)) {
return mono_byref_type_is_assignable_from (type, ctype, FALSE);
}
gboolean result;
mono_class_is_assignable_from_checked (klass, klassc, &result, error);
return result;
}
MonoBoolean
ves_icall_RuntimeTypeHandle_is_subclass_of (MonoQCallTypeHandle child_handle, MonoQCallTypeHandle base_handle, MonoError *error)
{
MonoType *childType = child_handle.type;
MonoType *baseType = base_handle.type;
mono_bool result = FALSE;
MonoClass *childClass;
MonoClass *baseClass;
childClass = mono_class_from_mono_type_internal (childType);
baseClass = mono_class_from_mono_type_internal (baseType);
if (G_UNLIKELY (m_type_is_byref (childType)))
return !m_type_is_byref (baseType) && baseClass == mono_defaults.object_class;
if (G_UNLIKELY (m_type_is_byref (baseType)))
return FALSE;
if (childType == baseType)
/* .NET IsSubclassOf is not reflexive */
return FALSE;
if (G_UNLIKELY (is_generic_parameter (childType))) {
/* slow path: walk the type hierarchy looking at base types
* until we see baseType. If the current type is not a gparam,
* break out of the loop and use is_subclass_of.
*/
MonoClass *c = mono_generic_param_get_base_type (childClass);
result = FALSE;
while (c != NULL) {
if (c == baseClass)
return TRUE;
if (!is_generic_parameter (m_class_get_byval_arg (c)))
return mono_class_is_subclass_of_internal (c, baseClass, FALSE);
else
c = mono_generic_param_get_base_type (c);
}
return result;
} else {
return mono_class_is_subclass_of_internal (childClass, baseClass, FALSE);
}
}
guint32
ves_icall_RuntimeTypeHandle_IsInstanceOfType (MonoQCallTypeHandle type_handle, MonoObjectHandle obj, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_val_if_nok (error, FALSE);
MonoObjectHandle inst = mono_object_handle_isinst (obj, klass, error);
return_val_if_nok (error, FALSE);
return !MONO_HANDLE_IS_NULL (inst);
}
guint32
ves_icall_RuntimeTypeHandle_GetAttributes (MonoQCallTypeHandle type_handle)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type) || type->type == MONO_TYPE_PTR || type->type == MONO_TYPE_FNPTR)
return TYPE_ATTRIBUTE_PUBLIC;
MonoClass *klass = mono_class_from_mono_type_internal (type);
return mono_class_get_flags (klass);
}
guint32
ves_icall_RuntimeTypeHandle_GetMetadataToken (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *mc = mono_class_from_mono_type_internal (type);
if (!mono_class_init_internal (mc)) {
mono_error_set_for_class_failure (error, mc);
return 0;
}
return m_class_get_type_token (mc);
}
MonoReflectionMarshalAsAttributeHandle
ves_icall_System_Reflection_FieldInfo_get_marshal_info (MonoReflectionFieldHandle field_h, MonoError *error)
{
MonoClassField *field = MONO_HANDLE_GETVAL (field_h, field);
MonoClass *klass = m_field_get_parent (field);
MonoGenericClass *gklass = mono_class_try_get_generic_class (klass);
if (mono_class_is_gtd (klass) ||
(gklass && gklass->context.class_inst->is_open))
return MONO_HANDLE_CAST (MonoReflectionMarshalAsAttribute, NULL_HANDLE);
MonoType *ftype = mono_field_get_type_internal (field);
if (ftype && !(ftype->attrs & FIELD_ATTRIBUTE_HAS_FIELD_MARSHAL))
return MONO_HANDLE_CAST (MonoReflectionMarshalAsAttribute, NULL_HANDLE);
MonoMarshalType *info = mono_marshal_load_type_info (klass);
for (int i = 0; i < info->num_fields; ++i) {
if (info->fields [i].field == field) {
if (!info->fields [i].mspec)
return MONO_HANDLE_CAST (MonoReflectionMarshalAsAttribute, NULL_HANDLE);
else {
return mono_reflection_marshal_as_attribute_from_marshal_spec (klass, info->fields [i].mspec, error);
}
}
}
return MONO_HANDLE_CAST (MonoReflectionMarshalAsAttribute, NULL_HANDLE);
}
MonoReflectionFieldHandle
ves_icall_System_Reflection_FieldInfo_internal_from_handle_type (MonoClassField *handle, MonoType *type, MonoError *error)
{
MonoClass *klass;
g_assert (handle);
if (!type) {
klass = m_field_get_parent (handle);
} else {
klass = mono_class_from_mono_type_internal (type);
gboolean found = klass == m_field_get_parent (handle) || mono_class_has_parent (klass, m_field_get_parent (handle));
if (!found)
/* The managed code will throw the exception */
return MONO_HANDLE_CAST (MonoReflectionField, NULL_HANDLE);
}
return mono_field_get_object_handle (klass, handle, error);
}
MonoReflectionEventHandle
ves_icall_System_Reflection_EventInfo_internal_from_handle_type (MonoEvent *handle, MonoType *type, MonoError *error)
{
MonoClass *klass;
g_assert (handle);
if (!type) {
klass = handle->parent;
} else {
klass = mono_class_from_mono_type_internal (type);
gboolean found = klass == handle->parent || mono_class_has_parent (klass, handle->parent);
if (!found)
/* Managed code will throw an exception */
return MONO_HANDLE_CAST (MonoReflectionEvent, NULL_HANDLE);
}
return mono_event_get_object_handle (klass, handle, error);
}
MonoReflectionPropertyHandle
ves_icall_System_Reflection_RuntimePropertyInfo_internal_from_handle_type (MonoProperty *handle, MonoType *type, MonoError *error)
{
MonoClass *klass;
g_assert (handle);
if (!type) {
klass = handle->parent;
} else {
klass = mono_class_from_mono_type_internal (type);
gboolean found = klass == handle->parent || mono_class_has_parent (klass, handle->parent);
if (!found)
/* Managed code will throw an exception */
return MONO_HANDLE_CAST (MonoReflectionProperty, NULL_HANDLE);
}
return mono_property_get_object_handle (klass, handle, error);
}
MonoArrayHandle
ves_icall_System_Reflection_FieldInfo_GetTypeModifiers (MonoReflectionFieldHandle field_h, MonoBoolean optional, MonoError *error)
{
MonoClassField *field = MONO_HANDLE_GETVAL (field_h, field);
MonoType *type = mono_field_get_type_checked (field, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
return type_array_from_modifiers (type, optional, error);
}
int
ves_icall_get_method_attributes (MonoMethod *method)
{
return method->flags;
}
void
ves_icall_get_method_info (MonoMethod *method, MonoMethodInfo *info, MonoError *error)
{
MonoMethodSignature* sig = mono_method_signature_checked (method, error);
return_if_nok (error);
MonoReflectionTypeHandle rt = mono_type_get_object_handle (m_class_get_byval_arg (method->klass), error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, parent, MONO_HANDLE_RAW (rt));
MONO_HANDLE_ASSIGN (rt, mono_type_get_object_handle (sig->ret, error));
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, ret, MONO_HANDLE_RAW (rt));
info->attrs = method->flags;
info->implattrs = method->iflags;
guint32 callconv;
if (sig->call_convention == MONO_CALL_DEFAULT)
callconv = sig->sentinelpos >= 0 ? 2 : 1;
else {
if (sig->call_convention == MONO_CALL_VARARG || sig->sentinelpos >= 0)
callconv = 2;
else
callconv = 1;
}
callconv |= (sig->hasthis << 5) | (sig->explicit_this << 6);
info->callconv = callconv;
}
MonoArrayHandle
ves_icall_System_Reflection_MonoMethodInfo_get_parameter_info (MonoMethod *method, MonoReflectionMethodHandle member, MonoError *error)
{
MonoReflectionTypeHandle reftype = MONO_HANDLE_NEW (MonoReflectionType, NULL);
MONO_HANDLE_GET (reftype, member, reftype);
MonoClass *klass = NULL;
if (!MONO_HANDLE_IS_NULL (reftype))
klass = mono_class_from_mono_type_internal (MONO_HANDLE_GETVAL (reftype, type));
return mono_param_get_objects_internal (method, klass, error);
}
MonoReflectionMarshalAsAttributeHandle
ves_icall_System_MonoMethodInfo_get_retval_marshal (MonoMethod *method, MonoError *error)
{
MonoReflectionMarshalAsAttributeHandle res = MONO_HANDLE_NEW (MonoReflectionMarshalAsAttribute, NULL);
MonoMarshalSpec **mspecs = g_new (MonoMarshalSpec*, mono_method_signature_internal (method)->param_count + 1);
mono_method_get_marshal_info (method, mspecs);
if (mspecs [0]) {
MONO_HANDLE_ASSIGN (res, mono_reflection_marshal_as_attribute_from_marshal_spec (method->klass, mspecs [0], error));
goto_if_nok (error, leave);
}
leave:
for (int i = mono_method_signature_internal (method)->param_count; i >= 0; i--)
if (mspecs [i])
mono_metadata_free_marshal_spec (mspecs [i]);
g_free (mspecs);
return res;
}
gint32
ves_icall_RuntimeFieldInfo_GetFieldOffset (MonoReflectionFieldHandle field, MonoError *error)
{
MonoClassField *class_field = MONO_HANDLE_GETVAL (field, field);
mono_class_setup_fields (m_field_get_parent (class_field));
return class_field->offset - MONO_ABI_SIZEOF (MonoObject);
}
MonoReflectionTypeHandle
ves_icall_RuntimeFieldInfo_GetParentType (MonoReflectionFieldHandle field, MonoBoolean declaring, MonoError *error)
{
MonoClass *parent;
if (declaring) {
MonoClassField *f = MONO_HANDLE_GETVAL (field, field);
parent = m_field_get_parent (f);
} else {
parent = MONO_HANDLE_GETVAL (field, klass);
}
return mono_type_get_object_handle (m_class_get_byval_arg (parent), error);
}
MonoObjectHandle
ves_icall_RuntimeFieldInfo_GetValueInternal (MonoReflectionFieldHandle field_handle, MonoObjectHandle obj_handle, MonoError *error)
{
MonoReflectionField * const field = MONO_HANDLE_RAW (field_handle);
MonoClassField *cf = field->field;
MonoObject * const obj = MONO_HANDLE_RAW (obj_handle);
MonoObject *result;
result = mono_field_get_value_object_checked (cf, obj, error);
return MONO_HANDLE_NEW (MonoObject, result);
}
void
ves_icall_RuntimeFieldInfo_SetValueInternal (MonoReflectionFieldHandle field, MonoObjectHandle obj, MonoObjectHandle value, MonoError *error)
{
MonoClassField *cf = MONO_HANDLE_GETVAL (field, field);
MonoType *type = mono_field_get_type_checked (cf, error);
return_if_nok (error);
gboolean isref = FALSE;
MonoGCHandle value_gchandle = 0;
gchar *v = NULL;
if (!m_type_is_byref (type)) {
switch (type->type) {
case MONO_TYPE_U1:
case MONO_TYPE_I1:
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_U2:
case MONO_TYPE_I2:
case MONO_TYPE_CHAR:
case MONO_TYPE_U:
case MONO_TYPE_I:
case MONO_TYPE_U4:
case MONO_TYPE_I4:
case MONO_TYPE_R4:
case MONO_TYPE_U8:
case MONO_TYPE_I8:
case MONO_TYPE_R8:
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_PTR:
isref = FALSE;
if (!MONO_HANDLE_IS_NULL (value)) {
if (m_class_is_valuetype (mono_handle_class (value)))
v = (char*)mono_object_handle_pin_unbox (value, &value_gchandle);
else {
char* n = g_strdup_printf ("Object of type '%s' cannot be converted to type '%s'.", m_class_get_name (mono_handle_class (value)), m_class_get_name (mono_class_from_mono_type_internal (type)));
mono_error_set_argument (error, cf->name, n);
g_free (n);
return;
}
}
break;
case MONO_TYPE_STRING:
case MONO_TYPE_OBJECT:
case MONO_TYPE_CLASS:
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY:
/* Do nothing */
isref = TRUE;
break;
case MONO_TYPE_GENERICINST: {
MonoGenericClass *gclass = type->data.generic_class;
g_assert (!gclass->context.class_inst->is_open);
if (mono_class_is_nullable (mono_class_from_mono_type_internal (type))) {
MonoClass *nklass = mono_class_from_mono_type_internal (type);
/*
* Convert the boxed vtype into a Nullable structure.
* This is complicated by the fact that Nullables have
* a variable structure.
*/
MonoObjectHandle nullable = mono_object_new_handle (nklass, error);
return_if_nok (error);
MonoGCHandle nullable_gchandle = 0;
guint8 *nval = (guint8*)mono_object_handle_pin_unbox (nullable, &nullable_gchandle);
mono_nullable_init_from_handle (nval, value, nklass);
isref = FALSE;
value_gchandle = nullable_gchandle;
v = (gchar*)nval;
}
else {
isref = !m_class_is_valuetype (gclass->container_class);
if (!isref && !MONO_HANDLE_IS_NULL (value)) {
v = (char*)mono_object_handle_pin_unbox (value, &value_gchandle);
};
}
break;
}
default:
g_error ("type 0x%x not handled in "
"ves_icall_FieldInfo_SetValueInternal", type->type);
return;
}
}
/* either value is a reference type, or it's a value type and we pinned
* it and v points to the payload. */
g_assert ((isref && v == NULL && value_gchandle == 0) ||
(!isref && v != NULL && value_gchandle != 0) ||
(!isref && v == NULL && value_gchandle == 0));
if (type->attrs & FIELD_ATTRIBUTE_STATIC) {
MonoVTable *vtable = mono_class_vtable_checked (m_field_get_parent (cf), error);
goto_if_nok (error, leave);
if (!vtable->initialized) {
if (!mono_runtime_class_init_full (vtable, error))
goto leave;
}
if (isref)
mono_field_static_set_value_internal (vtable, cf, MONO_HANDLE_RAW (value)); /* FIXME make mono_field_static_set_value work with handles for value */
else
mono_field_static_set_value_internal (vtable, cf, v);
} else {
if (isref)
MONO_HANDLE_SET_FIELD_REF (obj, cf, value);
else
mono_field_set_value_internal (MONO_HANDLE_RAW (obj), cf, v); /* FIXME: make mono_field_set_value take a handle for obj */
}
leave:
if (value_gchandle)
mono_gchandle_free_internal (value_gchandle);
}
static MonoObjectHandle
typed_reference_to_object (MonoTypedRef *tref, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoObjectHandle result;
if (MONO_TYPE_IS_REFERENCE (tref->type)) {
MonoObject** objp = (MonoObject **)tref->value;
result = MONO_HANDLE_NEW (MonoObject, *objp);
} else if (mono_type_is_pointer (tref->type)) {
/* Boxed as UIntPtr */
result = mono_value_box_handle (mono_get_uintptr_class (), tref->value, error);
} else {
result = mono_value_box_handle (tref->klass, tref->value, error);
}
HANDLE_FUNCTION_RETURN_REF (MonoObject, result);
}
MonoObjectHandle
ves_icall_System_RuntimeFieldHandle_GetValueDirect (MonoReflectionFieldHandle field_h, MonoReflectionTypeHandle field_type_h, MonoTypedRef *obj, MonoReflectionTypeHandle context_type_h, MonoError *error)
{
MonoClassField *field = MONO_HANDLE_GETVAL (field_h, field);
MonoClass *klass = mono_class_from_mono_type_internal (field->type);
if (!MONO_TYPE_ISSTRUCT (m_class_get_byval_arg (m_field_get_parent (field)))) {
mono_error_set_not_implemented (error, "");
return MONO_HANDLE_NEW (MonoObject, NULL);
} else if (MONO_TYPE_IS_REFERENCE (field->type)) {
return MONO_HANDLE_NEW (MonoObject, *(MonoObject**)((guint8*)obj->value + field->offset - sizeof (MonoObject)));
} else {
return mono_value_box_handle (klass, (guint8*)obj->value + field->offset - sizeof (MonoObject), error);
}
}
void
ves_icall_System_RuntimeFieldHandle_SetValueDirect (MonoReflectionFieldHandle field_h, MonoReflectionTypeHandle field_type_h, MonoTypedRef *obj, MonoObjectHandle value_h, MonoReflectionTypeHandle context_type_h, MonoError *error)
{
MonoClassField *f = MONO_HANDLE_GETVAL (field_h, field);
g_assert (obj);
mono_class_setup_fields (m_field_get_parent (f));
if (!MONO_TYPE_ISSTRUCT (m_class_get_byval_arg (m_field_get_parent (f)))) {
MonoObjectHandle objHandle = typed_reference_to_object (obj, error);
return_if_nok (error);
ves_icall_RuntimeFieldInfo_SetValueInternal (field_h, objHandle, value_h, error);
} else if (MONO_TYPE_IS_REFERENCE (f->type)) {
mono_copy_value (f->type, (guint8*)obj->value + m_field_get_offset (f) - sizeof (MonoObject), MONO_HANDLE_RAW (value_h), FALSE);
} else {
MonoGCHandle gchandle = NULL;
g_assert (MONO_HANDLE_RAW (value_h));
mono_copy_value (f->type, (guint8*)obj->value + m_field_get_offset (f) - sizeof (MonoObject), mono_object_handle_pin_unbox (value_h, &gchandle), FALSE);
mono_gchandle_free_internal (gchandle);
}
}
MonoObjectHandle
ves_icall_RuntimeFieldInfo_GetRawConstantValue (MonoReflectionFieldHandle rfield, MonoError* error)
{
MonoObjectHandle o_handle = NULL_HANDLE_INIT;
MonoObject *o = NULL;
MonoClassField *field = MONO_HANDLE_GETVAL (rfield, field);
MonoClass *klass;
gchar *v;
MonoTypeEnum def_type;
const char *def_value;
MonoType *t;
MonoStringHandle string_handle = MONO_HANDLE_NEW (MonoString, NULL); // FIXME? Not always needed.
mono_class_init_internal (m_field_get_parent (field));
t = mono_field_get_type_checked (field, error);
goto_if_nok (error, return_null);
if (!(t->attrs & FIELD_ATTRIBUTE_HAS_DEFAULT))
goto invalid_operation;
if (image_is_dynamic (m_class_get_image (m_field_get_parent (field)))) {
MonoClass *klass = m_field_get_parent (field);
int fidx = field - m_class_get_fields (klass);
MonoFieldDefaultValue *def_values = mono_class_get_field_def_values (klass);
g_assert (def_values);
def_type = def_values [fidx].def_type;
def_value = def_values [fidx].data;
if (def_type == MONO_TYPE_END)
goto invalid_operation;
} else {
def_value = mono_class_get_field_default_value (field, &def_type);
/* FIXME, maybe we should try to raise TLE if field->parent is broken */
if (!def_value)
goto invalid_operation;
}
/*FIXME unify this with reflection.c:mono_get_object_from_blob*/
switch (def_type) {
case MONO_TYPE_U1:
case MONO_TYPE_I1:
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_U2:
case MONO_TYPE_I2:
case MONO_TYPE_CHAR:
case MONO_TYPE_U:
case MONO_TYPE_I:
case MONO_TYPE_U4:
case MONO_TYPE_I4:
case MONO_TYPE_R4:
case MONO_TYPE_U8:
case MONO_TYPE_I8:
case MONO_TYPE_R8: {
MonoType *t;
/* boxed value type */
t = g_new0 (MonoType, 1);
t->type = def_type;
klass = mono_class_from_mono_type_internal (t);
g_free (t);
o = mono_object_new_checked (klass, error);
goto_if_nok (error, return_null);
o_handle = MONO_HANDLE_NEW (MonoObject, o);
v = ((gchar *) o) + sizeof (MonoObject);
(void)mono_get_constant_value_from_blob (def_type, def_value, v, string_handle, error);
goto_if_nok (error, return_null);
break;
}
case MONO_TYPE_STRING:
case MONO_TYPE_CLASS:
(void)mono_get_constant_value_from_blob (def_type, def_value, &o, string_handle, error);
goto_if_nok (error, return_null);
o_handle = MONO_HANDLE_NEW (MonoObject, o);
break;
default:
g_assert_not_reached ();
}
goto exit;
invalid_operation:
mono_error_set_invalid_operation (error, NULL);
// fall through
return_null:
o_handle = NULL_HANDLE;
// fall through
exit:
return o_handle;
}
MonoReflectionTypeHandle
ves_icall_RuntimeFieldInfo_ResolveType (MonoReflectionFieldHandle ref_field, MonoError *error)
{
MonoClassField *field = MONO_HANDLE_GETVAL (ref_field, field);
MonoType *type = mono_field_get_type_checked (field, error);
return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE));
return mono_type_get_object_handle (type, error);
}
void
ves_icall_RuntimePropertyInfo_get_property_info (MonoReflectionPropertyHandle property, MonoPropertyInfo *info, PInfo req_info, MonoError *error)
{
const MonoProperty *pproperty = MONO_HANDLE_GETVAL (property, property);
if ((req_info & PInfo_ReflectedType) != 0) {
MonoClass *klass = MONO_HANDLE_GETVAL (property, klass);
MonoReflectionTypeHandle rt = mono_type_get_object_handle (m_class_get_byval_arg (klass), error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, parent, MONO_HANDLE_RAW (rt));
}
if ((req_info & PInfo_DeclaringType) != 0) {
MonoReflectionTypeHandle rt = mono_type_get_object_handle (m_class_get_byval_arg (pproperty->parent), error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, declaring_type, MONO_HANDLE_RAW (rt));
}
if ((req_info & PInfo_Name) != 0) {
MonoStringHandle name = mono_string_new_handle (pproperty->name, error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, name, MONO_HANDLE_RAW (name));
}
if ((req_info & PInfo_Attributes) != 0)
info->attrs = pproperty->attrs;
if ((req_info & PInfo_GetMethod) != 0) {
MonoClass *property_klass = MONO_HANDLE_GETVAL (property, klass);
MonoReflectionMethodHandle rm;
if (pproperty->get &&
(((pproperty->get->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) != METHOD_ATTRIBUTE_PRIVATE) ||
pproperty->get->klass == property_klass)) {
rm = mono_method_get_object_handle (pproperty->get, property_klass, error);
return_if_nok (error);
} else {
rm = MONO_HANDLE_NEW (MonoReflectionMethod, NULL);
}
MONO_STRUCT_SETREF_INTERNAL (info, get, MONO_HANDLE_RAW (rm));
}
if ((req_info & PInfo_SetMethod) != 0) {
MonoClass *property_klass = MONO_HANDLE_GETVAL (property, klass);
MonoReflectionMethodHandle rm;
if (pproperty->set &&
(((pproperty->set->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) != METHOD_ATTRIBUTE_PRIVATE) ||
pproperty->set->klass == property_klass)) {
rm = mono_method_get_object_handle (pproperty->set, property_klass, error);
return_if_nok (error);
} else {
rm = MONO_HANDLE_NEW (MonoReflectionMethod, NULL);
}
MONO_STRUCT_SETREF_INTERNAL (info, set, MONO_HANDLE_RAW (rm));
}
/*
* There may be other methods defined for properties, though, it seems they are not exposed
* in the reflection API
*/
}
static gboolean
add_event_other_methods_to_array (MonoMethod *m, MonoArrayHandle dest, int i, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoReflectionMethodHandle rm = mono_method_get_object_handle (m, NULL, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, i, rm);
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
void
ves_icall_RuntimeEventInfo_get_event_info (MonoReflectionMonoEventHandle ref_event, MonoEventInfo *info, MonoError *error)
{
MonoClass *klass = MONO_HANDLE_GETVAL (ref_event, klass);
MonoEvent *event = MONO_HANDLE_GETVAL (ref_event, event);
MonoReflectionTypeHandle rt = mono_type_get_object_handle (m_class_get_byval_arg (klass), error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, reflected_type, MONO_HANDLE_RAW (rt));
rt = mono_type_get_object_handle (m_class_get_byval_arg (event->parent), error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, declaring_type, MONO_HANDLE_RAW (rt));
MonoStringHandle ev_name = mono_string_new_handle (event->name, error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, name, MONO_HANDLE_RAW (ev_name));
info->attrs = event->attrs;
MonoReflectionMethodHandle rm;
if (event->add) {
rm = mono_method_get_object_handle (event->add, klass, error);
return_if_nok (error);
} else {
rm = MONO_HANDLE_NEW (MonoReflectionMethod, NULL);
}
MONO_STRUCT_SETREF_INTERNAL (info, add_method, MONO_HANDLE_RAW (rm));
if (event->remove) {
rm = mono_method_get_object_handle (event->remove, klass, error);
return_if_nok (error);
} else {
rm = MONO_HANDLE_NEW (MonoReflectionMethod, NULL);
}
MONO_STRUCT_SETREF_INTERNAL (info, remove_method, MONO_HANDLE_RAW (rm));
if (event->raise) {
rm = mono_method_get_object_handle (event->raise, klass, error);
return_if_nok (error);
} else {
rm = MONO_HANDLE_NEW (MonoReflectionMethod, NULL);
}
MONO_STRUCT_SETREF_INTERNAL (info, raise_method, MONO_HANDLE_RAW (rm));
#ifndef MONO_SMALL_CONFIG
if (event->other) {
int i, n = 0;
while (event->other [n])
n++;
MonoArrayHandle info_arr = mono_array_new_handle (mono_defaults.method_info_class, n, error);
return_if_nok (error);
MONO_STRUCT_SETREF_INTERNAL (info, other_methods, MONO_HANDLE_RAW (info_arr));
for (i = 0; i < n; i++)
if (!add_event_other_methods_to_array (event->other [i], info_arr, i, error))
return;
}
#endif
}
static void
collect_interfaces (MonoClass *klass, GHashTable *ifaces, MonoError *error)
{
int i;
MonoClass *ic;
mono_class_setup_interfaces (klass, error);
return_if_nok (error);
int klass_interface_count = m_class_get_interface_count (klass);
MonoClass **klass_interfaces = m_class_get_interfaces (klass);
for (i = 0; i < klass_interface_count; i++) {
ic = klass_interfaces [i];
g_hash_table_insert (ifaces, ic, ic);
collect_interfaces (ic, ifaces, error);
return_if_nok (error);
}
}
typedef struct {
MonoArrayHandle iface_array;
MonoGenericContext *context;
MonoError *error;
int next_idx;
} FillIfaceArrayData;
static void
fill_iface_array (gpointer key, gpointer value, gpointer user_data)
{
HANDLE_FUNCTION_ENTER ();
FillIfaceArrayData *data = (FillIfaceArrayData *)user_data;
MonoClass *ic = (MonoClass *)key;
MonoType *ret = m_class_get_byval_arg (ic), *inflated = NULL;
MonoError *error = data->error;
goto_if_nok (error, leave);
if (data->context && mono_class_is_ginst (ic) && mono_class_get_generic_class (ic)->context.class_inst->is_open) {
inflated = ret = mono_class_inflate_generic_type_checked (ret, data->context, error);
goto_if_nok (error, leave);
}
MonoReflectionTypeHandle rt;
rt = mono_type_get_object_handle (ret, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (data->iface_array, data->next_idx, rt);
data->next_idx++;
if (inflated)
mono_metadata_free_type (inflated);
leave:
HANDLE_FUNCTION_RETURN ();
}
static guint
get_interfaces_hash (gconstpointer v1)
{
MonoClass *k = (MonoClass*)v1;
return m_class_get_type_token (k);
}
void
ves_icall_RuntimeType_GetInterfaces (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
GHashTable *iface_hash = g_hash_table_new (get_interfaces_hash, NULL);
MonoGenericContext *context = NULL;
if (mono_class_is_ginst (klass) && mono_class_get_generic_class (klass)->context.class_inst->is_open) {
context = mono_class_get_context (klass);
klass = mono_class_get_generic_class (klass)->container_class;
}
for (MonoClass *parent = klass; parent; parent = m_class_get_parent (parent)) {
mono_class_setup_interfaces (parent, error);
goto_if_nok (error, fail);
collect_interfaces (parent, iface_hash, error);
goto_if_nok (error, fail);
}
MonoDomain *domain = mono_get_root_domain ();
int len;
len = g_hash_table_size (iface_hash);
if (len == 0) {
g_hash_table_destroy (iface_hash);
if (!domain->empty_types) {
domain->empty_types = mono_array_new_cached (mono_defaults.runtimetype_class, 0, error);
goto_if_nok (error, fail);
}
HANDLE_ON_STACK_SET (res, domain->empty_types);
return;
}
FillIfaceArrayData data;
data.iface_array = MONO_HANDLE_NEW (MonoArray, mono_array_new_cached (mono_defaults.runtimetype_class, len, error));
goto_if_nok (error, fail);
data.context = context;
data.error = error;
data.next_idx = 0;
g_hash_table_foreach (iface_hash, fill_iface_array, &data);
goto_if_nok (error, fail);
g_hash_table_destroy (iface_hash);
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (data.iface_array));
return;
fail:
g_hash_table_destroy (iface_hash);
}
static gboolean
method_is_reabstracted (MonoMethod *method)
{
/* only on interfaces */
/* method is marked "final abstract" */
/* FIXME: we need some other way to detect reabstracted methods. "final" is an incidental detail of the spec. */
return m_method_is_final (method) && m_method_is_abstract (method);
}
static gboolean
method_is_dim (MonoMethod *method)
{
/* only valid on interface methods*/
/* method is marked "virtual" but not "virtual abstract" */
return m_method_is_virtual (method) && !m_method_is_abstract (method);
}
static gboolean
set_interface_map_data_method_object (MonoMethod *method, MonoClass *iclass, int ioffset, MonoClass *klass, MonoArrayHandle targets, MonoArrayHandle methods, int i, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoReflectionMethodHandle member = mono_method_get_object_handle (method, iclass, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (methods, i, member);
MonoMethod* foundMethod = m_class_get_vtable (klass) [i + ioffset];
if (mono_class_has_dim_conflicts (klass) && mono_class_is_interface (foundMethod->klass)) {
GSList* conflicts = mono_class_get_dim_conflicts (klass);
GSList* l;
MonoMethod* decl = method;
if (decl->is_inflated)
decl = ((MonoMethodInflated*)decl)->declaring;
gboolean in_conflict = FALSE;
for (l = conflicts; l; l = l->next) {
if (decl == l->data) {
in_conflict = TRUE;
break;
}
}
if (in_conflict) {
MONO_HANDLE_ARRAY_SETREF (targets, i, NULL_HANDLE);
goto leave;
}
}
/*
* if the iterface method is reabstracted, and either the found implementation method is abstract, or the found
* implementation method is from another DIM (meaning neither klass nor any of its ancestor classes implemented
* the method), then say the target method is null.
*/
if (method_is_reabstracted (method) &&
(m_method_is_abstract (foundMethod) ||
(mono_class_is_interface (foundMethod->klass) && method_is_dim (foundMethod))))
MONO_HANDLE_ARRAY_SETREF (targets, i, NULL_HANDLE);
else if (mono_class_is_interface (foundMethod->klass) && method_is_reabstracted (foundMethod) && !m_class_is_abstract (klass)) {
/* if the method we found is a reabstracted DIM method, but the class isn't abstract, return NULL */
/*
* (C# doesn't seem to allow constructing such types, it requires the whole class to be abstract - in
* which case we are supposed to return the reabstracted interface method. But in IL we can make a
* non-abstract class with reabstracted interface methods - which is supposed to fail with an
* EntryPointNotFoundException at invoke time, but does not prevent the class from loading.)
*/
MONO_HANDLE_ARRAY_SETREF (targets, i, NULL_HANDLE);
} else {
MONO_HANDLE_ASSIGN (member, mono_method_get_object_handle (foundMethod, mono_class_is_interface (foundMethod->klass) ? foundMethod->klass : klass, error));
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (targets, i, member);
}
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
void
ves_icall_RuntimeType_GetInterfaceMapData (MonoQCallTypeHandle type_handle, MonoQCallTypeHandle iface_handle, MonoArrayHandleOut targets, MonoArrayHandleOut methods, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
MonoType *iface = iface_handle.type;
MonoClass *iclass = mono_class_from_mono_type_internal (iface);
mono_class_init_checked (klass, error);
return_if_nok (error);
mono_class_init_checked (iclass, error);
return_if_nok (error);
mono_class_setup_vtable (klass);
gboolean variance_used;
int ioffset = mono_class_interface_offset_with_variance (klass, iclass, &variance_used);
if (ioffset == -1)
return;
MonoMethod* method;
int i = 0;
gpointer iter = NULL;
while ((method = mono_class_get_methods(iclass, &iter))) {
if (method->flags & METHOD_ATTRIBUTE_VIRTUAL)
i++;
}
MonoArrayHandle targets_arr = mono_array_new_handle (mono_defaults.method_info_class, i, error);
return_if_nok (error);
MONO_HANDLE_ASSIGN (targets, targets_arr);
MonoArrayHandle methods_arr = mono_array_new_handle (mono_defaults.method_info_class, i, error);
return_if_nok (error);
MONO_HANDLE_ASSIGN (methods, methods_arr);
i = 0;
iter = NULL;
while ((method = mono_class_get_methods (iclass, &iter))) {
if (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL))
continue;
if (!set_interface_map_data_method_object (method, iclass, ioffset, klass, targets, methods, i, error))
return;
i ++;
}
}
void
ves_icall_RuntimeType_GetPacking (MonoQCallTypeHandle type_handle, guint32 *packing, guint32 *size, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_if_nok (error);
if (image_is_dynamic (m_class_get_image (klass))) {
MonoGCHandle ref_info_handle = mono_class_get_ref_info_handle (klass);
g_assert (ref_info_handle);
MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder*)mono_gchandle_get_target_internal (ref_info_handle);
g_assert (tb);
*packing = tb->packing_size;
*size = tb->class_size;
} else {
mono_metadata_packing_from_typedef (m_class_get_image (klass), m_class_get_type_token (klass), packing, size);
}
}
void
ves_icall_RuntimeTypeHandle_GetElementType (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
if (!m_type_is_byref (type) && type->type == MONO_TYPE_SZARRAY) {
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (type->data.klass), error));
return;
}
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_if_nok (error);
// GetElementType should only return a type for:
// Array Pointer PassedByRef
if (m_type_is_byref (type))
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (klass), error));
else if (m_class_get_element_class (klass) && MONO_CLASS_IS_ARRAY (klass))
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (m_class_get_element_class (klass)), error));
else if (m_class_get_element_class (klass) && type->type == MONO_TYPE_PTR)
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (m_class_get_element_class (klass)), error));
else
HANDLE_ON_STACK_SET (res, NULL);
}
void
ves_icall_RuntimeTypeHandle_GetBaseType (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return;
MonoClass *klass = mono_class_from_mono_type_internal (type);
if (!m_class_get_parent (klass))
return;
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (m_class_get_parent (klass)), error));
}
guint32
ves_icall_RuntimeTypeHandle_GetCorElementType (MonoQCallTypeHandle type_handle)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return MONO_TYPE_BYREF;
else
return (guint32)type->type;
}
MonoBoolean
ves_icall_RuntimeTypeHandle_HasReferences (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass;
klass = mono_class_from_mono_type_internal (type);
mono_class_init_internal (klass);
return m_class_has_references (klass);
}
MonoBoolean
ves_icall_RuntimeTypeHandle_IsByRefLike (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
/* .NET Core says byref types are not IsByRefLike */
if (m_type_is_byref (type))
return FALSE;
MonoClass *klass = mono_class_from_mono_type_internal (type);
return m_class_is_byreflike (klass);
}
MonoBoolean
ves_icall_RuntimeTypeHandle_IsComObject (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_val_if_nok (error, FALSE);
return mono_class_is_com_object (klass);
}
guint32
ves_icall_reflection_get_token (MonoObjectHandle obj, MonoError *error)
{
return mono_reflection_get_token_checked (obj, error);
}
void
ves_icall_RuntimeTypeHandle_GetModule (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *t = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (t);
MonoReflectionModuleHandle module;
module = mono_module_get_object_handle (m_class_get_image (klass), error);
return_if_nok (error);
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (module));
}
void
ves_icall_RuntimeTypeHandle_GetAssembly (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *t = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (t);
MonoReflectionAssemblyHandle assembly;
assembly = mono_assembly_get_object_handle (m_class_get_image (klass)->assembly, error);
return_if_nok (error);
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (assembly));
}
void
ves_icall_RuntimeType_GetDeclaringType (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass;
if (m_type_is_byref (type))
return;
if (type->type == MONO_TYPE_VAR) {
MonoGenericContainer *param = mono_type_get_generic_param_owner (type);
klass = param ? param->owner.klass : NULL;
} else if (type->type == MONO_TYPE_MVAR) {
MonoGenericContainer *param = mono_type_get_generic_param_owner (type);
klass = param ? param->owner.method->klass : NULL;
} else {
klass = m_class_get_nested_in (mono_class_from_mono_type_internal (type));
}
if (!klass)
return;
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (klass), error));
}
void
ves_icall_RuntimeType_GetName (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
// FIXME: this should be escaped in some scenarios with mono_identifier_escape_type_name_chars
// Determining exactly when to do so is fairly difficult, so for now we don't bother to avoid regressions
const char *klass_name = m_class_get_name (klass);
if (m_type_is_byref (type)) {
char *n = g_strdup_printf ("%s&", klass_name);
HANDLE_ON_STACK_SET (res, mono_string_new_checked (n, error));
g_free (n);
} else {
HANDLE_ON_STACK_SET (res, mono_string_new_checked (klass_name, error));
}
}
void
ves_icall_RuntimeType_GetNamespace (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
MonoClass *klass_nested_in;
while ((klass_nested_in = m_class_get_nested_in (klass)))
klass = klass_nested_in;
if (m_class_get_name_space (klass) [0] == '\0')
return;
char *escaped = mono_identifier_escape_type_name_chars (m_class_get_name_space (klass));
HANDLE_ON_STACK_SET (res, mono_string_new_checked (escaped, error));
g_free (escaped);
}
gint32
ves_icall_RuntimeTypeHandle_GetArrayRank (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
if (type->type != MONO_TYPE_ARRAY && type->type != MONO_TYPE_SZARRAY) {
mono_error_set_argument (error, "type", "Type must be an array type");
return 0;
}
MonoClass *klass = mono_class_from_mono_type_internal (type);
return m_class_get_rank (klass);
}
static MonoArrayHandle
create_type_array (MonoBoolean runtimeTypeArray, int count, MonoError *error)
{
return mono_array_new_handle (runtimeTypeArray ? mono_defaults.runtimetype_class : mono_defaults.systemtype_class, count, error);
}
static gboolean
set_type_object_in_array (MonoType *type, MonoArrayHandle dest, int i, MonoError *error)
{
HANDLE_FUNCTION_ENTER();
MonoReflectionTypeHandle rt = mono_type_get_object_handle (type, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, i, rt);
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
void
ves_icall_RuntimeType_GetGenericArgumentsInternal (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res_handle, MonoBoolean runtimeTypeArray, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
MonoArrayHandle res = MONO_HANDLE_NEW (MonoArray, NULL);
if (mono_class_is_gtd (klass)) {
MonoGenericContainer *container = mono_class_get_generic_container (klass);
MONO_HANDLE_ASSIGN (res, create_type_array (runtimeTypeArray, container->type_argc, error));
return_if_nok (error);
for (int i = 0; i < container->type_argc; ++i) {
MonoClass *pklass = mono_class_create_generic_parameter (mono_generic_container_get_param (container, i));
if (!set_type_object_in_array (m_class_get_byval_arg (pklass), res, i, error))
return;
}
} else if (mono_class_is_ginst (klass)) {
MonoGenericInst *inst = mono_class_get_generic_class (klass)->context.class_inst;
MONO_HANDLE_ASSIGN (res, create_type_array (runtimeTypeArray, inst->type_argc, error));
return_if_nok (error);
for (int i = 0; i < inst->type_argc; ++i) {
if (!set_type_object_in_array (inst->type_argv [i], res, i, error))
return;
}
}
HANDLE_ON_STACK_SET(res_handle, MONO_HANDLE_RAW (res));
}
MonoBoolean
ves_icall_RuntimeTypeHandle_IsGenericTypeDefinition (MonoQCallTypeHandle type_handle)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return FALSE;
MonoClass *klass = mono_class_from_mono_type_internal (type);
return mono_class_is_gtd (klass);
}
void
ves_icall_RuntimeTypeHandle_GetGenericTypeDefinition_impl (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return;
MonoClass *klass;
klass = mono_class_from_mono_type_internal (type);
if (mono_class_is_gtd (klass)) {
HANDLE_ON_STACK_SET (res, NULL);
return;
}
if (mono_class_is_ginst (klass)) {
MonoClass *generic_class = mono_class_get_generic_class (klass)->container_class;
MonoGCHandle ref_info_handle = mono_class_get_ref_info_handle (generic_class);
if (m_class_was_typebuilder (generic_class) && ref_info_handle) {
MonoObjectHandle tb = mono_gchandle_get_target_handle (ref_info_handle);
g_assert (!MONO_HANDLE_IS_NULL (tb));
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (tb));
} else {
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (generic_class), error));
}
}
}
void
ves_icall_RuntimeType_MakeGenericType (MonoReflectionTypeHandle reftype, MonoArrayHandle type_array, MonoObjectHandleOnStack res, MonoError *error)
{
g_assert (IS_MONOTYPE_HANDLE (reftype));
MonoType *type = MONO_HANDLE_GETVAL (reftype, type);
mono_class_init_checked (mono_class_from_mono_type_internal (type), error);
return_if_nok (error);
int count = mono_array_handle_length (type_array);
MonoType **types = g_new0 (MonoType *, count);
MonoReflectionTypeHandle t = MONO_HANDLE_NEW (MonoReflectionType, NULL);
for (int i = 0; i < count; i++) {
MONO_HANDLE_ARRAY_GETREF (t, type_array, i);
types [i] = MONO_HANDLE_GETVAL (t, type);
}
MonoType *geninst = mono_reflection_bind_generic_parameters (reftype, count, types, error);
g_free (types);
if (!geninst)
return;
MonoClass *klass = mono_class_from_mono_type_internal (geninst);
/*we might inflate to the GTD*/
if (mono_class_is_ginst (klass) && !mono_verifier_class_is_valid_generic_instantiation (klass)) {
mono_error_set_argument (error, "typeArguments", "Invalid generic arguments");
return;
}
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (geninst, error));
}
MonoBoolean
ves_icall_RuntimeTypeHandle_HasInstantiation (MonoQCallTypeHandle type_handle)
{
MonoClass *klass;
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return FALSE;
klass = mono_class_from_mono_type_internal (type);
return mono_class_is_ginst (klass) || mono_class_is_gtd (klass);
}
gint32
ves_icall_RuntimeType_GetGenericParameterPosition (MonoQCallTypeHandle type_handle)
{
MonoType *type = type_handle.type;
if (is_generic_parameter (type))
return mono_type_get_generic_param_num (type);
return -1;
}
MonoGenericParamInfo *
ves_icall_RuntimeTypeHandle_GetGenericParameterInfo (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
return mono_generic_param_info (type->data.generic_param);
}
MonoReflectionMethodHandle
ves_icall_RuntimeType_GetCorrespondingInflatedMethod (MonoQCallTypeHandle type_handle,
MonoReflectionMethodHandle generic,
MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
MonoMethod *generic_method = MONO_HANDLE_GETVAL (generic, method);
MonoReflectionMethodHandle ret = MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
MonoMethod *method;
gpointer iter = NULL;
while ((method = mono_class_get_methods (klass, &iter))) {
if (method->token == generic_method->token) {
ret = mono_method_get_object_handle (method, klass, error);
return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
}
}
return ret;
}
void
ves_icall_RuntimeType_GetDeclaringMethod (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type) || (type->type != MONO_TYPE_MVAR && type->type != MONO_TYPE_VAR)) {
mono_error_set_invalid_operation (error, "DeclaringMethod can only be used on generic arguments");
return;
}
if (type->type == MONO_TYPE_VAR)
return;
MonoMethod *method;
method = mono_type_get_generic_param_owner (type)->owner.method;
g_assert (method);
HANDLE_ON_STACK_SET (res, mono_method_get_object_checked (method, method->klass, error));
}
void
ves_icall_RuntimeMethodInfo_GetPInvoke (MonoReflectionMethodHandle ref_method, int* flags, MonoStringHandleOut entry_point, MonoStringHandleOut dll_name, MonoError *error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
MonoImage *image = m_class_get_image (method->klass);
MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)method;
MonoTableInfo *tables = image->tables;
MonoTableInfo *im = &tables [MONO_TABLE_IMPLMAP];
MonoTableInfo *mr = &tables [MONO_TABLE_MODULEREF];
guint32 im_cols [MONO_IMPLMAP_SIZE];
guint32 scope_token;
const char *import = NULL;
const char *scope = NULL;
if (image_is_dynamic (image)) {
MonoReflectionMethodAux *method_aux =
(MonoReflectionMethodAux *)g_hash_table_lookup (((MonoDynamicImage*)image)->method_aux_hash, method);
if (method_aux) {
import = method_aux->dllentry;
scope = method_aux->dll;
}
if (!import || !scope) {
mono_error_set_argument (error, "method", "System.Refleciton.Emit method with invalid pinvoke information");
return;
}
}
else {
if (piinfo->implmap_idx) {
mono_metadata_decode_row (im, piinfo->implmap_idx - 1, im_cols, MONO_IMPLMAP_SIZE);
piinfo->piflags = im_cols [MONO_IMPLMAP_FLAGS];
import = mono_metadata_string_heap (image, im_cols [MONO_IMPLMAP_NAME]);
scope_token = mono_metadata_decode_row_col (mr, im_cols [MONO_IMPLMAP_SCOPE] - 1, MONO_MODULEREF_NAME);
scope = mono_metadata_string_heap (image, scope_token);
}
}
*flags = piinfo->piflags;
MONO_HANDLE_ASSIGN (entry_point, mono_string_new_handle (import, error));
return_if_nok (error);
MONO_HANDLE_ASSIGN (dll_name, mono_string_new_handle (scope, error));
}
MonoReflectionMethodHandle
ves_icall_RuntimeMethodInfo_GetGenericMethodDefinition (MonoReflectionMethodHandle ref_method, MonoError *error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
if (method->is_generic)
return ref_method;
if (!method->is_inflated)
return MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
MonoMethodInflated *imethod = (MonoMethodInflated *) method;
MonoMethod *result = imethod->declaring;
/* Not a generic method. */
if (!result->is_generic)
return MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
if (image_is_dynamic (m_class_get_image (method->klass))) {
MonoDynamicImage *image = (MonoDynamicImage*)m_class_get_image (method->klass);
/*
* FIXME: Why is this stuff needed at all ? Why can't the code below work for
* the dynamic case as well ?
*/
mono_image_lock ((MonoImage*)image);
MonoReflectionMethodHandle res = MONO_HANDLE_NEW (MonoReflectionMethod, (MonoReflectionMethod*)mono_g_hash_table_lookup (image->generic_def_objects, imethod));
mono_image_unlock ((MonoImage*)image);
if (!MONO_HANDLE_IS_NULL (res))
return res;
}
if (imethod->context.class_inst) {
MonoClass *klass = ((MonoMethod *) imethod)->klass;
/*Generic methods gets the context of the GTD.*/
if (mono_class_get_context (klass)) {
result = mono_class_inflate_generic_method_full_checked (result, klass, mono_class_get_context (klass), error);
return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
}
}
return mono_method_get_object_handle (result, NULL, error);
}
static GENERATE_TRY_GET_CLASS_WITH_CACHE (stream, "System.IO", "Stream")
static int io_stream_begin_read_slot = -1;
static int io_stream_begin_write_slot = -1;
static int io_stream_end_read_slot = -1;
static int io_stream_end_write_slot = -1;
static gboolean io_stream_slots_set = FALSE;
static void
init_io_stream_slots (void)
{
MonoClass* klass = mono_class_try_get_stream_class ();
mono_class_setup_vtable (klass);
MonoMethod **klass_methods = m_class_get_methods (klass);
if (!klass_methods) {
mono_class_setup_methods (klass);
klass_methods = m_class_get_methods (klass);
}
int method_count = mono_class_get_method_count (klass);
int methods_found = 0;
for (int i = 0; i < method_count; i++) {
// find slots for Begin(End)Read and Begin(End)Write
MonoMethod* m = klass_methods [i];
if (m->slot == -1)
continue;
if (!strcmp (m->name, "BeginRead")) {
methods_found++;
io_stream_begin_read_slot = m->slot;
} else if (!strcmp (m->name, "BeginWrite")) {
methods_found++;
io_stream_begin_write_slot = m->slot;
} else if (!strcmp (m->name, "EndRead")) {
methods_found++;
io_stream_end_read_slot = m->slot;
} else if (!strcmp (m->name, "EndWrite")) {
methods_found++;
io_stream_end_write_slot = m->slot;
}
}
g_assert (methods_found <= 4); // some of them can be linked out
io_stream_slots_set = TRUE;
}
MonoBoolean
ves_icall_System_IO_Stream_HasOverriddenBeginEndRead (MonoObjectHandle stream, MonoError *error)
{
MonoClass* curr_klass = MONO_HANDLE_GET_CLASS (stream);
MonoClass* base_klass = mono_class_try_get_stream_class ();
if (!io_stream_slots_set)
init_io_stream_slots ();
// slots can still be -1 and it means Linker removed the methods from the base class (Stream)
// in this case we can safely assume the methods are not overridden
// otherwise - check vtable
MonoMethod **curr_klass_vtable = m_class_get_vtable (curr_klass);
gboolean begin_read_is_overriden = io_stream_begin_read_slot != -1 && curr_klass_vtable [io_stream_begin_read_slot]->klass != base_klass;
gboolean end_read_is_overriden = io_stream_end_read_slot != -1 && curr_klass_vtable [io_stream_end_read_slot]->klass != base_klass;
// return true if BeginRead or EndRead were overriden
return begin_read_is_overriden || end_read_is_overriden;
}
MonoBoolean
ves_icall_System_IO_Stream_HasOverriddenBeginEndWrite (MonoObjectHandle stream, MonoError *error)
{
MonoClass* curr_klass = MONO_HANDLE_GETVAL (stream, vtable)->klass;
MonoClass* base_klass = mono_class_try_get_stream_class ();
if (!io_stream_slots_set)
init_io_stream_slots ();
// slots can still be -1 and it means Linker removed the methods from the base class (Stream)
// in this case we can safely assume the methods are not overridden
// otherwise - check vtable
MonoMethod **curr_klass_vtable = m_class_get_vtable (curr_klass);
gboolean begin_write_is_overriden = io_stream_begin_write_slot != -1 && curr_klass_vtable [io_stream_begin_write_slot]->klass != base_klass;
gboolean end_write_is_overriden = io_stream_end_write_slot != -1 && curr_klass_vtable [io_stream_end_write_slot]->klass != base_klass;
// return true if BeginWrite or EndWrite were overriden
return begin_write_is_overriden || end_write_is_overriden;
}
MonoBoolean
ves_icall_RuntimeMethodInfo_get_IsGenericMethod (MonoReflectionMethodHandle ref_method, MonoError *erro)
{
MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
return mono_method_signature_internal (method)->generic_param_count != 0;
}
MonoBoolean
ves_icall_RuntimeMethodInfo_get_IsGenericMethodDefinition (MonoReflectionMethodHandle ref_method, MonoError *Error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
return method->is_generic;
}
static gboolean
set_array_generic_argument_handle_inflated (MonoGenericInst *inst, int i, MonoArrayHandle arr, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoReflectionTypeHandle rt = mono_type_get_object_handle (inst->type_argv [i], error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (arr, i, rt);
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
static gboolean
set_array_generic_argument_handle_gparam (MonoGenericContainer *container, int i, MonoArrayHandle arr, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoGenericParam *param = mono_generic_container_get_param (container, i);
MonoClass *pklass = mono_class_create_generic_parameter (param);
MonoReflectionTypeHandle rt = mono_type_get_object_handle (m_class_get_byval_arg (pklass), error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (arr, i, rt);
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
MonoArrayHandle
ves_icall_RuntimeMethodInfo_GetGenericArguments (MonoReflectionMethodHandle ref_method, MonoError *error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (ref_method, method);
if (method->is_inflated) {
MonoGenericInst *inst = mono_method_get_context (method)->method_inst;
if (inst) {
int count = inst->type_argc;
MonoArrayHandle res = mono_array_new_handle (mono_defaults.systemtype_class, count, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
for (int i = 0; i < count; i++) {
if (!set_array_generic_argument_handle_inflated (inst, i, res, error))
break;
}
return_val_if_nok (error, NULL_HANDLE_ARRAY);
return res;
}
}
int count = mono_method_signature_internal (method)->generic_param_count;
MonoArrayHandle res = mono_array_new_handle (mono_defaults.systemtype_class, count, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
MonoGenericContainer *container = mono_method_get_generic_container (method);
for (int i = 0; i < count; i++) {
if (!set_array_generic_argument_handle_gparam (container, i, res, error))
break;
}
return_val_if_nok (error, NULL_HANDLE_ARRAY);
return res;
}
MonoObjectHandle
ves_icall_InternalInvoke (MonoReflectionMethodHandle method_handle, MonoObjectHandle this_arg_handle,
MonoSpanOfObjects *params_span, MonoExceptionHandleOut exception_out, MonoError *error)
{
MonoReflectionMethod* const method = MONO_HANDLE_RAW (method_handle);
MonoObject* const this_arg = MONO_HANDLE_RAW (this_arg_handle);
g_assert (params_span != NULL);
/*
* Invoke from reflection is supposed to always be a virtual call (the API
* is stupid), mono_runtime_invoke_*() calls the provided method, allowing
* greater flexibility.
*/
MonoMethod *m = method->method;
MonoMethodSignature* const sig = mono_method_signature_internal (m);
int pcount = 0;
void *obj = this_arg;
MonoObject *result = NULL;
MonoArray *arr = NULL;
MonoException *exception = NULL;
*MONO_HANDLE_REF (exception_out) = NULL;
if (!(m->flags & METHOD_ATTRIBUTE_STATIC)) {
if (!mono_class_vtable_checked (m->klass, error)) {
mono_error_cleanup (error); /* FIXME does this make sense? */
error_init_reuse (error);
exception = mono_class_get_exception_for_failure (m->klass);
goto return_null;
}
if (this_arg) {
m = mono_object_get_virtual_method_internal (this_arg, m);
/* must pass the pointer to the value for valuetype methods */
if (m_class_is_valuetype (m->klass)) {
obj = mono_object_unbox_internal (this_arg);
// FIXMEcoop? Does obj need to be put into a handle?
}
} else if (strcmp (m->name, ".ctor") && !m->wrapper_type) {
exception = mono_exception_from_name_msg (mono_defaults.corlib, "System.Reflection", "TargetException", "Non-static method requires a target.");
goto return_null;
}
}
/* Array constructor */
if (m_class_get_rank (m->klass) && !strcmp (m->name, ".ctor")) {
int i;
pcount = mono_span_length (params_span);
uintptr_t * const lengths = g_newa (uintptr_t, pcount);
/* Note: the synthetized array .ctors have int32 as argument type */
for (i = 0; i < pcount; ++i)
lengths [i] = *(int32_t*) ((char*)mono_span_get (params_span, MonoObject*, i) + sizeof (MonoObject));
if (m_class_get_rank (m->klass) == 1 && sig->param_count == 2 && m_class_get_rank (m_class_get_element_class (m->klass))) {
/* This is a ctor for jagged arrays. MS creates an array of arrays. */
arr = mono_array_new_full_checked (m->klass, lengths, NULL, error);
goto_if_nok (error, return_null);
MonoArrayHandle subarray_handle = MONO_HANDLE_NEW (MonoArray, NULL);
for (i = 0; i < mono_array_length_internal (arr); ++i) {
MonoArray *subarray = mono_array_new_full_checked (m_class_get_element_class (m->klass), &lengths [1], NULL, error);
goto_if_nok (error, return_null);
MONO_HANDLE_ASSIGN_RAW (subarray_handle, subarray); // FIXME? Overkill?
mono_array_setref_fast (arr, i, subarray);
}
goto exit;
}
if (m_class_get_rank (m->klass) == pcount) {
/* Only lengths provided. */
arr = mono_array_new_full_checked (m->klass, lengths, NULL, error);
goto_if_nok (error, return_null);
goto exit;
} else {
g_assert (pcount == (m_class_get_rank (m->klass) * 2));
/* The arguments are lower-bound-length pairs */
intptr_t * const lower_bounds = (intptr_t *)g_alloca (sizeof (intptr_t) * pcount);
for (i = 0; i < pcount / 2; ++i) {
lower_bounds [i] = *(int32_t*) ((char*)mono_span_get (params_span, MonoObject*, (i * 2)) + sizeof (MonoObject));
lengths [i] = *(int32_t*) ((char*)mono_span_get (params_span, MonoObject*, (i * 2) + 1) + sizeof (MonoObject));
}
arr = mono_array_new_full_checked (m->klass, lengths, lower_bounds, error);
goto_if_nok (error, return_null);
goto exit;
}
}
result = mono_runtime_invoke_span_checked (m, obj, params_span, error);
goto exit;
return_null:
result = NULL;
arr = NULL;
exit:
if (exception) {
MONO_HANDLE_NEW (MonoException, exception); // FIXME? overkill?
mono_gc_wbarrier_generic_store_internal (MONO_HANDLE_REF (exception_out), (MonoObject*)exception);
}
g_assert (!result || !arr); // only one, or neither, should be set
return result ? MONO_HANDLE_NEW (MonoObject, result) : arr ? MONO_HANDLE_NEW (MonoObject, (MonoObject*)arr) : NULL_HANDLE;
}
static guint64
read_enum_value (const char *mem, int type)
{
switch (type) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_U1:
return *(guint8*)mem;
case MONO_TYPE_I1:
return *(gint8*)mem;
case MONO_TYPE_CHAR:
case MONO_TYPE_U2:
return read16 (mem);
case MONO_TYPE_I2:
return (gint16) read16 (mem);
case MONO_TYPE_U4:
case MONO_TYPE_R4:
return read32 (mem);
case MONO_TYPE_I4:
return (gint32) read32 (mem);
case MONO_TYPE_U8:
case MONO_TYPE_I8:
case MONO_TYPE_R8:
return read64 (mem);
case MONO_TYPE_U:
case MONO_TYPE_I:
#if SIZEOF_REGISTER == 8
return read64 (mem);
#else
return read32 (mem);
#endif
default:
g_assert_not_reached ();
}
return 0;
}
static void
write_enum_value (void *mem, int type, guint64 value)
{
switch (type) {
case MONO_TYPE_U1:
case MONO_TYPE_I1:
case MONO_TYPE_BOOLEAN: {
guint8 *p = (guint8*)mem;
*p = value;
break;
}
case MONO_TYPE_U2:
case MONO_TYPE_I2:
case MONO_TYPE_CHAR: {
guint16 *p = (guint16 *)mem;
*p = value;
break;
}
case MONO_TYPE_U4:
case MONO_TYPE_I4:
case MONO_TYPE_R4: {
guint32 *p = (guint32 *)mem;
*p = value;
break;
}
case MONO_TYPE_U8:
case MONO_TYPE_I8:
case MONO_TYPE_R8: {
guint64 *p = (guint64 *)mem;
*p = value;
break;
}
case MONO_TYPE_U:
case MONO_TYPE_I: {
#if SIZEOF_REGISTER == 8
guint64 *p = (guint64 *)mem;
*p = value;
#else
guint32 *p = (guint32 *)mem;
*p = value;
break;
#endif
break;
}
default:
g_assert_not_reached ();
}
return;
}
void
ves_icall_System_Enum_InternalBoxEnum (MonoQCallTypeHandle enum_handle, MonoObjectHandleOnStack res, guint64 value, MonoError *error)
{
MonoClass *enumc;
MonoObjectHandle resultHandle;
MonoType *etype;
enumc = mono_class_from_mono_type_internal (enum_handle.type);
mono_class_init_checked (enumc, error);
return_if_nok (error);
etype = mono_class_enum_basetype_internal (enumc);
resultHandle = mono_object_new_handle (enumc, error);
return_if_nok (error);
write_enum_value (mono_handle_unbox_unsafe (resultHandle), etype->type, value);
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (resultHandle));
}
void
ves_icall_System_Enum_InternalGetUnderlyingType (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *etype;
MonoClass *klass;
klass = mono_class_from_mono_type_internal (type_handle.type);
mono_class_init_checked (klass, error);
return_if_nok (error);
etype = mono_class_enum_basetype_internal (klass);
if (!etype) {
mono_error_set_argument (error, "enumType", "Type provided must be an Enum.");
return;
}
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (etype, error));
}
int
ves_icall_System_Enum_InternalGetCorElementType (MonoQCallTypeHandle type_handle)
{
MonoClass *klass = mono_class_from_mono_type_internal (type_handle.type);
return (int)m_class_get_byval_arg (m_class_get_element_class (klass))->type;
}
static void
get_enum_field (MonoArrayHandle names, MonoArrayHandle values, int base_type, MonoClassField *field, guint* j, guint64 *previous_value, gboolean *sorted, MonoError *error)
{
HANDLE_FUNCTION_ENTER();
guint64 field_value;
const char *p;
MonoTypeEnum def_type;
if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC))
goto leave;
if (strcmp ("value__", mono_field_get_name (field)) == 0)
goto leave;
if (mono_field_is_deleted (field))
goto leave;
MonoStringHandle name;
name = mono_string_new_handle (mono_field_get_name (field), error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (names, *j, name);
p = mono_class_get_field_default_value (field, &def_type);
/* len = */ mono_metadata_decode_blob_size (p, &p);
field_value = read_enum_value (p, base_type);
MONO_HANDLE_ARRAY_SETVAL (values, guint64, *j, field_value);
if (*previous_value > field_value)
*sorted = FALSE;
*previous_value = field_value;
(*j)++;
leave:
HANDLE_FUNCTION_RETURN();
}
MonoBoolean
ves_icall_System_Enum_GetEnumValuesAndNames (MonoQCallTypeHandle type_handle, MonoArrayHandleOut values, MonoArrayHandleOut names, MonoError *error)
{
MonoClass *enumc = mono_class_from_mono_type_internal (type_handle.type);
guint j = 0, nvalues;
gpointer iter;
MonoClassField *field;
int base_type;
guint64 previous_value = 0;
gboolean sorted = TRUE;
mono_class_init_checked (enumc, error);
return_val_if_nok (error, FALSE);
if (!m_class_is_enumtype (enumc)) {
mono_error_set_argument (error, NULL, "Type provided must be an Enum.");
return TRUE;
}
base_type = mono_class_enum_basetype_internal (enumc)->type;
nvalues = mono_class_num_fields (enumc) > 0 ? mono_class_num_fields (enumc) - 1 : 0;
MONO_HANDLE_ASSIGN(names, mono_array_new_handle (mono_defaults.string_class, nvalues, error));
return_val_if_nok (error, FALSE);
MONO_HANDLE_ASSIGN(values, mono_array_new_handle (mono_defaults.uint64_class, nvalues, error));
return_val_if_nok (error, FALSE);
iter = NULL;
while ((field = mono_class_get_fields_internal (enumc, &iter))) {
get_enum_field (names, values, base_type, field, &j, &previous_value, &sorted, error);
if (!is_ok (error))
break;
}
return_val_if_nok (error, FALSE);
return sorted || base_type == MONO_TYPE_R4 || base_type == MONO_TYPE_R8;
}
enum {
BFLAGS_IgnoreCase = 1,
BFLAGS_DeclaredOnly = 2,
BFLAGS_Instance = 4,
BFLAGS_Static = 8,
BFLAGS_Public = 0x10,
BFLAGS_NonPublic = 0x20,
BFLAGS_FlattenHierarchy = 0x40,
BFLAGS_InvokeMethod = 0x100,
BFLAGS_CreateInstance = 0x200,
BFLAGS_GetField = 0x400,
BFLAGS_SetField = 0x800,
BFLAGS_GetProperty = 0x1000,
BFLAGS_SetProperty = 0x2000,
BFLAGS_ExactBinding = 0x10000,
BFLAGS_SuppressChangeType = 0x20000,
BFLAGS_OptionalParamBinding = 0x40000
};
enum {
MLISTTYPE_All = 0,
MLISTTYPE_CaseSensitive = 1,
MLISTTYPE_CaseInsensitive = 2,
MLISTTYPE_HandleToInfo = 3
};
GPtrArray*
ves_icall_RuntimeType_GetFields_native (MonoQCallTypeHandle type_handle, char *utf8_name, guint32 bflags, guint32 mlisttype, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return g_ptr_array_new ();
int (*compare_func) (const char *s1, const char *s2) = NULL;
compare_func = ((bflags & BFLAGS_IgnoreCase) || (mlisttype == MLISTTYPE_CaseInsensitive)) ? mono_utf8_strcasecmp : strcmp;
MonoClass *startklass, *klass;
klass = startklass = mono_class_from_mono_type_internal (type);
GPtrArray *ptr_array = g_ptr_array_sized_new (16);
handle_parent:
if (mono_class_has_failure (klass)) {
mono_error_set_for_class_failure (error, klass);
goto fail;
}
MonoClassField *field;
gpointer iter;
iter = NULL;
while ((field = mono_class_get_fields_lazy (klass, &iter))) {
guint32 flags = mono_field_get_flags (field);
int match = 0;
if (mono_field_is_deleted_with_flags (field, flags))
continue;
if ((flags & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
if (bflags & BFLAGS_Public)
match++;
} else if ((klass == startklass) || (flags & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) != FIELD_ATTRIBUTE_PRIVATE) {
if (bflags & BFLAGS_NonPublic) {
match++;
}
}
if (!match)
continue;
match = 0;
if (flags & FIELD_ATTRIBUTE_STATIC) {
if (bflags & BFLAGS_Static)
if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
match++;
} else {
if (bflags & BFLAGS_Instance)
match++;
}
if (!match)
continue;
if (((mlisttype != MLISTTYPE_All) && (utf8_name != NULL)) && compare_func (mono_field_get_name (field), utf8_name))
continue;
g_ptr_array_add (ptr_array, field);
}
if (!(bflags & BFLAGS_DeclaredOnly) && (klass = m_class_get_parent (klass)))
goto handle_parent;
return ptr_array;
fail:
g_ptr_array_free (ptr_array, TRUE);
return NULL;
}
static gboolean
method_nonpublic (MonoMethod* method, gboolean start_klass)
{
switch (method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) {
case METHOD_ATTRIBUTE_ASSEM:
return TRUE;
case METHOD_ATTRIBUTE_PRIVATE:
return start_klass;
case METHOD_ATTRIBUTE_PUBLIC:
return FALSE;
default:
return TRUE;
}
}
GPtrArray*
mono_class_get_methods_by_name (MonoClass *klass, const char *name, guint32 bflags, guint32 mlisttype, gboolean allow_ctors, MonoError *error)
{
GPtrArray *array;
MonoClass *startklass;
MonoMethod *method;
gpointer iter;
int match, nslots;
/*FIXME, use MonoBitSet*/
guint32 method_slots_default [8];
guint32 *method_slots = NULL;
int (*compare_func) (const char *s1, const char *s2) = NULL;
array = g_ptr_array_new ();
startklass = klass;
compare_func = ((bflags & BFLAGS_IgnoreCase) || (mlisttype == MLISTTYPE_CaseInsensitive)) ? mono_utf8_strcasecmp : strcmp;
/* An optimization for calls made from Delegate:CreateDelegate () */
if (m_class_is_delegate (klass) && klass != mono_defaults.delegate_class && klass != mono_defaults.multicastdelegate_class && name && !strcmp (name, "Invoke") && (bflags == (BFLAGS_Public | BFLAGS_Static | BFLAGS_Instance))) {
method = mono_get_delegate_invoke_internal (klass);
g_assert (method);
g_ptr_array_add (array, method);
return array;
}
mono_class_setup_methods (klass);
mono_class_setup_vtable (klass);
if (mono_class_has_failure (klass))
goto loader_error;
if (is_generic_parameter (m_class_get_byval_arg (klass)))
nslots = mono_class_get_vtable_size (m_class_get_parent (klass));
else
nslots = MONO_CLASS_IS_INTERFACE_INTERNAL (klass) ? mono_class_num_methods (klass) : mono_class_get_vtable_size (klass);
if (nslots >= sizeof (method_slots_default) * 8) {
method_slots = g_new0 (guint32, nslots / 32 + 1);
} else {
method_slots = method_slots_default;
memset (method_slots, 0, sizeof (method_slots_default));
}
handle_parent:
mono_class_setup_methods (klass);
mono_class_setup_vtable (klass);
if (mono_class_has_failure (klass))
goto loader_error;
iter = NULL;
while ((method = mono_class_get_methods (klass, &iter))) {
match = 0;
if (method->slot != -1) {
g_assert (method->slot < nslots);
if (method_slots [method->slot >> 5] & (1 << (method->slot & 0x1f)))
continue;
if (!(method->flags & METHOD_ATTRIBUTE_NEW_SLOT))
method_slots [method->slot >> 5] |= 1 << (method->slot & 0x1f);
}
if (!allow_ctors && method->name [0] == '.' && (strcmp (method->name, ".ctor") == 0 || strcmp (method->name, ".cctor") == 0))
continue;
if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
if (bflags & BFLAGS_Public)
match++;
} else if ((bflags & BFLAGS_NonPublic) && method_nonpublic (method, (klass == startklass))) {
match++;
}
if (!match)
continue;
match = 0;
if (method->flags & METHOD_ATTRIBUTE_STATIC) {
if (bflags & BFLAGS_Static)
if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
match++;
} else {
if (bflags & BFLAGS_Instance)
match++;
}
if (!match)
continue;
if ((mlisttype != MLISTTYPE_All) && (name != NULL)) {
if (compare_func (name, method->name))
continue;
}
match = 0;
g_ptr_array_add (array, method);
}
if (!(bflags & BFLAGS_DeclaredOnly) && (klass = m_class_get_parent (klass)))
goto handle_parent;
if (method_slots != method_slots_default)
g_free (method_slots);
return array;
loader_error:
if (method_slots != method_slots_default)
g_free (method_slots);
g_ptr_array_free (array, TRUE);
g_assert (mono_class_has_failure (klass));
mono_error_set_for_class_failure (error, klass);
return NULL;
}
GPtrArray*
ves_icall_RuntimeType_GetMethodsByName_native (MonoQCallTypeHandle type_handle, const char *mname, guint32 bflags, guint32 mlisttype, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
if (m_type_is_byref (type))
return g_ptr_array_new ();
return mono_class_get_methods_by_name (klass, mname, bflags, mlisttype, FALSE, error);
}
GPtrArray*
ves_icall_RuntimeType_GetConstructors_native (MonoQCallTypeHandle type_handle, guint32 bflags, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type)) {
return g_ptr_array_new ();
}
MonoClass *startklass, *klass;
klass = startklass = mono_class_from_mono_type_internal (type);
mono_class_setup_methods (klass);
if (mono_class_has_failure (klass)) {
mono_error_set_for_class_failure (error, klass);
return NULL;
}
GPtrArray *res_array = g_ptr_array_sized_new (4); /* FIXME, guestimating */
MonoMethod *method;
gpointer iter = NULL;
while ((method = mono_class_get_methods (klass, &iter))) {
int match = 0;
if (strcmp (method->name, ".ctor") && strcmp (method->name, ".cctor"))
continue;
if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
if (bflags & BFLAGS_Public)
match++;
} else {
if (bflags & BFLAGS_NonPublic)
match++;
}
if (!match)
continue;
match = 0;
if (method->flags & METHOD_ATTRIBUTE_STATIC) {
if (bflags & BFLAGS_Static)
if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
match++;
} else {
if (bflags & BFLAGS_Instance)
match++;
}
if (!match)
continue;
g_ptr_array_add (res_array, method);
}
return res_array;
}
static guint
property_hash (gconstpointer data)
{
MonoProperty *prop = (MonoProperty*)data;
return g_str_hash (prop->name);
}
static gboolean
property_accessor_override (MonoMethod *method1, MonoMethod *method2)
{
if (method1->slot != -1 && method1->slot == method2->slot)
return TRUE;
if (mono_class_get_generic_type_definition (method1->klass) == mono_class_get_generic_type_definition (method2->klass)) {
if (method1->is_inflated)
method1 = ((MonoMethodInflated*) method1)->declaring;
if (method2->is_inflated)
method2 = ((MonoMethodInflated*) method2)->declaring;
}
return mono_metadata_signature_equal (mono_method_signature_internal (method1), mono_method_signature_internal (method2));
}
static gboolean
property_equal (MonoProperty *prop1, MonoProperty *prop2)
{
// Properties are hide-by-name-and-signature
if (!g_str_equal (prop1->name, prop2->name))
return FALSE;
/* If we see a property in a generic method, we want to
compare the generic signatures, not the inflated signatures
because we might conflate two properties that were
distinct:
class Foo<T,U> {
public T this[T t] { getter { return t; } } // method 1
public U this[U u] { getter { return u; } } // method 2
}
If we see int Foo<int,int>::Item[int] we need to know if
the indexer came from method 1 or from method 2, and we
shouldn't conflate them. (Bugzilla 36283)
*/
if (prop1->get && prop2->get && !property_accessor_override (prop1->get, prop2->get))
return FALSE;
if (prop1->set && prop2->set && !property_accessor_override (prop1->set, prop2->set))
return FALSE;
return TRUE;
}
static gboolean
property_accessor_nonpublic (MonoMethod* accessor, gboolean start_klass)
{
if (!accessor)
return FALSE;
return method_nonpublic (accessor, start_klass);
}
GPtrArray*
ves_icall_RuntimeType_GetPropertiesByName_native (MonoQCallTypeHandle type_handle, gchar *propname, guint32 bflags, guint32 mlisttype, MonoError *error)
{
// Fetch non-public properties as well because they can hide public properties with the same name in base classes
bflags |= BFLAGS_NonPublic;
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return g_ptr_array_new ();
MonoClass *startklass, *klass;
klass = startklass = mono_class_from_mono_type_internal (type);
int (*compare_func) (const char *s1, const char *s2) = (mlisttype == MLISTTYPE_CaseInsensitive) ? mono_utf8_strcasecmp : strcmp;
GPtrArray *res_array = g_ptr_array_sized_new (8); /*This the average for ASP.NET types*/
GHashTable *properties = g_hash_table_new (property_hash, (GEqualFunc)property_equal);
handle_parent:
mono_class_setup_methods (klass);
mono_class_setup_vtable (klass);
if (mono_class_has_failure (klass)) {
mono_error_set_for_class_failure (error, klass);
goto loader_error;
}
MonoProperty *prop;
gpointer iter;
iter = NULL;
while ((prop = mono_class_get_properties (klass, &iter))) {
int match = 0;
MonoMethod *method = prop->get;
if (!method)
method = prop->set;
guint32 flags = 0;
if (method)
flags = method->flags;
if ((prop->get && ((prop->get->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC)) ||
(prop->set && ((prop->set->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC))) {
if (bflags & BFLAGS_Public)
match++;
} else if (bflags & BFLAGS_NonPublic) {
if (property_accessor_nonpublic(prop->get, startklass == klass) ||
property_accessor_nonpublic(prop->set, startklass == klass)) {
match++;
}
}
if (!match)
continue;
match = 0;
if (flags & METHOD_ATTRIBUTE_STATIC) {
if (bflags & BFLAGS_Static)
if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
match++;
} else {
if (bflags & BFLAGS_Instance)
match++;
}
if (!match)
continue;
match = 0;
if ((mlisttype != MLISTTYPE_All) && (propname != NULL) && compare_func (propname, prop->name))
continue;
if (g_hash_table_lookup (properties, prop))
continue;
g_ptr_array_add (res_array, prop);
g_hash_table_insert (properties, prop, prop);
}
if (!(bflags & BFLAGS_DeclaredOnly) && (klass = m_class_get_parent (klass))) {
// BFLAGS_NonPublic should be excluded for base classes
bflags &= ~BFLAGS_NonPublic;
goto handle_parent;
}
g_hash_table_destroy (properties);
return res_array;
loader_error:
if (properties)
g_hash_table_destroy (properties);
g_ptr_array_free (res_array, TRUE);
return NULL;
}
static guint
event_hash (gconstpointer data)
{
MonoEvent *event = (MonoEvent*)data;
return g_str_hash (event->name);
}
static gboolean
event_equal (MonoEvent *event1, MonoEvent *event2)
{
// Events are hide-by-name
return g_str_equal (event1->name, event2->name);
}
GPtrArray*
ves_icall_RuntimeType_GetEvents_native (MonoQCallTypeHandle type_handle, char *utf8_name, guint32 mlisttype, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return g_ptr_array_new ();
int (*compare_func) (const char *s1, const char *s2) = (mlisttype == MLISTTYPE_CaseInsensitive) ? mono_utf8_strcasecmp : strcmp;
GPtrArray *res_array = g_ptr_array_sized_new (4);
MonoClass *startklass, *klass;
klass = startklass = mono_class_from_mono_type_internal (type);
GHashTable *events = g_hash_table_new (event_hash, (GEqualFunc)event_equal);
handle_parent:
mono_class_setup_methods (klass);
mono_class_setup_vtable (klass);
if (mono_class_has_failure (klass)) {
mono_error_set_for_class_failure (error, klass);
goto failure;
}
MonoEvent *event;
gpointer iter;
iter = NULL;
while ((event = mono_class_get_events (klass, &iter))) {
// Remove inherited privates and inherited
// without add/remove/raise methods
if (klass != startklass)
{
MonoMethod *method = event->add;
if (!method)
method = event->remove;
if (!method)
method = event->raise;
if (!method)
continue;
if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PRIVATE)
continue;
}
if ((mlisttype != MLISTTYPE_All) && (utf8_name != NULL) && compare_func (event->name, utf8_name))
continue;
if (g_hash_table_lookup (events, event))
continue;
g_ptr_array_add (res_array, event);
g_hash_table_insert (events, event, event);
}
if ((klass = m_class_get_parent (klass)))
goto handle_parent;
g_hash_table_destroy (events);
return res_array;
failure:
if (events != NULL)
g_hash_table_destroy (events);
g_ptr_array_free (res_array, TRUE);
return NULL;
}
GPtrArray *
ves_icall_RuntimeType_GetNestedTypes_native (MonoQCallTypeHandle type_handle, char *str, guint32 bflags, guint32 mlisttype, MonoError *error)
{
MonoType *type = type_handle.type;
if (m_type_is_byref (type))
return g_ptr_array_new ();
int (*compare_func) (const char *s1, const char *s2) = ((bflags & BFLAGS_IgnoreCase) || (mlisttype == MLISTTYPE_CaseInsensitive)) ? mono_utf8_strcasecmp : strcmp;
MonoClass *klass = mono_class_from_mono_type_internal (type);
/*
* If a nested type is generic, return its generic type definition.
* Note that this means that the return value is essentially the set
* of nested types of the generic type definition of @klass.
*
* A note in MSDN claims that a generic type definition can have
* nested types that aren't generic. In any case, the container of that
* nested type would be the generic type definition.
*/
if (mono_class_is_ginst (klass))
klass = mono_class_get_generic_class (klass)->container_class;
GPtrArray *res_array = g_ptr_array_new ();
MonoClass *nested;
gpointer iter = NULL;
while ((nested = mono_class_get_nested_types (klass, &iter))) {
int match = 0;
if ((mono_class_get_flags (nested) & TYPE_ATTRIBUTE_VISIBILITY_MASK) == TYPE_ATTRIBUTE_NESTED_PUBLIC) {
if (bflags & BFLAGS_Public)
match++;
} else {
if (bflags & BFLAGS_NonPublic)
match++;
}
if (!match)
continue;
if ((mlisttype != MLISTTYPE_All) && (str != NULL) && compare_func (m_class_get_name (nested), str))
continue;
g_ptr_array_add (res_array, m_class_get_byval_arg (nested));
}
return res_array;
}
static MonoType*
get_type_from_module_builder_module (MonoAssemblyLoadContext *alc, MonoArrayHandle modules, int i, MonoTypeNameParse *info, MonoBoolean ignoreCase, gboolean *type_resolve, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoType *type = NULL;
MonoReflectionModuleBuilderHandle mb = MONO_HANDLE_NEW (MonoReflectionModuleBuilder, NULL);
MONO_HANDLE_ARRAY_GETREF (mb, modules, i);
MonoDynamicImage *dynamic_image = MONO_HANDLE_GETVAL (mb, dynamic_image);
type = mono_reflection_get_type_checked (alc, &dynamic_image->image, &dynamic_image->image, info, ignoreCase, FALSE, type_resolve, error);
HANDLE_FUNCTION_RETURN_VAL (type);
}
static MonoType*
get_type_from_module_builder_loaded_modules (MonoAssemblyLoadContext *alc, MonoArrayHandle loaded_modules, int i, MonoTypeNameParse *info, MonoBoolean ignoreCase, gboolean *type_resolve, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoType *type = NULL;
MonoReflectionModuleHandle mod = MONO_HANDLE_NEW (MonoReflectionModule, NULL);
MONO_HANDLE_ARRAY_GETREF (mod, loaded_modules, i);
MonoImage *image = MONO_HANDLE_GETVAL (mod, image);
type = mono_reflection_get_type_checked (alc, image, image, info, ignoreCase, FALSE, type_resolve, error);
HANDLE_FUNCTION_RETURN_VAL (type);
}
MonoReflectionTypeHandle
ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssemblyHandle assembly_h, MonoReflectionModuleHandle module, MonoStringHandle name, MonoBoolean throwOnError, MonoBoolean ignoreCase, MonoError *error)
{
ERROR_DECL (parse_error);
MonoTypeNameParse info;
gboolean type_resolve;
MonoAssemblyLoadContext *alc = mono_alc_get_ambient ();
/* On MS.NET, this does not fire a TypeResolve event */
type_resolve = TRUE;
char *str = mono_string_handle_to_utf8 (name, error);
goto_if_nok (error, fail);
/*g_print ("requested type %s in %s\n", str, assembly->assembly->aname.name);*/
if (!mono_reflection_parse_type_checked (str, &info, parse_error)) {
g_free (str);
mono_reflection_free_type_info (&info);
mono_error_cleanup (parse_error);
if (throwOnError) {
mono_error_set_argument (error, "typeName@0", "failed to parse the type");
goto fail;
}
/*g_print ("failed parse\n");*/
return MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
}
if (info.assembly.name) {
g_free (str);
mono_reflection_free_type_info (&info);
if (throwOnError) {
mono_error_set_argument (error, NULL, "Type names passed to Assembly.GetType() must not specify an assembly.");
goto fail;
}
return MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
}
MonoType *type;
type = NULL;
if (!MONO_HANDLE_IS_NULL (module)) {
MonoImage *image = MONO_HANDLE_GETVAL (module, image);
if (image) {
type = mono_reflection_get_type_checked (alc, image, image, &info, ignoreCase, FALSE, &type_resolve, error);
if (!is_ok (error)) {
g_free (str);
mono_reflection_free_type_info (&info);
goto fail;
}
}
}
else {
MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_h, assembly);
if (assembly_is_dynamic (assembly)) {
/* Enumerate all modules */
MonoReflectionAssemblyBuilderHandle abuilder = MONO_HANDLE_NEW (MonoReflectionAssemblyBuilder, NULL);
MONO_HANDLE_ASSIGN (abuilder, assembly_h);
int i;
MonoArrayHandle modules = MONO_HANDLE_NEW (MonoArray, NULL);
MONO_HANDLE_GET (modules, abuilder, modules);
if (!MONO_HANDLE_IS_NULL (modules)) {
int n = mono_array_handle_length (modules);
for (i = 0; i < n; ++i) {
type = get_type_from_module_builder_module (alc, modules, i, &info, ignoreCase, &type_resolve, error);
if (!is_ok (error)) {
g_free (str);
mono_reflection_free_type_info (&info);
goto fail;
}
if (type)
break;
}
}
MonoArrayHandle loaded_modules = MONO_HANDLE_NEW (MonoArray, NULL);
MONO_HANDLE_GET (loaded_modules, abuilder, loaded_modules);
if (!type && !MONO_HANDLE_IS_NULL (loaded_modules)) {
int n = mono_array_handle_length (loaded_modules);
for (i = 0; i < n; ++i) {
type = get_type_from_module_builder_loaded_modules (alc, loaded_modules, i, &info, ignoreCase, &type_resolve, error);
if (!is_ok (error)) {
g_free (str);
mono_reflection_free_type_info (&info);
goto fail;
}
if (type)
break;
}
}
}
else {
type = mono_reflection_get_type_checked (alc, assembly->image, assembly->image, &info, ignoreCase, FALSE, &type_resolve, error);
if (!is_ok (error)) {
g_free (str);
mono_reflection_free_type_info (&info);
goto fail;
}
}
}
g_free (str);
mono_reflection_free_type_info (&info);
if (!type) {
if (throwOnError) {
ERROR_DECL (inner_error);
char *type_name = mono_string_handle_to_utf8 (name, inner_error);
mono_error_assert_ok (inner_error);
MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_h, assembly);
char *assmname = mono_stringify_assembly_name (&assembly->aname);
mono_error_set_type_load_name (error, type_name, assmname, "%s", "");
goto fail;
}
return MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
}
if (type->type == MONO_TYPE_CLASS) {
MonoClass *klass = mono_type_get_class_internal (type);
/* need to report exceptions ? */
if (throwOnError && mono_class_has_failure (klass)) {
/* report SecurityException (or others) that occured when loading the assembly */
mono_error_set_for_class_failure (error, klass);
goto fail;
}
}
/* g_print ("got it\n"); */
return mono_type_get_object_handle (type, error);
fail:
g_assert (!is_ok (error));
return MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
}
/* This corresponds to RuntimeAssembly.AssemblyInfoKind */
typedef enum {
ASSEMBLY_INFO_KIND_LOCATION = 1,
ASSEMBLY_INFO_KIND_CODEBASE = 2,
ASSEMBLY_INFO_KIND_FULLNAME = 3,
ASSEMBLY_INFO_KIND_VERSION = 4
} MonoAssemblyInfoKind;
void
ves_icall_System_Reflection_RuntimeAssembly_GetInfo (MonoQCallAssemblyHandle assembly_h, MonoObjectHandleOnStack res, guint32 int_kind, MonoError *error)
{
MonoAssembly *assembly = assembly_h.assembly;
MonoAssemblyInfoKind kind = (MonoAssemblyInfoKind)int_kind;
switch (kind) {
case ASSEMBLY_INFO_KIND_LOCATION: {
const char *image_name = m_image_get_filename (assembly->image);
HANDLE_ON_STACK_SET (res, mono_string_new_checked (image_name != NULL ? image_name : "", error));
break;
}
case ASSEMBLY_INFO_KIND_CODEBASE: {
/* return NULL for bundled assemblies in single-file scenarios */
const char* filename = m_image_get_filename (assembly->image);
if (!filename)
break;
gchar *absolute;
if (g_path_is_absolute (filename))
absolute = g_strdup (filename);
else
absolute = g_build_filename (assembly->basedir, filename, (const char*)NULL);
mono_icall_make_platform_path (absolute);
const gchar *prepend = mono_icall_get_file_path_prefix (absolute);
gchar *uri = g_strconcat (prepend, absolute, (const char*)NULL);
g_free (absolute);
if (uri) {
HANDLE_ON_STACK_SET (res, mono_string_new_checked (uri, error));
g_free (uri);
return_if_nok (error);
}
break;
}
case ASSEMBLY_INFO_KIND_FULLNAME: {
char *name = mono_stringify_assembly_name (&assembly->aname);
HANDLE_ON_STACK_SET (res, mono_string_new_checked (name, error));
g_free (name);
return_if_nok (error);
break;
}
case ASSEMBLY_INFO_KIND_VERSION: {
HANDLE_ON_STACK_SET (res, mono_string_new_checked (assembly->image->version, error));
return_if_nok (error);
break;
}
default:
g_assert_not_reached ();
}
}
void
ves_icall_System_Reflection_RuntimeAssembly_GetEntryPoint (MonoQCallAssemblyHandle assembly_h, MonoObjectHandleOnStack res, MonoError *error)
{
MonoAssembly *assembly = assembly_h.assembly;
MonoMethod *method;
guint32 token = mono_image_get_entry_point (assembly->image);
if (!token)
return;
method = mono_get_method_checked (assembly->image, token, NULL, NULL, error);
return_if_nok (error);
HANDLE_ON_STACK_SET (res, mono_method_get_object_checked (method, NULL, error));
}
void
ves_icall_System_Reflection_Assembly_GetManifestModuleInternal (MonoQCallAssemblyHandle assembly_h, MonoObjectHandleOnStack res, MonoError *error)
{
MonoAssembly *a = assembly_h.assembly;
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (mono_module_get_object_handle (a->image, error)));
}
static gboolean
add_manifest_resource_name_to_array (MonoImage *image, MonoTableInfo *table, int i, MonoArrayHandle dest, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
const char *val = mono_metadata_string_heap (image, mono_metadata_decode_row_col (table, i, MONO_MANIFEST_NAME));
MonoStringHandle str = mono_string_new_handle (val, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, i, str);
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
void
ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceNames (MonoQCallAssemblyHandle assembly_h, MonoObjectHandleOnStack res, MonoError *error)
{
MonoAssembly *assembly = assembly_h.assembly;
MonoTableInfo *table = &assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
/* FIXME: metadata-update */
int rows = table_info_get_rows (table);
MonoArrayHandle result = mono_array_new_handle (mono_defaults.string_class, rows, error);
return_if_nok (error);
for (int i = 0; i < rows; ++i) {
if (!add_manifest_resource_name_to_array (assembly->image, table, i, result, error))
return;
}
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (result));
}
static MonoAssemblyName*
create_referenced_assembly_name (MonoImage *image, int i, MonoError *error)
{
MonoAssemblyName *aname = g_new0 (MonoAssemblyName, 1);
mono_assembly_get_assemblyref_checked (image, i, aname, error);
return_val_if_nok (error, NULL);
aname->hash_alg = ASSEMBLY_HASH_SHA1 /* SHA1 (default) */;
/* name and culture are pointers into the image tables, but we need
* real malloc'd strings (so that we can g_free() them later from
* Mono.RuntimeMarshal.FreeAssemblyName) */
aname->name = g_strdup (aname->name);
aname->culture = g_strdup (aname->culture);
/* Don't need the hash value in managed */
aname->hash_value = NULL;
aname->hash_len = 0;
g_assert (aname->public_key == NULL);
/* note: this function doesn't return the codebase on purpose (i.e. it can
be used under partial trust as path information isn't present). */
return aname;
}
GPtrArray*
ves_icall_System_Reflection_Assembly_InternalGetReferencedAssemblies (MonoReflectionAssemblyHandle assembly_h, MonoError *error)
{
MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_h, assembly);
MonoImage *image = assembly->image;
int count;
/* FIXME: metadata-update */
if (image_is_dynamic (assembly->image)) {
MonoDynamicTable *t = &(((MonoDynamicImage*) image)->tables [MONO_TABLE_ASSEMBLYREF]);
count = t->rows;
}
else {
MonoTableInfo *t = &image->tables [MONO_TABLE_ASSEMBLYREF];
count = table_info_get_rows (t);
}
GPtrArray *result = g_ptr_array_sized_new (count);
for (int i = 0; i < count; i++) {
MonoAssemblyName *aname = create_referenced_assembly_name (image, i, error);
if (!is_ok (error))
break;
g_ptr_array_add (result, aname);
}
return result;
}
/* move this in some file in mono/util/ */
static char *
g_concat_dir_and_file (const char *dir, const char *file)
{
g_return_val_if_fail (dir != NULL, NULL);
g_return_val_if_fail (file != NULL, NULL);
/*
* If the directory name doesn't have a / on the end, we need
* to add one so we get a proper path to the file
*/
if (dir [strlen(dir) - 1] != G_DIR_SEPARATOR)
return g_strconcat (dir, G_DIR_SEPARATOR_S, file, (const char*)NULL);
else
return g_strconcat (dir, file, (const char*)NULL);
}
static MonoReflectionAssemblyHandle
try_resource_resolve_name (MonoReflectionAssemblyHandle assembly_handle, MonoStringHandle name_handle)
{
MonoObjectHandle ret;
ERROR_DECL (error);
HANDLE_FUNCTION_ENTER ();
if (mono_runtime_get_no_exec ())
goto return_null;
MONO_STATIC_POINTER_INIT (MonoMethod, resolve_method)
static gboolean inited;
if (!inited) {
MonoClass *alc_class = mono_class_get_assembly_load_context_class ();
g_assert (alc_class);
resolve_method = mono_class_get_method_from_name_checked (alc_class, "OnResourceResolve", -1, 0, error);
inited = TRUE;
}
mono_error_cleanup (error);
error_init_reuse (error);
MONO_STATIC_POINTER_INIT_END (MonoMethod, resolve_method)
if (!resolve_method)
goto return_null;
gpointer args [2];
args [0] = MONO_HANDLE_RAW (assembly_handle);
args [1] = MONO_HANDLE_RAW (name_handle);
ret = mono_runtime_try_invoke_handle (resolve_method, NULL_HANDLE, args, error);
goto_if_nok (error, return_null);
goto exit;
return_null:
ret = NULL_HANDLE;
exit:
HANDLE_FUNCTION_RETURN_REF (MonoReflectionAssembly, MONO_HANDLE_CAST (MonoReflectionAssembly, ret));
}
void *
ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceInternal (MonoQCallAssemblyHandle assembly_h, MonoStringHandle name, gint32 *size, MonoObjectHandleOnStack ref_module, MonoError *error)
{
MonoAssembly *assembly = assembly_h.assembly;
MonoTableInfo *table = &assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
guint32 i;
guint32 cols [MONO_MANIFEST_SIZE];
guint32 impl, file_idx;
const char *val;
MonoImage *module;
char *n = mono_string_handle_to_utf8 (name, error);
return_val_if_nok (error, NULL);
/* FIXME: metadata update */
int rows = table_info_get_rows (table);
for (i = 0; i < rows; ++i) {
mono_metadata_decode_row (table, i, cols, MONO_MANIFEST_SIZE);
val = mono_metadata_string_heap (assembly->image, cols [MONO_MANIFEST_NAME]);
if (strcmp (val, n) == 0)
break;
}
g_free (n);
if (i == rows)
return NULL;
/* FIXME */
impl = cols [MONO_MANIFEST_IMPLEMENTATION];
if (impl) {
/*
* this code should only be called after obtaining the
* ResourceInfo and handling the other cases.
*/
g_assert ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_FILE);
file_idx = impl >> MONO_IMPLEMENTATION_BITS;
module = mono_image_load_file_for_image_checked (assembly->image, file_idx, error);
if (!is_ok (error) || !module)
return NULL;
} else {
module = assembly->image;
}
MonoReflectionModuleHandle rm = mono_module_get_object_handle (module, error);
return_val_if_nok (error, NULL);
HANDLE_ON_STACK_SET (ref_module, MONO_HANDLE_RAW (rm));
return (void*)mono_image_get_resource (module, cols [MONO_MANIFEST_OFFSET], (guint32*)size);
}
static gboolean
get_manifest_resource_info_internal (MonoAssembly *assembly, MonoStringHandle name, MonoManifestResourceInfoHandle info, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoTableInfo *table = &assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
int i;
guint32 cols [MONO_MANIFEST_SIZE];
guint32 file_cols [MONO_FILE_SIZE];
const char *val;
char *n;
gboolean result = FALSE;
n = mono_string_handle_to_utf8 (name, error);
goto_if_nok (error, leave);
int rows = table_info_get_rows (table);
for (i = 0; i < rows; ++i) {
mono_metadata_decode_row (table, i, cols, MONO_MANIFEST_SIZE);
val = mono_metadata_string_heap (assembly->image, cols [MONO_MANIFEST_NAME]);
if (strcmp (val, n) == 0)
break;
}
g_free (n);
if (i == rows)
goto leave;
if (!cols [MONO_MANIFEST_IMPLEMENTATION]) {
MONO_HANDLE_SETVAL (info, location, guint32, RESOURCE_LOCATION_EMBEDDED | RESOURCE_LOCATION_IN_MANIFEST);
}
else {
switch (cols [MONO_MANIFEST_IMPLEMENTATION] & MONO_IMPLEMENTATION_MASK) {
case MONO_IMPLEMENTATION_FILE:
i = cols [MONO_MANIFEST_IMPLEMENTATION] >> MONO_IMPLEMENTATION_BITS;
table = &assembly->image->tables [MONO_TABLE_FILE];
mono_metadata_decode_row (table, i - 1, file_cols, MONO_FILE_SIZE);
val = mono_metadata_string_heap (assembly->image, file_cols [MONO_FILE_NAME]);
MONO_HANDLE_SET (info, filename, mono_string_new_handle (val, error));
if (file_cols [MONO_FILE_FLAGS] & FILE_CONTAINS_NO_METADATA)
MONO_HANDLE_SETVAL (info, location, guint32, 0);
else
MONO_HANDLE_SETVAL (info, location, guint32, RESOURCE_LOCATION_EMBEDDED);
break;
case MONO_IMPLEMENTATION_ASSEMBLYREF:
i = cols [MONO_MANIFEST_IMPLEMENTATION] >> MONO_IMPLEMENTATION_BITS;
mono_assembly_load_reference (assembly->image, i - 1);
if (assembly->image->references [i - 1] == REFERENCE_MISSING) {
mono_error_set_file_not_found (error, NULL, "Assembly %d referenced from assembly %s not found ", i - 1, assembly->image->name);
goto leave;
}
MonoReflectionAssemblyHandle assm_obj;
assm_obj = mono_assembly_get_object_handle (assembly->image->references [i - 1], error);
goto_if_nok (error, leave);
MONO_HANDLE_SET (info, assembly, assm_obj);
/* Obtain info recursively */
get_manifest_resource_info_internal (MONO_HANDLE_GETVAL (assm_obj, assembly), name, info, error);
goto_if_nok (error, leave);
guint32 location;
location = MONO_HANDLE_GETVAL (info, location);
location |= RESOURCE_LOCATION_ANOTHER_ASSEMBLY;
MONO_HANDLE_SETVAL (info, location, guint32, location);
break;
case MONO_IMPLEMENTATION_EXP_TYPE:
g_assert_not_reached ();
break;
}
}
result = TRUE;
leave:
HANDLE_FUNCTION_RETURN_VAL (result);
}
MonoBoolean
ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceInfoInternal (MonoQCallAssemblyHandle assembly_h, MonoStringHandle name, MonoManifestResourceInfoHandle info_h, MonoError *error)
{
return get_manifest_resource_info_internal (assembly_h.assembly, name, info_h, error);
}
static gboolean
add_module_to_modules_array (MonoArrayHandle dest, int *dest_idx, MonoImage* module, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
if (module) {
MonoReflectionModuleHandle rm = mono_module_get_object_handle (module, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, *dest_idx, rm);
++(*dest_idx);
}
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
static gboolean
add_file_to_modules_array (MonoArrayHandle dest, int dest_idx, MonoImage *image, MonoTableInfo *table, int table_idx, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
guint32 cols [MONO_FILE_SIZE];
mono_metadata_decode_row (table, table_idx, cols, MONO_FILE_SIZE);
if (cols [MONO_FILE_FLAGS] & FILE_CONTAINS_NO_METADATA) {
MonoReflectionModuleHandle rm = mono_module_file_get_object_handle (image, table_idx, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, dest_idx, rm);
} else {
MonoImage *m = mono_image_load_file_for_image_checked (image, table_idx + 1, error);
goto_if_nok (error, leave);
if (!m) {
const char *filename = mono_metadata_string_heap (image, cols [MONO_FILE_NAME]);
mono_error_set_simple_file_not_found (error, filename);
goto leave;
}
MonoReflectionModuleHandle rm = mono_module_get_object_handle (m, error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, dest_idx, rm);
}
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
void
ves_icall_System_Reflection_RuntimeAssembly_GetModulesInternal (MonoQCallAssemblyHandle assembly_h, MonoObjectHandleOnStack res_h, MonoError *error)
{
MonoAssembly *assembly = assembly_h.assembly;
MonoClass *klass;
int i, j, file_count = 0;
MonoImage **modules;
guint32 module_count, real_module_count;
MonoTableInfo *table;
MonoImage *image = assembly->image;
g_assert (image != NULL);
g_assert (!assembly_is_dynamic (assembly));
table = &image->tables [MONO_TABLE_FILE];
file_count = table_info_get_rows (table);
modules = image->modules;
module_count = image->module_count;
real_module_count = 0;
for (i = 0; i < module_count; ++i)
if (modules [i])
real_module_count ++;
klass = mono_class_get_module_class ();
MonoArrayHandle res = mono_array_new_handle (klass, 1 + real_module_count + file_count, error);
return_if_nok (error);
MonoReflectionModuleHandle image_obj = mono_module_get_object_handle (image, error);
return_if_nok (error);
MONO_HANDLE_ARRAY_SETREF (res, 0, image_obj);
j = 1;
for (i = 0; i < module_count; ++i)
if (!add_module_to_modules_array (res, &j, modules[i], error))
return;
for (i = 0; i < file_count; ++i, ++j) {
if (!add_file_to_modules_array (res, j, image, table, i, error))
return;
}
HANDLE_ON_STACK_SET (res_h, MONO_HANDLE_RAW (res));
}
MonoReflectionMethodHandle
ves_icall_GetCurrentMethod (MonoError *error)
{
MonoMethod *m = mono_method_get_last_managed ();
if (!m) {
mono_error_set_not_supported (error, "Stack walks are not supported on this platform.");
return MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
}
while (m->is_inflated)
m = ((MonoMethodInflated*)m)->declaring;
return mono_method_get_object_handle (m, NULL, error);
}
static MonoMethod*
mono_method_get_equivalent_method (MonoMethod *method, MonoClass *klass)
{
int offset = -1, i;
if (method->is_inflated && ((MonoMethodInflated*)method)->context.method_inst) {
ERROR_DECL (error);
MonoMethod *result;
MonoMethodInflated *inflated = (MonoMethodInflated*)method;
//method is inflated, we should inflate it on the other class
MonoGenericContext ctx;
ctx.method_inst = inflated->context.method_inst;
ctx.class_inst = inflated->context.class_inst;
if (mono_class_is_ginst (klass))
ctx.class_inst = mono_class_get_generic_class (klass)->context.class_inst;
else if (mono_class_is_gtd (klass))
ctx.class_inst = mono_class_get_generic_container (klass)->context.class_inst;
result = mono_class_inflate_generic_method_full_checked (inflated->declaring, klass, &ctx, error);
g_assert (is_ok (error)); /* FIXME don't swallow the error */
return result;
}
mono_class_setup_methods (method->klass);
if (mono_class_has_failure (method->klass))
return NULL;
int mcount = mono_class_get_method_count (method->klass);
MonoMethod **method_klass_methods = m_class_get_methods (method->klass);
for (i = 0; i < mcount; ++i) {
if (method_klass_methods [i] == method) {
offset = i;
break;
}
}
mono_class_setup_methods (klass);
if (mono_class_has_failure (klass))
return NULL;
g_assert (offset >= 0 && offset < mono_class_get_method_count (klass));
return m_class_get_methods (klass) [offset];
}
MonoReflectionMethodHandle
ves_icall_System_Reflection_RuntimeMethodInfo_GetMethodFromHandleInternalType_native (MonoMethod *method, MonoType *type, MonoBoolean generic_check, MonoError *error)
{
MonoClass *klass;
if (type && generic_check) {
klass = mono_class_from_mono_type_internal (type);
if (mono_class_get_generic_type_definition (method->klass) != mono_class_get_generic_type_definition (klass))
return MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
if (method->klass != klass) {
method = mono_method_get_equivalent_method (method, klass);
if (!method)
return MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
}
} else if (type)
klass = mono_class_from_mono_type_internal (type);
else
klass = method->klass;
return mono_method_get_object_handle (method, klass, error);
}
MonoReflectionMethodBodyHandle
ves_icall_System_Reflection_RuntimeMethodInfo_GetMethodBodyInternal (MonoMethod *method, MonoError *error)
{
return mono_method_body_get_object_handle (method, error);
}
MonoReflectionAssemblyHandle
ves_icall_System_Reflection_Assembly_GetExecutingAssembly (MonoStackCrawlMark *stack_mark, MonoError *error)
{
MonoAssembly *assembly;
assembly = mono_runtime_get_caller_from_stack_mark (stack_mark);
g_assert (assembly);
return mono_assembly_get_object_handle (assembly, error);
}
MonoReflectionAssemblyHandle
ves_icall_System_Reflection_Assembly_GetEntryAssembly (MonoError *error)
{
MonoAssembly *assembly = mono_runtime_get_entry_assembly ();
if (!assembly)
return MONO_HANDLE_CAST (MonoReflectionAssembly, NULL_HANDLE);
return mono_assembly_get_object_handle (assembly, error);
}
MonoReflectionAssemblyHandle
ves_icall_System_Reflection_Assembly_GetCallingAssembly (MonoError *error)
{
MonoMethod *m;
MonoMethod *dest;
dest = NULL;
mono_stack_walk_no_il (get_executing, &dest);
m = dest;
mono_stack_walk_no_il (get_caller_no_reflection, &dest);
if (!dest)
dest = m;
if (!m) {
mono_error_set_not_supported (error, "Stack walks are not supported on this platform.");
return MONO_HANDLE_CAST (MonoReflectionAssembly, NULL_HANDLE);
}
return mono_assembly_get_object_handle (m_class_get_image (dest->klass)->assembly, error);
}
void
ves_icall_System_RuntimeType_getFullName (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoBoolean full_name,
MonoBoolean assembly_qualified, MonoError *error)
{
MonoType *type = type_handle.type;
MonoTypeNameFormat format;
gchar *name;
if (full_name)
format = assembly_qualified ?
MONO_TYPE_NAME_FORMAT_ASSEMBLY_QUALIFIED :
MONO_TYPE_NAME_FORMAT_FULL_NAME;
else
format = MONO_TYPE_NAME_FORMAT_REFLECTION;
name = mono_type_get_name_full (type, format);
if (!name)
return;
if (full_name && (type->type == MONO_TYPE_VAR || type->type == MONO_TYPE_MVAR)) {
g_free (name);
return;
}
HANDLE_ON_STACK_SET (res, mono_string_new_checked (name, error));
g_free (name);
}
MonoAssemblyName *
ves_icall_System_Reflection_AssemblyName_GetNativeName (MonoAssembly *mass)
{
return &mass->aname;
}
static gboolean
mono_module_type_is_visible (MonoTableInfo *tdef, MonoImage *image, int type)
{
guint32 attrs, visibility;
do {
attrs = mono_metadata_decode_row_col (tdef, type - 1, MONO_TYPEDEF_FLAGS);
visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
if (visibility != TYPE_ATTRIBUTE_PUBLIC && visibility != TYPE_ATTRIBUTE_NESTED_PUBLIC)
return FALSE;
} while ((type = mono_metadata_token_index (mono_metadata_nested_in_typedef (image, type))));
return TRUE;
}
static void
image_get_type (MonoImage *image, MonoTableInfo *tdef, int table_idx, int count, MonoArrayHandle res, MonoArrayHandle exceptions, MonoBoolean exportedOnly, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
ERROR_DECL (klass_error);
MonoClass *klass = mono_class_get_checked (image, table_idx | MONO_TOKEN_TYPE_DEF, klass_error);
if (klass) {
MonoReflectionTypeHandle rt = mono_type_get_object_handle (m_class_get_byval_arg (klass), error);
return_if_nok (error);
MONO_HANDLE_ARRAY_SETREF (res, count, rt);
} else {
MonoExceptionHandle ex = mono_error_convert_to_exception_handle (klass_error);
MONO_HANDLE_ARRAY_SETREF (exceptions, count, ex);
}
HANDLE_FUNCTION_RETURN ();
}
static MonoArrayHandle
mono_module_get_types (MonoImage *image, MonoArrayHandleOut exceptions, MonoBoolean exportedOnly, MonoError *error)
{
/* FIXME: metadata-update */
MonoTableInfo *tdef = &image->tables [MONO_TABLE_TYPEDEF];
int rows = table_info_get_rows (tdef);
int i, count;
/* we start the count from 1 because we skip the special type <Module> */
if (exportedOnly) {
count = 0;
for (i = 1; i < rows; ++i) {
if (mono_module_type_is_visible (tdef, image, i + 1))
count++;
}
} else {
count = rows - 1;
}
MonoArrayHandle res = mono_array_new_handle (mono_defaults.runtimetype_class, count, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
MONO_HANDLE_ASSIGN (exceptions, mono_array_new_handle (mono_defaults.exception_class, count, error));
return_val_if_nok (error, NULL_HANDLE_ARRAY);
count = 0;
for (i = 1; i < rows; ++i) {
if (!exportedOnly || mono_module_type_is_visible (tdef, image, i+1)) {
image_get_type (image, tdef, i + 1, count, res, exceptions, exportedOnly, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
count++;
}
}
return res;
}
static void
append_module_types (MonoArrayHandleOut res, MonoArrayHandleOut exceptions, MonoImage *image, MonoBoolean exportedOnly, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoArrayHandle ex2 = MONO_HANDLE_NEW (MonoArray, NULL);
MonoArrayHandle res2 = mono_module_get_types (image, ex2, exportedOnly, error);
goto_if_nok (error, leave);
/* Append the new types to the end of the array */
if (mono_array_handle_length (res2) > 0) {
guint32 len1, len2;
len1 = mono_array_handle_length (res);
len2 = mono_array_handle_length (res2);
MonoArrayHandle res3 = mono_array_new_handle (mono_defaults.runtimetype_class, len1 + len2, error);
goto_if_nok (error, leave);
mono_array_handle_memcpy_refs (res3, 0, res, 0, len1);
mono_array_handle_memcpy_refs (res3, len1, res2, 0, len2);
MONO_HANDLE_ASSIGN (res, res3);
MonoArrayHandle ex3 = mono_array_new_handle (mono_defaults.runtimetype_class, len1 + len2, error);
goto_if_nok (error, leave);
mono_array_handle_memcpy_refs (ex3, 0, exceptions, 0, len1);
mono_array_handle_memcpy_refs (ex3, len1, ex2, 0, len2);
MONO_HANDLE_ASSIGN (exceptions, ex3);
}
leave:
HANDLE_FUNCTION_RETURN ();
}
static void
set_class_failure_in_array (MonoArrayHandle exl, int i, MonoClass *klass)
{
HANDLE_FUNCTION_ENTER ();
ERROR_DECL (unboxed_error);
mono_error_set_for_class_failure (unboxed_error, klass);
MonoExceptionHandle exc = MONO_HANDLE_NEW (MonoException, mono_error_convert_to_exception (unboxed_error));
MONO_HANDLE_ARRAY_SETREF (exl, i, exc);
HANDLE_FUNCTION_RETURN ();
}
void
ves_icall_System_Reflection_RuntimeAssembly_GetExportedTypes (MonoQCallAssemblyHandle assembly_handle, MonoObjectHandleOnStack res_h,
MonoError *error)
{
MonoArrayHandle exceptions = MONO_HANDLE_NEW(MonoArray, NULL);
MonoAssembly *assembly = assembly_handle.assembly;
int i;
g_assert (!assembly_is_dynamic (assembly));
MonoImage *image = assembly->image;
MonoTableInfo *table = &image->tables [MONO_TABLE_FILE];
MonoArrayHandle res = mono_module_get_types (image, exceptions, TRUE, error);
return_if_nok (error);
/* Append data from all modules in the assembly */
int rows = table_info_get_rows (table);
for (i = 0; i < rows; ++i) {
if (!(mono_metadata_decode_row_col (table, i, MONO_FILE_FLAGS) & FILE_CONTAINS_NO_METADATA)) {
MonoImage *loaded_image = mono_assembly_load_module_checked (image->assembly, i + 1, error);
return_if_nok (error);
if (loaded_image) {
append_module_types (res, exceptions, loaded_image, TRUE, error);
return_if_nok (error);
}
}
}
/* the ReflectionTypeLoadException must have all the types (Types property),
* NULL replacing types which throws an exception. The LoaderException must
* contain all exceptions for NULL items.
*/
int len = mono_array_handle_length (res);
int ex_count = 0;
GList *list = NULL;
MonoReflectionTypeHandle t = MONO_HANDLE_NEW (MonoReflectionType, NULL);
for (i = 0; i < len; i++) {
MONO_HANDLE_ARRAY_GETREF (t, res, i);
if (!MONO_HANDLE_IS_NULL (t)) {
MonoClass *klass = mono_type_get_class_internal (MONO_HANDLE_GETVAL (t, type));
if ((klass != NULL) && mono_class_has_failure (klass)) {
/* keep the class in the list */
list = g_list_append (list, klass);
/* and replace Type with NULL */
MONO_HANDLE_ARRAY_SETREF (res, i, NULL_HANDLE);
}
} else {
ex_count ++;
}
}
if (list || ex_count) {
GList *tmp = NULL;
int j, length = g_list_length (list) + ex_count;
MonoArrayHandle exl = mono_array_new_handle (mono_defaults.exception_class, length, error);
if (!is_ok (error)) {
g_list_free (list);
return;
}
/* Types for which mono_class_get_checked () succeeded */
MonoExceptionHandle exc = MONO_HANDLE_NEW (MonoException, NULL);
for (i = 0, tmp = list; tmp; i++, tmp = tmp->next) {
set_class_failure_in_array (exl, i, (MonoClass*)tmp->data);
}
/* Types for which it don't */
for (j = 0; j < mono_array_handle_length (exceptions); ++j) {
MONO_HANDLE_ARRAY_GETREF (exc, exceptions, j);
if (!MONO_HANDLE_IS_NULL (exc)) {
g_assert (i < length);
MONO_HANDLE_ARRAY_SETREF (exl, i, exc);
i ++;
}
}
g_list_free (list);
list = NULL;
MONO_HANDLE_ASSIGN (exc, mono_get_exception_reflection_type_load_checked (res, exl, error));
return_if_nok (error);
mono_error_set_exception_handle (error, exc);
return;
}
HANDLE_ON_STACK_SET (res_h, MONO_HANDLE_RAW (res));
}
static void
get_top_level_forwarded_type (MonoImage *image, MonoTableInfo *table, int i, MonoArrayHandle types, MonoArrayHandle exceptions, int *aindex, int *exception_count)
{
ERROR_DECL (local_error);
guint32 cols [MONO_EXP_TYPE_SIZE];
MonoClass *klass;
MonoReflectionTypeHandle rt;
mono_metadata_decode_row (table, i, cols, MONO_EXP_TYPE_SIZE);
if (!(cols [MONO_EXP_TYPE_FLAGS] & TYPE_ATTRIBUTE_FORWARDER))
return;
guint32 impl = cols [MONO_EXP_TYPE_IMPLEMENTATION];
const char *name = mono_metadata_string_heap (image, cols [MONO_EXP_TYPE_NAME]);
const char *nspace = mono_metadata_string_heap (image, cols [MONO_EXP_TYPE_NAMESPACE]);
g_assert ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_ASSEMBLYREF);
guint32 assembly_idx = impl >> MONO_IMPLEMENTATION_BITS;
mono_assembly_load_reference (image, assembly_idx - 1);
g_assert (image->references [assembly_idx - 1]);
HANDLE_FUNCTION_ENTER ();
if (image->references [assembly_idx - 1] == REFERENCE_MISSING) {
MonoExceptionHandle ex = MONO_HANDLE_NEW (MonoException, mono_get_exception_bad_image_format ("Invalid image"));
MONO_HANDLE_ARRAY_SETREF (types, *aindex, NULL_HANDLE);
MONO_HANDLE_ARRAY_SETREF (exceptions, *aindex, ex);
(*exception_count)++; (*aindex)++;
goto exit;
}
klass = mono_class_from_name_checked (image->references [assembly_idx - 1]->image, nspace, name, local_error);
if (!is_ok (local_error)) {
MonoExceptionHandle ex = mono_error_convert_to_exception_handle (local_error);
MONO_HANDLE_ARRAY_SETREF (types, *aindex, NULL_HANDLE);
MONO_HANDLE_ARRAY_SETREF (exceptions, *aindex, ex);
mono_error_cleanup (local_error);
(*exception_count)++; (*aindex)++;
goto exit;
}
rt = mono_type_get_object_handle (m_class_get_byval_arg (klass), local_error);
if (!is_ok (local_error)) {
MonoExceptionHandle ex = mono_error_convert_to_exception_handle (local_error);
MONO_HANDLE_ARRAY_SETREF (types, *aindex, NULL_HANDLE);
MONO_HANDLE_ARRAY_SETREF (exceptions, *aindex, ex);
mono_error_cleanup (local_error);
(*exception_count)++; (*aindex)++;
goto exit;
}
MONO_HANDLE_ARRAY_SETREF (types, *aindex, rt);
MONO_HANDLE_ARRAY_SETREF (exceptions, *aindex, NULL_HANDLE);
(*aindex)++;
exit:
HANDLE_FUNCTION_RETURN ();
}
void
ves_icall_System_Reflection_RuntimeAssembly_GetTopLevelForwardedTypes (MonoQCallAssemblyHandle assembly_h, MonoObjectHandleOnStack res,
MonoError *error)
{
MonoAssembly *assembly = assembly_h.assembly;
MonoImage *image = assembly->image;
int count = 0;
g_assert (!assembly_is_dynamic (assembly));
MonoTableInfo *table = &image->tables [MONO_TABLE_EXPORTEDTYPE];
int rows = table_info_get_rows (table);
for (int i = 0; i < rows; ++i) {
if (mono_metadata_decode_row_col (table, i, MONO_EXP_TYPE_FLAGS) & TYPE_ATTRIBUTE_FORWARDER)
count ++;
}
MonoArrayHandle types = mono_array_new_handle (mono_defaults.runtimetype_class, count, error);
return_if_nok (error);
MonoArrayHandle exceptions = mono_array_new_handle (mono_defaults.exception_class, count, error);
return_if_nok (error);
int aindex = 0;
int exception_count = 0;
for (int i = 0; i < rows; ++i)
get_top_level_forwarded_type (image, table, i, types, exceptions, &aindex, &exception_count);
if (exception_count > 0) {
MonoExceptionHandle exc = MONO_HANDLE_NEW (MonoException, NULL);
MONO_HANDLE_ASSIGN (exc, mono_get_exception_reflection_type_load_checked (types, exceptions, error));
return_if_nok (error);
mono_error_set_exception_handle (error, exc);
return;
}
HANDLE_ON_STACK_SET (res, MONO_HANDLE_RAW (types));
}
void
ves_icall_Mono_RuntimeMarshal_FreeAssemblyName (MonoAssemblyName *aname, MonoBoolean free_struct)
{
mono_assembly_name_free_internal (aname);
if (free_struct)
g_free (aname);
}
void
ves_icall_AssemblyExtensions_ApplyUpdate (MonoAssembly *assm,
gconstpointer dmeta_bytes, int32_t dmeta_len,
gconstpointer dil_bytes, int32_t dil_len,
gconstpointer dpdb_bytes, int32_t dpdb_len)
{
ERROR_DECL (error);
g_assert (assm);
g_assert (dmeta_len >= 0);
MonoImage *image_base = assm->image;
g_assert (image_base);
#ifndef HOST_WASM
if (mono_is_debugger_attached ()) {
mono_error_set_not_supported (error, "Cannot use System.Reflection.Metadata.MetadataUpdater.ApplyChanges while debugger is attached");
mono_error_set_pending_exception (error);
return;
}
#endif
mono_image_load_enc_delta (MONO_ENC_DELTA_API, image_base, dmeta_bytes, dmeta_len, dil_bytes, dil_len, dpdb_bytes, dpdb_len, error);
mono_error_set_pending_exception (error);
}
gint32 ves_icall_AssemblyExtensions_ApplyUpdateEnabled (gint32 just_component_check)
{
// if just_component_check is true, we only care whether the hot_reload component is enabled,
// not whether the environment is appropriately setup to apply updates.
return mono_metadata_update_available () && (just_component_check || mono_metadata_update_enabled (NULL));
}
MonoReflectionTypeHandle
ves_icall_System_Reflection_RuntimeModule_GetGlobalType (MonoImage *image, MonoError *error)
{
MonoClass *klass;
g_assert (image);
MonoReflectionTypeHandle ret = MONO_HANDLE_CAST (MonoReflectionType, NULL_HANDLE);
if (image_is_dynamic (image) && ((MonoDynamicImage*)image)->initial_image)
/* These images do not have a global type */
goto leave;
klass = mono_class_get_checked (image, 1 | MONO_TOKEN_TYPE_DEF, error);
goto_if_nok (error, leave);
ret = mono_type_get_object_handle (m_class_get_byval_arg (klass), error);
leave:
return ret;
}
void
ves_icall_System_Reflection_RuntimeModule_GetGuidInternal (MonoImage *image, MonoArrayHandle guid_h, MonoError *error)
{
g_assert (mono_array_handle_length (guid_h) == 16);
if (!image->metadata_only) {
g_assert (image->heap_guid.data);
g_assert (image->heap_guid.size >= 16);
MONO_ENTER_NO_SAFEPOINTS;
guint8 *data = (guint8*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (guid_h), 1, 0);
memcpy (data, (guint8*)image->heap_guid.data, 16);
MONO_EXIT_NO_SAFEPOINTS;
} else {
MONO_ENTER_NO_SAFEPOINTS;
guint8 *data = (guint8*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (guid_h), 1, 0);
memset (data, 0, 16);
MONO_EXIT_NO_SAFEPOINTS;
}
}
void
ves_icall_System_Reflection_RuntimeModule_GetPEKind (MonoImage *image, gint32 *pe_kind, gint32 *machine, MonoError *error)
{
if (image_is_dynamic (image)) {
MonoDynamicImage *dyn = (MonoDynamicImage*)image;
*pe_kind = dyn->pe_kind;
*machine = dyn->machine;
}
else {
*pe_kind = (image->image_info->cli_cli_header.ch_flags & 0x3);
*machine = image->image_info->cli_header.coff.coff_machine;
}
}
gint32
ves_icall_System_Reflection_RuntimeModule_GetMDStreamVersion (MonoImage *image, MonoError *error)
{
return (image->md_version_major << 16) | (image->md_version_minor);
}
MonoArrayHandle
ves_icall_System_Reflection_RuntimeModule_InternalGetTypes (MonoImage *image, MonoError *error)
{
if (!image) {
MonoArrayHandle arr = mono_array_new_handle (mono_defaults.runtimetype_class, 0, error);
return arr;
} else {
MonoArrayHandle exceptions = MONO_HANDLE_NEW (MonoArray, NULL);
MonoArrayHandle res = mono_module_get_types (image, exceptions, FALSE, error);
return_val_if_nok (error, MONO_HANDLE_CAST(MonoArray, NULL_HANDLE));
int n = mono_array_handle_length (exceptions);
MonoExceptionHandle ex = MONO_HANDLE_NEW (MonoException, NULL);
for (int i = 0; i < n; ++i) {
MONO_HANDLE_ARRAY_GETREF(ex, exceptions, i);
if (!MONO_HANDLE_IS_NULL (ex)) {
mono_error_set_exception_handle (error, ex);
return MONO_HANDLE_CAST(MonoArray, NULL_HANDLE);
}
}
return res;
}
}
static gboolean
mono_memberref_is_method (MonoImage *image, guint32 token)
{
if (!image_is_dynamic (image)) {
int idx = mono_metadata_token_index (token);
if (idx <= 0 || mono_metadata_table_bounds_check (image, MONO_TABLE_MEMBERREF, idx)) {
return FALSE;
}
guint32 cols [MONO_MEMBERREF_SIZE];
const MonoTableInfo *table = &image->tables [MONO_TABLE_MEMBERREF];
mono_metadata_decode_row (table, idx - 1, cols, MONO_MEMBERREF_SIZE);
const char *sig = mono_metadata_blob_heap (image, cols [MONO_MEMBERREF_SIGNATURE]);
mono_metadata_decode_blob_size (sig, &sig);
return (*sig != 0x6);
} else {
ERROR_DECL (error);
MonoClass *handle_class;
if (!mono_lookup_dynamic_token_class (image, token, FALSE, &handle_class, NULL, error)) {
mono_error_cleanup (error); /* just probing, ignore error */
return FALSE;
}
return mono_defaults.methodhandle_class == handle_class;
}
}
static MonoGenericInst *
get_generic_inst_from_array_handle (MonoArrayHandle type_args)
{
int type_argc = mono_array_handle_length (type_args);
int size = MONO_SIZEOF_GENERIC_INST + type_argc * sizeof (MonoType *);
MonoGenericInst *ginst = (MonoGenericInst *)g_alloca (size);
memset (ginst, 0, MONO_SIZEOF_GENERIC_INST);
ginst->type_argc = type_argc;
for (int i = 0; i < type_argc; i++) {
MONO_HANDLE_ARRAY_GETVAL (ginst->type_argv[i], type_args, MonoType*, i);
}
ginst->is_open = FALSE;
for (int i = 0; i < type_argc; i++) {
if (mono_class_is_open_constructed_type (ginst->type_argv[i])) {
ginst->is_open = TRUE;
break;
}
}
return mono_metadata_get_canonical_generic_inst (ginst);
}
static void
init_generic_context_from_args_handles (MonoGenericContext *context, MonoArrayHandle type_args, MonoArrayHandle method_args)
{
if (!MONO_HANDLE_IS_NULL (type_args)) {
context->class_inst = get_generic_inst_from_array_handle (type_args);
} else {
context->class_inst = NULL;
}
if (!MONO_HANDLE_IS_NULL (method_args)) {
context->method_inst = get_generic_inst_from_array_handle (method_args);
} else {
context->method_inst = NULL;
}
}
static MonoType*
module_resolve_type_token (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *resolve_error, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoType *result = NULL;
MonoClass *klass;
int table = mono_metadata_token_table (token);
int index = mono_metadata_token_index (token);
MonoGenericContext context;
*resolve_error = ResolveTokenError_Other;
/* Validate token */
if ((table != MONO_TABLE_TYPEDEF) && (table != MONO_TABLE_TYPEREF) &&
(table != MONO_TABLE_TYPESPEC)) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
if (image_is_dynamic (image)) {
if ((table == MONO_TABLE_TYPEDEF) || (table == MONO_TABLE_TYPEREF)) {
ERROR_DECL (inner_error);
klass = (MonoClass *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL, inner_error);
mono_error_cleanup (inner_error);
result = klass ? m_class_get_byval_arg (klass) : NULL;
goto leave;
}
init_generic_context_from_args_handles (&context, type_args, method_args);
ERROR_DECL (inner_error);
klass = (MonoClass *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context, inner_error);
mono_error_cleanup (inner_error);
result = klass ? m_class_get_byval_arg (klass) : NULL;
goto leave;
}
if ((index <= 0) || mono_metadata_table_bounds_check (image, table, index)) {
*resolve_error = ResolveTokenError_OutOfRange;
goto leave;
}
init_generic_context_from_args_handles (&context, type_args, method_args);
klass = mono_class_get_checked (image, token, error);
if (klass)
klass = mono_class_inflate_generic_class_checked (klass, &context, error);
goto_if_nok (error, leave);
if (klass)
result = m_class_get_byval_arg (klass);
leave:
HANDLE_FUNCTION_RETURN_VAL (result);
}
MonoType*
ves_icall_System_Reflection_RuntimeModule_ResolveTypeToken (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *resolve_error, MonoError *error)
{
return module_resolve_type_token (image, token, type_args, method_args, resolve_error, error);
}
static MonoMethod*
module_resolve_method_token (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *resolve_error, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoMethod *method = NULL;
int table = mono_metadata_token_table (token);
int index = mono_metadata_token_index (token);
MonoGenericContext context;
*resolve_error = ResolveTokenError_Other;
/* Validate token */
if ((table != MONO_TABLE_METHOD) && (table != MONO_TABLE_METHODSPEC) &&
(table != MONO_TABLE_MEMBERREF)) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
if (image_is_dynamic (image)) {
if (table == MONO_TABLE_METHOD) {
ERROR_DECL (inner_error);
method = (MonoMethod *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL, inner_error);
mono_error_cleanup (inner_error);
goto leave;
}
if ((table == MONO_TABLE_MEMBERREF) && !(mono_memberref_is_method (image, token))) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
init_generic_context_from_args_handles (&context, type_args, method_args);
ERROR_DECL (inner_error);
method = (MonoMethod *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context, inner_error);
mono_error_cleanup (inner_error);
goto leave;
}
if ((index <= 0) || mono_metadata_table_bounds_check (image, table, index)) {
*resolve_error = ResolveTokenError_OutOfRange;
goto leave;
}
if ((table == MONO_TABLE_MEMBERREF) && (!mono_memberref_is_method (image, token))) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
init_generic_context_from_args_handles (&context, type_args, method_args);
method = mono_get_method_checked (image, token, NULL, &context, error);
leave:
HANDLE_FUNCTION_RETURN_VAL (method);
}
MonoMethod*
ves_icall_System_Reflection_RuntimeModule_ResolveMethodToken (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *resolve_error, MonoError *error)
{
return module_resolve_method_token (image, token, type_args, method_args, resolve_error, error);
}
MonoStringHandle
ves_icall_System_Reflection_RuntimeModule_ResolveStringToken (MonoImage *image, guint32 token, MonoResolveTokenError *resolve_error, MonoError *error)
{
int index = mono_metadata_token_index (token);
*resolve_error = ResolveTokenError_Other;
/* Validate token */
if (mono_metadata_token_code (token) != MONO_TOKEN_STRING) {
*resolve_error = ResolveTokenError_BadTable;
return NULL_HANDLE_STRING;
}
if (image_is_dynamic (image)) {
ERROR_DECL (ignore_inner_error);
// FIXME ignoring error
// FIXME Push MONO_HANDLE_NEW to lower layers.
MonoStringHandle result = MONO_HANDLE_NEW (MonoString, (MonoString*)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL, ignore_inner_error));
mono_error_cleanup (ignore_inner_error);
return result;
}
if ((index <= 0) || (index >= image->heap_us.size)) {
*resolve_error = ResolveTokenError_OutOfRange;
return NULL_HANDLE_STRING;
}
/* FIXME: What to do if the index points into the middle of a string ? */
return mono_ldstr_handle (image, index, error);
}
static MonoClassField*
module_resolve_field_token (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *resolve_error, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoClass *klass;
int table = mono_metadata_token_table (token);
int index = mono_metadata_token_index (token);
MonoGenericContext context;
MonoClassField *field = NULL;
*resolve_error = ResolveTokenError_Other;
/* Validate token */
if ((table != MONO_TABLE_FIELD) && (table != MONO_TABLE_MEMBERREF)) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
if (image_is_dynamic (image)) {
if (table == MONO_TABLE_FIELD) {
ERROR_DECL (inner_error);
field = (MonoClassField *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, NULL, inner_error);
mono_error_cleanup (inner_error);
goto leave;
}
if (mono_memberref_is_method (image, token)) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
init_generic_context_from_args_handles (&context, type_args, method_args);
ERROR_DECL (inner_error);
field = (MonoClassField *)mono_lookup_dynamic_token_class (image, token, FALSE, NULL, &context, inner_error);
mono_error_cleanup (inner_error);
goto leave;
}
if ((index <= 0) || mono_metadata_table_bounds_check (image, table, index)) {
*resolve_error = ResolveTokenError_OutOfRange;
goto leave;
}
if ((table == MONO_TABLE_MEMBERREF) && (mono_memberref_is_method (image, token))) {
*resolve_error = ResolveTokenError_BadTable;
goto leave;
}
init_generic_context_from_args_handles (&context, type_args, method_args);
field = mono_field_from_token_checked (image, token, &klass, &context, error);
leave:
HANDLE_FUNCTION_RETURN_VAL (field);
}
MonoClassField*
ves_icall_System_Reflection_RuntimeModule_ResolveFieldToken (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *resolve_error, MonoError *error)
{
return module_resolve_field_token (image, token, type_args, method_args, resolve_error, error);
}
MonoObjectHandle
ves_icall_System_Reflection_RuntimeModule_ResolveMemberToken (MonoImage *image, guint32 token, MonoArrayHandle type_args, MonoArrayHandle method_args, MonoResolveTokenError *error, MonoError *merror)
{
int table = mono_metadata_token_table (token);
*error = ResolveTokenError_Other;
switch (table) {
case MONO_TABLE_TYPEDEF:
case MONO_TABLE_TYPEREF:
case MONO_TABLE_TYPESPEC: {
MonoType *t = module_resolve_type_token (image, token, type_args, method_args, error, merror);
if (t) {
return MONO_HANDLE_CAST (MonoObject, mono_type_get_object_handle (t, merror));
}
else
return NULL_HANDLE;
}
case MONO_TABLE_METHOD:
case MONO_TABLE_METHODSPEC: {
MonoMethod *m = module_resolve_method_token (image, token, type_args, method_args, error, merror);
if (m) {
return MONO_HANDLE_CAST (MonoObject, mono_method_get_object_handle (m, m->klass, merror));
} else
return NULL_HANDLE;
}
case MONO_TABLE_FIELD: {
MonoClassField *f = module_resolve_field_token (image, token, type_args, method_args, error, merror);
if (f) {
return MONO_HANDLE_CAST (MonoObject, mono_field_get_object_handle (m_field_get_parent (f), f, merror));
}
else
return NULL_HANDLE;
}
case MONO_TABLE_MEMBERREF:
if (mono_memberref_is_method (image, token)) {
MonoMethod *m = module_resolve_method_token (image, token, type_args, method_args, error, merror);
if (m) {
return MONO_HANDLE_CAST (MonoObject, mono_method_get_object_handle (m, m->klass, merror));
} else
return NULL_HANDLE;
}
else {
MonoClassField *f = module_resolve_field_token (image, token, type_args, method_args, error, merror);
if (f) {
return MONO_HANDLE_CAST (MonoObject, mono_field_get_object_handle (m_field_get_parent (f), f, merror));
}
else
return NULL_HANDLE;
}
break;
default:
*error = ResolveTokenError_BadTable;
}
return NULL_HANDLE;
}
MonoArrayHandle
ves_icall_System_Reflection_RuntimeModule_ResolveSignature (MonoImage *image, guint32 token, MonoResolveTokenError *resolve_error, MonoError *error)
{
int table = mono_metadata_token_table (token);
int idx = mono_metadata_token_index (token);
MonoTableInfo *tables = image->tables;
guint32 sig, len;
const char *ptr;
*resolve_error = ResolveTokenError_OutOfRange;
/* FIXME: Support other tables ? */
if (table != MONO_TABLE_STANDALONESIG)
return NULL_HANDLE_ARRAY;
if (image_is_dynamic (image))
return NULL_HANDLE_ARRAY;
if ((idx == 0) || mono_metadata_table_bounds_check (image, MONO_TABLE_STANDALONESIG, idx))
return NULL_HANDLE_ARRAY;
sig = mono_metadata_decode_row_col (&tables [MONO_TABLE_STANDALONESIG], idx - 1, 0);
ptr = mono_metadata_blob_heap (image, sig);
len = mono_metadata_decode_blob_size (ptr, &ptr);
MonoArrayHandle res = mono_array_new_handle (mono_defaults.byte_class, len, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
// FIXME MONO_ENTER_NO_SAFEPOINTS instead of pin/gchandle.
MonoGCHandle h;
gpointer array_base = MONO_ARRAY_HANDLE_PIN (res, guint8, 0, &h);
memcpy (array_base, ptr, len);
mono_gchandle_free_internal (h);
return res;
}
static void
check_for_invalid_array_type (MonoType *type, MonoError *error)
{
gboolean allowed = TRUE;
char *name;
if (m_type_is_byref (type))
allowed = FALSE;
else if (type->type == MONO_TYPE_TYPEDBYREF)
allowed = FALSE;
MonoClass *klass = mono_class_from_mono_type_internal (type);
if (m_class_is_byreflike (klass))
allowed = FALSE;
if (allowed)
return;
name = mono_type_get_full_name (klass);
mono_error_set_type_load_name (error, name, g_strdup (""), "");
}
static void
check_for_invalid_byref_or_pointer_type (MonoClass *klass, MonoError *error)
{
return;
}
void
ves_icall_RuntimeType_make_array_type (MonoQCallTypeHandle type_handle, int rank, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
check_for_invalid_array_type (type, error);
return_if_nok (error);
MonoClass *klass = mono_class_from_mono_type_internal (type);
MonoClass *aklass;
if (rank == 0) //single dimension array
aklass = mono_class_create_array (klass, 1);
else
aklass = mono_class_create_bounded_array (klass, rank, TRUE);
if (mono_class_has_failure (aklass)) {
mono_error_set_for_class_failure (error, aklass);
return;
}
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (aklass), error));
}
void
ves_icall_RuntimeType_make_byref_type (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_if_nok (error);
check_for_invalid_byref_or_pointer_type (klass, error);
return_if_nok (error);
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_this_arg (klass), error));
}
void
ves_icall_RuntimeType_make_pointer_type (MonoQCallTypeHandle type_handle, MonoObjectHandleOnStack res, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
mono_class_init_checked (klass, error);
return_if_nok (error);
check_for_invalid_byref_or_pointer_type (klass, error);
return_if_nok (error);
MonoClass *pklass = mono_class_create_ptr (type);
HANDLE_ON_STACK_SET (res, mono_type_get_object_checked (m_class_get_byval_arg (pklass), error));
}
MonoObjectHandle
ves_icall_System_Delegate_CreateDelegate_internal (MonoQCallTypeHandle type_handle, MonoObjectHandle target,
MonoReflectionMethodHandle info, MonoBoolean throwOnBindFailure, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *delegate_class = mono_class_from_mono_type_internal (type);
MonoMethod *method = MONO_HANDLE_GETVAL (info, method);
MonoMethodSignature *sig = mono_method_signature_internal (method);
mono_class_init_checked (delegate_class, error);
return_val_if_nok (error, NULL_HANDLE);
if (!(m_class_get_parent (delegate_class) == mono_defaults.multicastdelegate_class)) {
/* FIXME improve this exception message */
mono_error_set_execution_engine (error, "file %s: line %d (%s): assertion failed: (%s)", __FILE__, __LINE__,
__func__,
"delegate_class->parent == mono_defaults.multicastdelegate_class");
return NULL_HANDLE;
}
if (sig->generic_param_count && method->wrapper_type == MONO_WRAPPER_NONE) {
if (!method->is_inflated) {
mono_error_set_argument (error, "method", " Cannot bind to the target method because its signature differs from that of the delegate type");
return NULL_HANDLE;
}
}
MonoObjectHandle delegate = mono_object_new_handle (delegate_class, error);
return_val_if_nok (error, NULL_HANDLE);
if (!method_is_dynamic (method) && (!MONO_HANDLE_IS_NULL (target) && method->flags & METHOD_ATTRIBUTE_VIRTUAL && method->klass != mono_handle_class (target))) {
method = mono_object_handle_get_virtual_method (target, method, error);
return_val_if_nok (error, NULL_HANDLE);
}
mono_delegate_ctor (delegate, target, NULL, method, error);
return_val_if_nok (error, NULL_HANDLE);
return delegate;
}
MonoMulticastDelegateHandle
ves_icall_System_Delegate_AllocDelegateLike_internal (MonoDelegateHandle delegate, MonoError *error)
{
MonoClass *klass = mono_handle_class (delegate);
g_assert (mono_class_has_parent (klass, mono_defaults.multicastdelegate_class));
MonoMulticastDelegateHandle ret = MONO_HANDLE_CAST (MonoMulticastDelegate, mono_object_new_handle (klass, error));
return_val_if_nok (error, MONO_HANDLE_CAST (MonoMulticastDelegate, NULL_HANDLE));
mono_get_runtime_callbacks ()->init_delegate (MONO_HANDLE_CAST (MonoDelegate, ret), NULL_HANDLE, NULL, NULL, error);
return ret;
}
MonoReflectionMethodHandle
ves_icall_System_Delegate_GetVirtualMethod_internal (MonoDelegateHandle delegate, MonoError *error)
{
MonoObjectHandle delegate_target = MONO_HANDLE_NEW_GET (MonoObject, delegate, target);
MonoMethod *m = mono_object_handle_get_virtual_method (delegate_target, MONO_HANDLE_GETVAL (delegate, method), error);
return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
return mono_method_get_object_handle (m, m->klass, error);
}
/* System.Buffer */
static gint32
mono_array_get_byte_length (MonoArrayHandle array)
{
int length;
MonoClass * const klass = mono_handle_class (array);
// This resembles mono_array_get_length, but adds the loop.
if (mono_handle_array_has_bounds (array)) {
length = 1;
const int klass_rank = m_class_get_rank (klass);
for (int i = 0; i < klass_rank; ++ i)
length *= MONO_HANDLE_GETVAL (array, bounds [i].length);
} else {
length = mono_array_handle_length (array);
}
switch (m_class_get_byval_arg (m_class_get_element_class (klass))->type) {
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_BOOLEAN:
return length;
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_CHAR:
return length << 1;
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_R4:
return length << 2;
case MONO_TYPE_I:
case MONO_TYPE_U:
return length * sizeof (gpointer);
case MONO_TYPE_I8:
case MONO_TYPE_U8:
case MONO_TYPE_R8:
return length << 3;
default:
return -1;
}
}
/* System.Environment */
MonoArrayHandle
ves_icall_System_Environment_GetCommandLineArgs (MonoError *error)
{
MonoArrayHandle result = mono_runtime_get_main_args_handle (error);
return result;
}
void
ves_icall_System_Environment_Exit (int result)
{
mono_environment_exitcode_set (result);
if (!mono_runtime_try_shutdown ())
mono_thread_exit ();
mono_runtime_quit_internal ();
/* we may need to do some cleanup here... */
exit (result);
}
void
ves_icall_System_Environment_FailFast (MonoStringHandle message, MonoExceptionHandle exception, MonoStringHandle errorSource, MonoError *error)
{
if (MONO_HANDLE_IS_NULL (message)) {
g_warning ("Process terminated.");
} else {
char *msg = mono_string_handle_to_utf8 (message, error);
g_warning ("Process terminated due to \"%s\"", msg);
g_free (msg);
}
if (!MONO_HANDLE_IS_NULL (exception)) {
mono_print_unhandled_exception_internal ((MonoObject *) MONO_HANDLE_RAW (exception));
}
// NOTE: While this does trigger WER on Windows it doesn't quite provide all the
// information in the error dump that CoreCLR would. On Windows 7+ we should call
// RaiseFailFastException directly instead of relying on the C runtime doing it
// for us and pass it as much information as possible. On Windows 8+ we can also
// use the __fastfail intrinsic.
abort ();
}
gint32
ves_icall_System_Environment_get_TickCount (void)
{
/* this will overflow after ~24 days */
return (gint32) (mono_msec_boottime () & 0xffffffff);
}
gint64
ves_icall_System_Environment_get_TickCount64 (void)
{
return mono_msec_boottime ();
}
gpointer
ves_icall_RuntimeMethodHandle_GetFunctionPointer (MonoMethod *method, MonoError *error)
{
return mono_method_get_unmanaged_wrapper_ftnptr_internal (method, FALSE, error);
}
void*
mono_method_get_unmanaged_wrapper_ftnptr_internal (MonoMethod *method, gboolean only_unmanaged_callers_only, MonoError *error)
{
/* WISH: we should do this in managed */
if (G_UNLIKELY (mono_method_has_unmanaged_callers_only_attribute (method))) {
method = mono_marshal_get_managed_wrapper (method, NULL, (MonoGCHandle)0, error);
return_val_if_nok (error, NULL);
} else {
g_assert (!only_unmanaged_callers_only);
}
return mono_get_runtime_callbacks ()->get_ftnptr (method, error);
}
MonoBoolean
ves_icall_System_Diagnostics_Debugger_IsAttached_internal (void)
{
return mono_is_debugger_attached ();
}
MonoBoolean
ves_icall_System_Diagnostics_Debugger_IsLogging (void)
{
return mono_get_runtime_callbacks ()->debug_log_is_enabled
&& mono_get_runtime_callbacks ()->debug_log_is_enabled ();
}
void
ves_icall_System_Diagnostics_Debugger_Log (int level, MonoString *volatile* category, MonoString *volatile* message)
{
if (mono_get_runtime_callbacks ()->debug_log)
mono_get_runtime_callbacks ()->debug_log (level, *category, *message);
}
/* Only used for value types */
MonoObjectHandle
ves_icall_System_RuntimeType_CreateInstanceInternal (MonoQCallTypeHandle type_handle, MonoError *error)
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);
(void)klass;
mono_class_init_checked (klass, error);
return_val_if_nok (error, NULL_HANDLE);
if (mono_class_is_nullable (klass))
/* No arguments -> null */
return NULL_HANDLE;
return mono_object_new_handle (klass, error);
}
MonoReflectionMethodHandle
ves_icall_RuntimeMethodInfo_get_base_method (MonoReflectionMethodHandle m, MonoBoolean definition, MonoError *error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (m, method);
MonoMethod *base = mono_method_get_base_method (method, definition, error);
return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
if (base == method) {
/* we want to short-circuit and return 'm' here. But we should
return the same method object that
mono_method_get_object_handle, below would return. Since
that call takes NULL for the reftype argument, it will take
base->klass as the reflected type for the MonoMethod. So we
need to check that m also has base->klass as the reflected
type. */
MonoReflectionTypeHandle orig_reftype = MONO_HANDLE_NEW_GET (MonoReflectionType, m, reftype);
MonoClass *orig_klass = mono_class_from_mono_type_internal (MONO_HANDLE_GETVAL (orig_reftype, type));
if (base->klass == orig_klass)
return m;
}
return mono_method_get_object_handle (base, NULL, error);
}
MonoStringHandle
ves_icall_RuntimeMethodInfo_get_name (MonoReflectionMethodHandle m, MonoError *error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (m, method);
MonoStringHandle s = mono_string_new_handle (method->name, error);
return_val_if_nok (error, NULL_HANDLE_STRING);
MONO_HANDLE_SET (m, name, s);
return s;
}
void
ves_icall_System_ArgIterator_Setup (MonoArgIterator *iter, char* argsp, char* start)
{
iter->sig = *(MonoMethodSignature**)argsp;
g_assert (iter->sig->sentinelpos <= iter->sig->param_count);
g_assert (iter->sig->call_convention == MONO_CALL_VARARG);
iter->next_arg = 0;
/* FIXME: it's not documented what start is exactly... */
if (start) {
iter->args = start;
} else {
iter->args = argsp + sizeof (gpointer);
}
iter->num_args = iter->sig->param_count - iter->sig->sentinelpos;
/* g_print ("sig %p, param_count: %d, sent: %d\n", iter->sig, iter->sig->param_count, iter->sig->sentinelpos); */
}
void
ves_icall_System_ArgIterator_IntGetNextArg (MonoArgIterator *iter, MonoTypedRef *res)
{
guint32 i, arg_size;
gint32 align;
i = iter->sig->sentinelpos + iter->next_arg;
g_assert (i < iter->sig->param_count);
res->type = iter->sig->params [i];
res->klass = mono_class_from_mono_type_internal (res->type);
arg_size = mono_type_stack_size (res->type, &align);
#if defined(__arm__) || defined(__mips__)
iter->args = (guint8*)(((gsize)iter->args + (align) - 1) & ~(align - 1));
#endif
res->value = iter->args;
#if G_BYTE_ORDER != G_LITTLE_ENDIAN
if (arg_size <= sizeof (gpointer)) {
int dummy;
int padding = arg_size - mono_type_size (res->type, &dummy);
res->value = (guint8*)res->value + padding;
}
#endif
iter->args = (char*)iter->args + arg_size;
iter->next_arg++;
/* g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res->type->type, arg_size, res->value); */
}
void
ves_icall_System_ArgIterator_IntGetNextArgWithType (MonoArgIterator *iter, MonoTypedRef *res, MonoType *type)
{
guint32 i, arg_size;
gint32 align;
i = iter->sig->sentinelpos + iter->next_arg;
g_assert (i < iter->sig->param_count);
while (i < iter->sig->param_count) {
if (!mono_metadata_type_equal (type, iter->sig->params [i]))
continue;
res->type = iter->sig->params [i];
res->klass = mono_class_from_mono_type_internal (res->type);
/* FIXME: endianess issue... */
arg_size = mono_type_stack_size (res->type, &align);
#if defined(__arm__) || defined(__mips__)
iter->args = (guint8*)(((gsize)iter->args + (align) - 1) & ~(align - 1));
#endif
res->value = iter->args;
iter->args = (char*)iter->args + arg_size;
iter->next_arg++;
/* g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value); */
return;
}
/* g_print ("arg type 0x%02x not found\n", res.type->type); */
memset (res, 0, sizeof (MonoTypedRef));
}
MonoType*
ves_icall_System_ArgIterator_IntGetNextArgType (MonoArgIterator *iter)
{
gint i;
i = iter->sig->sentinelpos + iter->next_arg;
g_assert (i < iter->sig->param_count);
return iter->sig->params [i];
}
MonoObjectHandle
ves_icall_System_TypedReference_ToObject (MonoTypedRef* tref, MonoError *error)
{
return typed_reference_to_object (tref, error);
}
void
ves_icall_System_TypedReference_InternalMakeTypedReference (MonoTypedRef *res, MonoObjectHandle target, MonoArrayHandle fields, MonoReflectionTypeHandle last_field, MonoError *error)
{
MonoType *ftype = NULL;
int i;
memset (res, 0, sizeof (MonoTypedRef));
g_assert (mono_array_handle_length (fields) > 0);
(void)mono_handle_class (target);
int offset = 0;
for (i = 0; i < mono_array_handle_length (fields); ++i) {
MonoClassField *f;
MONO_HANDLE_ARRAY_GETVAL (f, fields, MonoClassField*, i);
g_assert (f);
if (i == 0)
offset = f->offset;
else
offset += f->offset - sizeof (MonoObject);
(void)mono_class_from_mono_type_internal (f->type);
ftype = f->type;
}
res->type = ftype;
res->klass = mono_class_from_mono_type_internal (ftype);
res->value = (guint8*)MONO_HANDLE_RAW (target) + offset;
}
void
ves_icall_System_Runtime_InteropServices_Marshal_Prelink (MonoReflectionMethodHandle method_h, MonoError *error)
{
MonoMethod *method = MONO_HANDLE_GETVAL (method_h, method);
if (!(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
return;
mono_lookup_pinvoke_call_internal (method, error);
/* create the wrapper, too? */
}
int
ves_icall_Interop_Sys_DoubleToString(double value, char *format, char *buffer, int bufferLength)
{
#if defined(TARGET_ARM)
/* workaround for faulty vcmp.f64 implementation on some 32bit ARM CPUs */
guint64 bits = *(guint64 *) &value;
if (bits == 0x1) { /* 4.9406564584124654E-324 */
g_assert (!strcmp (format, "%.40e"));
return snprintf (buffer, bufferLength, "%s", "4.9406564584124654417656879286822137236506e-324");
} else if (bits == 0x4) { /* 2E-323 */
g_assert (!strcmp (format, "%.40e"));
return snprintf (buffer, bufferLength, "%s", "1.9762625833649861767062751714728854894602e-323");
}
#endif
return snprintf(buffer, bufferLength, format, value);
}
static gboolean
add_modifier_to_array (MonoType *type, MonoArrayHandle dest, int dest_idx, MonoError *error)
{
HANDLE_FUNCTION_ENTER ();
MonoClass *klass = mono_class_from_mono_type_internal (type);
MonoReflectionTypeHandle rt;
rt = mono_type_get_object_handle (m_class_get_byval_arg (klass), error);
goto_if_nok (error, leave);
MONO_HANDLE_ARRAY_SETREF (dest, dest_idx, rt);
leave:
HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
}
/*
* We return NULL for no modifiers so the corlib code can return Type.EmptyTypes
* and avoid useless allocations.
*/
static MonoArrayHandle
type_array_from_modifiers (MonoType *type, int optional, MonoError *error)
{
int i, count = 0;
int cmod_count = mono_type_custom_modifier_count (type);
if (cmod_count == 0)
goto fail;
for (i = 0; i < cmod_count; ++i) {
gboolean required;
(void) mono_type_get_custom_modifier (type, i, &required, error);
goto_if_nok (error, fail);
if ((optional && !required) || (!optional && required))
count++;
}
if (!count)
goto fail;
MonoArrayHandle res;
res = mono_array_new_handle (mono_defaults.systemtype_class, count, error);
goto_if_nok (error, fail);
count = 0;
for (i = 0; i < cmod_count; ++i) {
gboolean required;
MonoType *cmod_type = mono_type_get_custom_modifier (type, i, &required, error);
goto_if_nok (error, fail);
if ((optional && !required) || (!optional && required)) {
if (!add_modifier_to_array (cmod_type, res, count, error))
goto fail;
count++;
}
}
return res;
fail:
return MONO_HANDLE_NEW (MonoArray, NULL);
}
MonoArrayHandle
ves_icall_RuntimeParameterInfo_GetTypeModifiers (MonoReflectionTypeHandle rt, MonoObjectHandle member, int pos, MonoBoolean optional, MonoError *error)
{
MonoType *type = MONO_HANDLE_GETVAL (rt, type);
MonoClass *member_class = mono_handle_class (member);
MonoMethod *method = NULL;
MonoMethodSignature *sig;
if (mono_class_is_reflection_method_or_constructor (member_class)) {
method = MONO_HANDLE_GETVAL (MONO_HANDLE_CAST (MonoReflectionMethod, member), method);
} else if (m_class_get_image (member_class) == mono_defaults.corlib && !strcmp ("RuntimePropertyInfo", m_class_get_name (member_class))) {
MonoProperty *prop = MONO_HANDLE_GETVAL (MONO_HANDLE_CAST (MonoReflectionProperty, member), property);
if (!(method = prop->get))
method = prop->set;
g_assert (method);
} else if (strcmp (m_class_get_name (member_class), "DynamicMethod") == 0 && strcmp (m_class_get_name_space (member_class), "System.Reflection.Emit") == 0) {
MonoArrayHandle params = MONO_HANDLE_NEW_GET (MonoArray, MONO_HANDLE_CAST (MonoReflectionDynamicMethod, member), parameters);
MonoReflectionTypeHandle t = MONO_HANDLE_NEW (MonoReflectionType, NULL);
MONO_HANDLE_ARRAY_GETREF (t, params, pos);
type = mono_reflection_type_handle_mono_type (t, error);
return type_array_from_modifiers (type, optional, error);
} else {
char *type_name = mono_type_get_full_name (member_class);
mono_error_set_not_supported (error, "Custom modifiers on a ParamInfo with member %s are not supported", type_name);
g_free (type_name);
return NULL_HANDLE_ARRAY;
}
sig = mono_method_signature_internal (method);
if (pos == -1)
type = sig->ret;
else
type = sig->params [pos];
return type_array_from_modifiers (type, optional, error);
}
static MonoType*
get_property_type (MonoProperty *prop)
{
MonoMethodSignature *sig;
if (prop->get) {
sig = mono_method_signature_internal (prop->get);
return sig->ret;
} else if (prop->set) {
sig = mono_method_signature_internal (prop->set);
return sig->params [sig->param_count - 1];
}
return NULL;
}
MonoArrayHandle
ves_icall_RuntimePropertyInfo_GetTypeModifiers (MonoReflectionPropertyHandle property, MonoBoolean optional, MonoError *error)
{
MonoProperty *prop = MONO_HANDLE_GETVAL (property, property);
MonoType *type = get_property_type (prop);
if (!type)
return NULL_HANDLE_ARRAY;
return type_array_from_modifiers (type, optional, error);
}
/*
*Construct a MonoType suited to be used to decode a constant blob object.
*
* @type is the target type which will be constructed
* @blob_type is the blob type, for example, that comes from the constant table
* @real_type is the expected constructed type.
*/
static void
mono_type_from_blob_type (MonoType *type, MonoTypeEnum blob_type, MonoType *real_type)
{
type->type = blob_type;
type->data.klass = NULL;
if (blob_type == MONO_TYPE_CLASS)
type->data.klass = mono_defaults.object_class;
else if (real_type->type == MONO_TYPE_VALUETYPE && m_class_is_enumtype (real_type->data.klass)) {
/* For enums, we need to use the base type */
type->type = MONO_TYPE_VALUETYPE;
type->data.klass = mono_class_from_mono_type_internal (real_type);
} else
type->data.klass = mono_class_from_mono_type_internal (real_type);
}
MonoObjectHandle
ves_icall_property_info_get_default_value (MonoReflectionPropertyHandle property_handle, MonoError* error)
{
MonoReflectionProperty* property = MONO_HANDLE_RAW (property_handle);
MonoType blob_type;
MonoProperty *prop = property->property;
MonoType *type = get_property_type (prop);
MonoTypeEnum def_type;
const char *def_value;
mono_class_init_internal (prop->parent);
if (!(prop->attrs & PROPERTY_ATTRIBUTE_HAS_DEFAULT)) {
mono_error_set_invalid_operation (error, NULL);
return NULL_HANDLE;
}
def_value = mono_class_get_property_default_value (prop, &def_type);
mono_type_from_blob_type (&blob_type, def_type, type);
return mono_get_object_from_blob (&blob_type, def_value, MONO_HANDLE_NEW (MonoString, NULL), error);
}
MonoBoolean
ves_icall_MonoCustomAttrs_IsDefinedInternal (MonoObjectHandle obj, MonoReflectionTypeHandle attr_type, MonoError *error)
{
MonoClass *attr_class = mono_class_from_mono_type_internal (MONO_HANDLE_GETVAL (attr_type, type));
mono_class_init_checked (attr_class, error);
return_val_if_nok (error, FALSE);
MonoCustomAttrInfo *cinfo = mono_reflection_get_custom_attrs_info_checked (obj, error);
return_val_if_nok (error, FALSE);
if (!cinfo)
return FALSE;
gboolean found = mono_custom_attrs_has_attr (cinfo, attr_class);
if (!cinfo->cached)
mono_custom_attrs_free (cinfo);
return found;
}
MonoArrayHandle
ves_icall_MonoCustomAttrs_GetCustomAttributesInternal (MonoObjectHandle obj, MonoReflectionTypeHandle attr_type, MonoBoolean pseudoattrs, MonoError *error)
{
MonoClass *attr_class;
if (MONO_HANDLE_IS_NULL (attr_type))
attr_class = NULL;
else
attr_class = mono_class_from_mono_type_internal (MONO_HANDLE_GETVAL (attr_type, type));
if (attr_class) {
mono_class_init_checked (attr_class, error);
return_val_if_nok (error, NULL_HANDLE_ARRAY);
}
return mono_reflection_get_custom_attrs_by_type_handle (obj, attr_class, error);
}
MonoArrayHandle
ves_icall_MonoCustomAttrs_GetCustomAttributesDataInternal (MonoObjectHandle obj, MonoError *error)
{
return mono_reflection_get_custom_attrs_data_checked (obj, error);
}
#ifndef DISABLE_COM
int
ves_icall_System_Runtime_InteropServices_Marshal_GetHRForException_WinRT(MonoExceptionHandle ex, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.Marshal.GetHRForException_WinRT internal call is not implemented.");
return 0;
}
MonoObjectHandle
ves_icall_System_Runtime_InteropServices_Marshal_GetNativeActivationFactory(MonoObjectHandle type, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.Marshal.GetNativeActivationFactory internal call is not implemented.");
return NULL_HANDLE;
}
void*
ves_icall_System_Runtime_InteropServices_Marshal_GetRawIUnknownForComObjectNoAddRef(MonoObjectHandle obj, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.Marshal.GetRawIUnknownForComObjectNoAddRef internal call is not implemented.");
return NULL;
}
MonoObjectHandle
ves_icall_System_Runtime_InteropServices_WindowsRuntime_UnsafeNativeMethods_GetRestrictedErrorInfo(MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.WindowsRuntime.UnsafeNativeMethods.GetRestrictedErrorInfo internal call is not implemented.");
return NULL_HANDLE;
}
MonoBoolean
ves_icall_System_Runtime_InteropServices_WindowsRuntime_UnsafeNativeMethods_RoOriginateLanguageException (int ierr, MonoStringHandle message, void* languageException, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.WindowsRuntime.UnsafeNativeMethods.RoOriginateLanguageException internal call is not implemented.");
return FALSE;
}
void
ves_icall_System_Runtime_InteropServices_WindowsRuntime_UnsafeNativeMethods_RoReportUnhandledError (MonoObjectHandle oerr, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.WindowsRuntime.UnsafeNativeMethods.RoReportUnhandledError internal call is not implemented.");
}
int
ves_icall_System_Runtime_InteropServices_WindowsRuntime_UnsafeNativeMethods_WindowsCreateString(MonoStringHandle sourceString, int length, void** hstring, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.WindowsRuntime.UnsafeNativeMethods.WindowsCreateString internal call is not implemented.");
return 0;
}
int
ves_icall_System_Runtime_InteropServices_WindowsRuntime_UnsafeNativeMethods_WindowsDeleteString(void* hstring, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.WindowsRuntime.UnsafeNativeMethods.WindowsDeleteString internal call is not implemented.");
return 0;
}
mono_unichar2*
ves_icall_System_Runtime_InteropServices_WindowsRuntime_UnsafeNativeMethods_WindowsGetStringRawBuffer(void* hstring, unsigned* length, MonoError *error)
{
mono_error_set_not_implemented (error, "System.Runtime.InteropServices.WindowsRuntime.UnsafeNativeMethods.WindowsGetStringRawBuffer internal call is not implemented.");
return NULL;
}
#endif
static const MonoIcallTableCallbacks *icall_table;
static mono_mutex_t icall_mutex;
static GHashTable *icall_hash = NULL;
typedef struct _MonoIcallHashTableValue {
gconstpointer method;
guint32 flags;
} MonoIcallHashTableValue;
void
mono_install_icall_table_callbacks (const MonoIcallTableCallbacks *cb)
{
g_assert (cb->version == MONO_ICALL_TABLE_CALLBACKS_VERSION);
icall_table = cb;
}
void
mono_icall_init (void)
{
#ifndef DISABLE_ICALL_TABLES
mono_icall_table_init ();
#endif
icall_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
mono_os_mutex_init (&icall_mutex);
}
static void
mono_icall_lock (void)
{
mono_locks_os_acquire (&icall_mutex, IcallLock);
}
static void
mono_icall_unlock (void)
{
mono_locks_os_release (&icall_mutex, IcallLock);
}
static void
add_internal_call_with_flags (const char *name, gconstpointer method, guint32 flags)
{
char *key = g_strdup (name);
MonoIcallHashTableValue *value = g_new (MonoIcallHashTableValue, 1);
if (key && value) {
value->method = method;
value->flags = flags;
mono_icall_lock ();
g_hash_table_insert (icall_hash, key, (gpointer)value);
mono_icall_unlock ();
}
}
/**
* mono_dangerous_add_internal_call_coop:
* \param name method specification to surface to the managed world
* \param method pointer to a C method to invoke when the method is called
*
* Similar to \c mono_dangerous_add_raw_internal_call.
*
*/
void
mono_dangerous_add_internal_call_coop (const char *name, gconstpointer method)
{
add_internal_call_with_flags (name, method, MONO_ICALL_FLAGS_COOPERATIVE);
}
/**
* mono_dangerous_add_internal_call_no_wrapper:
* \param name method specification to surface to the managed world
* \param method pointer to a C method to invoke when the method is called
*
* Similar to \c mono_dangerous_add_raw_internal_call but with more requirements for correct
* operation.
*
* The \p method must NOT:
*
* Run for an unbounded amount of time without calling the mono runtime.
* Additionally, the method must switch to GC Safe mode to perform all blocking
* operations: performing blocking I/O, taking locks, etc. The method can't throw or raise
* exceptions or call other methods that will throw or raise exceptions since the runtime won't
* be able to detect exeptions and unwinder won't be able to correctly find last managed frame in callstack.
* This registration method is for icalls that needs very low overhead and follow all rules in their implementation.
*
*/
void
mono_dangerous_add_internal_call_no_wrapper (const char *name, gconstpointer method)
{
add_internal_call_with_flags (name, method, MONO_ICALL_FLAGS_NO_WRAPPER);
}
/**
* mono_add_internal_call:
* \param name method specification to surface to the managed world
* \param method pointer to a C method to invoke when the method is called
*
* This method surfaces the C function pointed by \p method as a method
* that has been surfaced in managed code with the method specified in
* \p name as an internal call.
*
* Internal calls are surfaced to all app domains loaded and they are
* accessibly by a type with the specified name.
*
* You must provide a fully qualified type name, that is namespaces
* and type name, followed by a colon and the method name, with an
* optional signature to bind.
*
* For example, the following are all valid declarations:
*
* \c MyApp.Services.ScriptService:Accelerate
*
* \c MyApp.Services.ScriptService:Slowdown(int,bool)
*
* You use method parameters in cases where there might be more than
* one surface method to managed code. That way you can register different
* internal calls for different method overloads.
*
* The internal calls are invoked with no marshalling. This means that .NET
* types like \c System.String are exposed as \c MonoString* parameters. This is
* different than the way that strings are surfaced in P/Invoke.
*
* For more information on how the parameters are marshalled, see the
* <a href="http://www.mono-project.com/docs/advanced/embedding/">Mono Embedding</a>
* page.
*
* See the <a href="mono-api-methods.html#method-desc">Method Description</a>
* reference for more information on the format of method descriptions.
*/
void
mono_add_internal_call (const char *name, gconstpointer method)
{
add_internal_call_with_flags (name, method, MONO_ICALL_FLAGS_FOREIGN);
}
/**
* mono_dangerous_add_raw_internal_call:
* \param name method specification to surface to the managed world
* \param method pointer to a C method to invoke when the method is called
*
* Similar to \c mono_add_internal_call but with more requirements for correct
* operation.
*
* A thread running a dangerous raw internal call will avoid a thread state
* transition on entry and exit, but it must take responsiblity for cooperating
* with the Mono runtime.
*
* The \p method must NOT:
*
* Run for an unbounded amount of time without calling the mono runtime.
* Additionally, the method must switch to GC Safe mode to perform all blocking
* operations: performing blocking I/O, taking locks, etc.
*
*/
void
mono_dangerous_add_raw_internal_call (const char *name, gconstpointer method)
{
add_internal_call_with_flags (name, method, MONO_ICALL_FLAGS_COOPERATIVE);
}
/**
* mono_add_internal_call_with_flags:
* \param name method specification to surface to the managed world
* \param method pointer to a C method to invoke when the method is called
* \param cooperative if \c TRUE, run icall in GC Unsafe (cooperatively suspended) mode,
* otherwise GC Safe (blocking)
*
* Like \c mono_add_internal_call, but if \p cooperative is \c TRUE the added
* icall promises that it will use the coopertive API to inform the runtime
* when it is running blocking operations, that it will not run for unbounded
* amounts of time without safepointing, and that it will not hold managed
* object references across suspend safepoints.
*
* If \p cooperative is \c FALSE, run the icall in GC Safe mode - the icall may
* block. The icall must obey the GC Safe rules, e.g. it must not touch
* unpinned managed memory.
*
*/
void
mono_add_internal_call_with_flags (const char *name, gconstpointer method, gboolean cooperative)
{
add_internal_call_with_flags (name, method, cooperative ? MONO_ICALL_FLAGS_COOPERATIVE : MONO_ICALL_FLAGS_FOREIGN);
}
void
mono_add_internal_call_internal (const char *name, gconstpointer method)
{
add_internal_call_with_flags (name, method, MONO_ICALL_FLAGS_COOPERATIVE);
}
/*
* we should probably export this as an helper (handle nested types).
* Returns the number of chars written in buf.
*/
static int
concat_class_name (char *buf, int bufsize, MonoClass *klass)
{
int nspacelen, cnamelen;
nspacelen = strlen (m_class_get_name_space (klass));
cnamelen = strlen (m_class_get_name (klass));
if (nspacelen + cnamelen + 2 > bufsize)
return 0;
if (nspacelen) {
memcpy (buf, m_class_get_name_space (klass), nspacelen);
buf [nspacelen ++] = '.';
}
memcpy (buf + nspacelen, m_class_get_name (klass), cnamelen);
buf [nspacelen + cnamelen] = 0;
return nspacelen + cnamelen;
}
static void
no_icall_table (void)
{
g_assert_not_reached ();
}
gboolean
mono_is_missing_icall_addr (gconstpointer addr)
{
return addr == NULL || addr == no_icall_table;
}
/*
* Returns either NULL or no_icall_table for missing icalls.
*/
gconstpointer
mono_lookup_internal_call_full_with_flags (MonoMethod *method, gboolean warn_on_missing, guint32 *flags)
{
char *sigstart = NULL;
char *tmpsig = NULL;
char mname [2048];
char *classname = NULL;
int typelen = 0, mlen, siglen;
gconstpointer res = NULL;
gboolean locked = FALSE;
g_assert (method != NULL);
if (method->is_inflated)
method = ((MonoMethodInflated *) method)->declaring;
if (m_class_get_nested_in (method->klass)) {
int pos = concat_class_name (mname, sizeof (mname)-2, m_class_get_nested_in (method->klass));
if (!pos)
goto exit;
mname [pos++] = '/';
mname [pos] = 0;
typelen = concat_class_name (mname+pos, sizeof (mname)-pos-1, method->klass);
if (!typelen)
goto exit;
typelen += pos;
} else {
typelen = concat_class_name (mname, sizeof (mname), method->klass);
if (!typelen)
goto exit;
}
classname = g_strdup (mname);
mname [typelen] = ':';
mname [typelen + 1] = ':';
mlen = strlen (method->name);
memcpy (mname + typelen + 2, method->name, mlen);
sigstart = mname + typelen + 2 + mlen;
*sigstart = 0;
tmpsig = mono_signature_get_desc (mono_method_signature_internal (method), TRUE);
siglen = strlen (tmpsig);
if (typelen + mlen + siglen + 6 > sizeof (mname))
goto exit;
sigstart [0] = '(';
memcpy (sigstart + 1, tmpsig, siglen);
sigstart [siglen + 1] = ')';
sigstart [siglen + 2] = 0;
/* mono_marshal_get_native_wrapper () depends on this */
if (method->klass == mono_defaults.string_class && !strcmp (method->name, ".ctor")) {
res = (gconstpointer)ves_icall_System_String_ctor_RedirectToCreateString;
goto exit;
}
mono_icall_lock ();
locked = TRUE;
res = g_hash_table_lookup (icall_hash, mname);
if (res) {
MonoIcallHashTableValue *value = (MonoIcallHashTableValue *)res;
if (flags)
*flags = value->flags;
res = value->method;
goto exit;
}
/* try without signature */
*sigstart = 0;
res = g_hash_table_lookup (icall_hash, mname);
if (res) {
MonoIcallHashTableValue *value = (MonoIcallHashTableValue *)res;
if (flags)
*flags = value->flags;
res = value->method;
goto exit;
}
if (!icall_table) {
/* Fail only when the result is actually used */
res = (gconstpointer)no_icall_table;
goto exit;
} else {
gboolean uses_handles = FALSE;
g_assert (icall_table->lookup);
res = icall_table->lookup (method, classname, sigstart - mlen, sigstart, &uses_handles);
if (res && flags && uses_handles)
*flags = *flags | MONO_ICALL_FLAGS_USES_HANDLES;
mono_icall_unlock ();
locked = FALSE;
if (res)
goto exit;
if (warn_on_missing) {
g_warning ("cant resolve internal call to \"%s\" (tested without signature also)", mname);
g_print ("\nYour mono runtime and class libraries are out of sync.\n");
g_print ("The out of sync library is: %s\n", m_class_get_image (method->klass)->name);
g_print ("\nWhen you update one from git you need to update, compile and install\nthe other too.\n");
g_print ("Do not report this as a bug unless you're sure you have updated correctly:\nyou probably have a broken mono install.\n");
g_print ("If you see other errors or faults after this message they are probably related\n");
g_print ("and you need to fix your mono install first.\n");
}
res = NULL;
}
exit:
if (locked)
mono_icall_unlock ();
g_free (classname);
g_free (tmpsig);
return res;
}
/**
* mono_lookup_internal_call_full:
* \param method the method to look up
* \param uses_handles out argument if method needs handles around managed objects.
* \returns a pointer to the icall code for the given method. If
* \p uses_handles is not NULL, it will be set to TRUE if the method
* needs managed objects wrapped using the infrastructure in handle.h
*
* If the method is not found, warns and returns NULL.
*/
gconstpointer
mono_lookup_internal_call_full (MonoMethod *method, gboolean warn_on_missing, mono_bool *uses_handles, mono_bool *foreign)
{
if (uses_handles)
*uses_handles = FALSE;
if (foreign)
*foreign = FALSE;
guint32 flags = MONO_ICALL_FLAGS_NONE;
gconstpointer addr = mono_lookup_internal_call_full_with_flags (method, warn_on_missing, &flags);
if (uses_handles && (flags & MONO_ICALL_FLAGS_USES_HANDLES))
*uses_handles = TRUE;
if (foreign && (flags & MONO_ICALL_FLAGS_FOREIGN))
*foreign = TRUE;
return addr;
}
/**
* mono_lookup_internal_call:
*/
gpointer
mono_lookup_internal_call (MonoMethod *method)
{
return (gpointer)mono_lookup_internal_call_full (method, TRUE, NULL, NULL);
}
/*
* mono_lookup_icall_symbol:
*
* Given the icall METHOD, returns its C symbol.
*/
const char*
mono_lookup_icall_symbol (MonoMethod *m)
{
if (!icall_table)
return NULL;
g_assert (icall_table->lookup_icall_symbol);
gpointer func;
func = (gpointer)mono_lookup_internal_call_full (m, FALSE, NULL, NULL);
if (!func)
return NULL;
return icall_table->lookup_icall_symbol (func);
}
#if defined(TARGET_WIN32) && defined(TARGET_X86)
/*
* Under windows, the default pinvoke calling convention is STDCALL but
* we need CDECL.
*/
#define MONO_ICALL_SIGNATURE_CALL_CONVENTION MONO_CALL_C
#else
#define MONO_ICALL_SIGNATURE_CALL_CONVENTION 0
#endif
// Storage for these enums is pointer-sized as it gets replaced with MonoType*.
//
// mono_create_icall_signatures depends on this order. Handle with care.
typedef enum ICallSigType {
ICALL_SIG_TYPE_bool = 0x00,
ICALL_SIG_TYPE_boolean = ICALL_SIG_TYPE_bool,
ICALL_SIG_TYPE_double = 0x01,
ICALL_SIG_TYPE_float = 0x02,
ICALL_SIG_TYPE_int = 0x03,
ICALL_SIG_TYPE_int16 = 0x04,
ICALL_SIG_TYPE_int32 = ICALL_SIG_TYPE_int,
ICALL_SIG_TYPE_int8 = 0x05,
ICALL_SIG_TYPE_long = 0x06,
ICALL_SIG_TYPE_obj = 0x07,
ICALL_SIG_TYPE_object = ICALL_SIG_TYPE_obj,
ICALL_SIG_TYPE_ptr = 0x08,
ICALL_SIG_TYPE_ptrref = 0x09,
ICALL_SIG_TYPE_string = 0x0A,
ICALL_SIG_TYPE_uint16 = 0x0B,
ICALL_SIG_TYPE_uint32 = 0x0C,
ICALL_SIG_TYPE_uint8 = 0x0D,
ICALL_SIG_TYPE_ulong = 0x0E,
ICALL_SIG_TYPE_void = 0x0F,
ICALL_SIG_TYPE_sizet = 0x10
} ICallSigType;
#define ICALL_SIG_TYPES_1(a) ICALL_SIG_TYPE_ ## a,
#define ICALL_SIG_TYPES_2(a, b) ICALL_SIG_TYPES_1 (a ) ICALL_SIG_TYPES_1 (b)
#define ICALL_SIG_TYPES_3(a, b, c) ICALL_SIG_TYPES_2 (a, b ) ICALL_SIG_TYPES_1 (c)
#define ICALL_SIG_TYPES_4(a, b, c, d) ICALL_SIG_TYPES_3 (a, b, c ) ICALL_SIG_TYPES_1 (d)
#define ICALL_SIG_TYPES_5(a, b, c, d, e) ICALL_SIG_TYPES_4 (a, b, c, d ) ICALL_SIG_TYPES_1 (e)
#define ICALL_SIG_TYPES_6(a, b, c, d, e, f) ICALL_SIG_TYPES_5 (a, b, c, d, e) ICALL_SIG_TYPES_1 (f)
#define ICALL_SIG_TYPES_7(a, b, c, d, e, f, g) ICALL_SIG_TYPES_6 (a, b, c, d, e, f) ICALL_SIG_TYPES_1 (g)
#define ICALL_SIG_TYPES_8(a, b, c, d, e, f, g, h) ICALL_SIG_TYPES_7 (a, b, c, d, e, f, g) ICALL_SIG_TYPES_1 (h)
#define ICALL_SIG_TYPES(n, types) ICALL_SIG_TYPES_ ## n types
// A scheme to make these const would be nice.
static struct {
#define ICALL_SIG(n, xtypes) \
struct { \
MonoMethodSignature sig; \
gsize types [n]; \
} ICALL_SIG_NAME (n, xtypes);
ICALL_SIGS
MonoMethodSignature end; // terminal zeroed element
} mono_icall_signatures = {
#undef ICALL_SIG
#define ICALL_SIG(n, types) { { \
0, /* ret */ \
n, /* param_count */ \
-1, /* sentinelpos */ \
0, /* generic_param_count */ \
MONO_ICALL_SIGNATURE_CALL_CONVENTION, \
0, /* hasthis */ \
0, /* explicit_this */ \
1, /* pinvoke */ \
0, /* is_inflated */ \
0, /* has_type_parameters */ \
}, /* possible gap here, depending on MONO_ZERO_LEN_ARRAY */ \
{ ICALL_SIG_TYPES (n, types) } }, /* params and ret */
ICALL_SIGS
};
#undef ICALL_SIG
#define ICALL_SIG(n, types) MonoMethodSignature * const ICALL_SIG_NAME (n, types) = &mono_icall_signatures.ICALL_SIG_NAME (n, types).sig;
ICALL_SIGS
#undef ICALL_SIG
void
mono_create_icall_signatures (void)
{
// Fixup the mostly statically initialized icall signatures.
// x = m_class_get_byval_arg (x)
// Initialize ret with params [0] and params [i] with params [i + 1].
// ptrref is special
//
// FIXME This is a bit obscure.
typedef MonoMethodSignature G_MAY_ALIAS MonoMethodSignature_a;
typedef gsize G_MAY_ALIAS gsize_a;
MonoType * const lookup [ ] = {
m_class_get_byval_arg (mono_defaults.boolean_class), // ICALL_SIG_TYPE_bool
m_class_get_byval_arg (mono_defaults.double_class), // ICALL_SIG_TYPE_double
m_class_get_byval_arg (mono_defaults.single_class), // ICALL_SIG_TYPE_float
m_class_get_byval_arg (mono_defaults.int32_class), // ICALL_SIG_TYPE_int
m_class_get_byval_arg (mono_defaults.int16_class), // ICALL_SIG_TYPE_int16
m_class_get_byval_arg (mono_defaults.sbyte_class), // ICALL_SIG_TYPE_int8
m_class_get_byval_arg (mono_defaults.int64_class), // ICALL_SIG_TYPE_long
m_class_get_byval_arg (mono_defaults.object_class), // ICALL_SIG_TYPE_obj
m_class_get_byval_arg (mono_defaults.int_class), // ICALL_SIG_TYPE_ptr
mono_class_get_byref_type (mono_defaults.int_class), // ICALL_SIG_TYPE_ptrref
m_class_get_byval_arg (mono_defaults.string_class), // ICALL_SIG_TYPE_string
m_class_get_byval_arg (mono_defaults.uint16_class), // ICALL_SIG_TYPE_uint16
m_class_get_byval_arg (mono_defaults.uint32_class), // ICALL_SIG_TYPE_uint32
m_class_get_byval_arg (mono_defaults.byte_class), // ICALL_SIG_TYPE_uint8
m_class_get_byval_arg (mono_defaults.uint64_class), // ICALL_SIG_TYPE_ulong
m_class_get_byval_arg (mono_defaults.void_class), // ICALL_SIG_TYPE_void
m_class_get_byval_arg (mono_defaults.int_class), // ICALL_SIG_TYPE_sizet
};
MonoMethodSignature_a *sig = (MonoMethodSignature*)&mono_icall_signatures;
int n;
while ((n = sig->param_count)) {
--sig->param_count; // remove ret
gsize_a *types = (gsize_a*)(sig + 1);
for (int i = 0; i < n; ++i) {
gsize index = *types++;
g_assert (index < G_N_ELEMENTS (lookup));
// Casts on next line are attempt to follow strict aliasing rules,
// to ensure reading from *types precedes writing
// to params [].
*(gsize*)(i ? &sig->params [i - 1] : &sig->ret) = (gsize)lookup [index];
}
sig = (MonoMethodSignature*)types;
}
}
void
mono_register_jit_icall_info (MonoJitICallInfo *info, gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean avoid_wrapper, const char *c_symbol)
{
// Duplicate initialization is allowed and racy, assuming it is equivalent.
info->name = name;
info->func = func;
info->sig = sig;
info->c_symbol = c_symbol;
// Fill in wrapper ahead of time, to just be func, to avoid
// later initializing it to anything else. So therefore, no wrapper.
if (avoid_wrapper) {
info->wrapper = func;
} else {
// Leave it alone in case of a race.
}
}
int
ves_icall_System_GC_GetCollectionCount (int generation)
{
return mono_gc_collection_count (generation);
}
int
ves_icall_System_GC_GetGeneration (MonoObjectHandle object, MonoError *error)
{
return mono_gc_get_generation (MONO_HANDLE_RAW (object));
}
int
ves_icall_System_GC_GetMaxGeneration (void)
{
return mono_gc_max_generation ();
}
gint64
ves_icall_System_GC_GetAllocatedBytesForCurrentThread (void)
{
return mono_gc_get_allocated_bytes_for_current_thread ();
}
guint64
ves_icall_System_GC_GetTotalAllocatedBytes (MonoBoolean precise, MonoError* error)
{
return mono_gc_get_total_allocated_bytes (precise);
}
void
ves_icall_System_GC_RecordPressure (gint64 value)
{
mono_gc_add_memory_pressure (value);
}
MonoBoolean
ves_icall_System_Threading_Thread_YieldInternal (void)
{
mono_threads_platform_yield ();
return TRUE;
}
gint32
ves_icall_System_Environment_get_ProcessorCount (void)
{
return mono_cpu_count ();
}
// Generate wrappers.
#define ICALL_TYPE(id,name,first) /* nothing */
#define ICALL(id,name,func) /* nothing */
#define NOHANDLES(inner) /* nothing */
#define MONO_HANDLE_REGISTER_ICALL(func, ret, nargs, argtypes) MONO_HANDLE_REGISTER_ICALL_IMPLEMENT (func, ret, nargs, argtypes)
// Some native functions are exposed via multiple managed names.
// Producing a wrapper for these results in duplicate wrappers with the same names,
// which fails to compile. Do not produce such duplicate wrappers. Alternatively,
// a one line native function with a different name that calls the main one could be used.
// i.e. the wrapper would also have a different name.
#define HANDLES_REUSE_WRAPPER(...) /* nothing */
#define HANDLES(id, name, func, ret, nargs, argtypes) \
MONO_HANDLE_DECLARE (id, name, func, ret, nargs, argtypes); \
MONO_HANDLE_IMPLEMENT (id, name, func, ret, nargs, argtypes)
#include "metadata/icall-def.h"
#undef HANDLES
#undef HANDLES_REUSE_WRAPPER
#undef ICALL_TYPE
#undef ICALL
#undef NOHANDLES
#undef MONO_HANDLE_REGISTER_ICALL
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/utils/mono-threads-aix.c | /**
* \file
*/
#include <config.h>
#if defined(_AIX)
#include <mono/utils/mono-threads.h>
#include <pthread.h>
void
mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize)
{
/* see GC_push_all_stacks in libgc/aix_irix_threads.c
for why we do this; pthread_getattr_np exists only
on some versions of AIX and not on PASE, so use a
legacy way to get the stack information */
struct __pthrdsinfo pi;
pthread_t pt;
int res, rbv, ps;
char rb[255];
pt = pthread_self();
ps = sizeof(pi);
rbv = sizeof(rb);
*staddr = NULL;
*stsize = (size_t)-1;
res = pthread_getthrds_np(&pt, PTHRDSINFO_QUERY_ALL, &pi, ps, rb, &rbv);
/* FIXME: are these the right values? */
*staddr = (guint8*)pi.__pi_stackaddr;
/*
* ruby doesn't use stacksize; see:
* github.com/ruby/ruby/commit/a2594be783c727c6034308f5294333752c3845bb
*/
*stsize = pi.__pi_stackend - pi.__pi_stackaddr;
}
gboolean
mono_threads_platform_is_main_thread (void)
{
/* returns 1 on main thread, even if the kernel tid is diff */
return pthread_self () == 1;
}
guint64
mono_native_thread_os_id_get (void)
{
pthread_t t = pthread_self ();
struct __pthrdsinfo ti;
int err, size = 0;
err = pthread_getthrds_np (&t, PTHRDSINFO_QUERY_TID, &ti, sizeof (struct __pthrdsinfo), NULL, &size);
return (guint64)ti.__pi_tid;
}
#else
#include <mono/utils/mono-compiler.h>
MONO_EMPTY_SOURCE_FILE (mono_threads_aix);
#endif
| /**
* \file
*/
#include <config.h>
#if defined(_AIX)
#include <mono/utils/mono-threads.h>
#include <pthread.h>
void
mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize)
{
/* see GC_push_all_stacks in libgc/aix_irix_threads.c
for why we do this; pthread_getattr_np exists only
on some versions of AIX and not on PASE, so use a
legacy way to get the stack information */
struct __pthrdsinfo pi;
pthread_t pt;
int res, rbv, ps;
char rb[255];
pt = pthread_self();
ps = sizeof(pi);
rbv = sizeof(rb);
*staddr = NULL;
*stsize = (size_t)-1;
res = pthread_getthrds_np(&pt, PTHRDSINFO_QUERY_ALL, &pi, ps, rb, &rbv);
/* FIXME: are these the right values? */
*staddr = (guint8*)pi.__pi_stackaddr;
/*
* ruby doesn't use stacksize; see:
* github.com/ruby/ruby/commit/a2594be783c727c6034308f5294333752c3845bb
*/
*stsize = pi.__pi_stackend - pi.__pi_stackaddr;
}
gboolean
mono_threads_platform_is_main_thread (void)
{
/* returns 1 on main thread, even if the kernel tid is diff */
return pthread_self () == 1;
}
guint64
mono_native_thread_os_id_get (void)
{
pthread_t t = pthread_self ();
struct __pthrdsinfo ti;
int err, size = 0;
err = pthread_getthrds_np (&t, PTHRDSINFO_QUERY_TID, &ti, sizeof (struct __pthrdsinfo), NULL, &size);
return (guint64)ti.__pi_tid;
}
#else
#include <mono/utils/mono-compiler.h>
MONO_EMPTY_SOURCE_FILE (mono_threads_aix);
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/src/loongarch64/Lcreate_addr_space.c | #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gcreate_addr_space.c"
#endif
| #define UNW_LOCAL_ONLY
#include <libunwind.h>
#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
#include "Gcreate_addr_space.c"
#endif
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/pal/src/libunwind/tests/test-ptrace.c | /* libunwind - a platform-independent unwind library
Copyright (C) 2003-2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <config.h>
#ifdef HAVE_TTRACE
int
main (void)
{
printf ("FAILURE: ttrace() not supported yet\n");
return -1;
}
#else /* !HAVE_TTRACE */
#include <errno.h>
#include <fcntl.h>
#include <libunwind-ptrace.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
extern char **environ;
static const int nerrors_max = 100;
int nerrors;
int verbose;
int print_names = 1;
enum
{
INSTRUCTION,
SYSCALL,
TRIGGER
}
trace_mode = SYSCALL;
#define panic(args...) \
do { fprintf (stderr, args); ++nerrors; } while (0)
static unw_addr_space_t as;
static struct UPT_info *ui;
static int killed;
void
do_backtrace (void)
{
unw_word_t ip, sp, start_ip = 0, off;
int n = 0, ret;
unw_proc_info_t pi;
unw_cursor_t c;
char buf[512];
size_t len;
ret = unw_init_remote (&c, as, ui);
if (ret < 0)
panic ("unw_init_remote() failed: ret=%d\n", ret);
do
{
if ((ret = unw_get_reg (&c, UNW_REG_IP, &ip)) < 0
|| (ret = unw_get_reg (&c, UNW_REG_SP, &sp)) < 0)
panic ("unw_get_reg/unw_get_proc_name() failed: ret=%d\n", ret);
if (n == 0)
start_ip = ip;
buf[0] = '\0';
if (print_names)
unw_get_proc_name (&c, buf, sizeof (buf), &off);
if (verbose)
{
if (off)
{
len = strlen (buf);
if (len >= sizeof (buf) - 32)
len = sizeof (buf) - 32;
sprintf (buf + len, "+0x%lx", (unsigned long) off);
}
printf ("%016lx %-32s (sp=%016lx)\n", (long) ip, buf, (long) sp);
}
if ((ret = unw_get_proc_info (&c, &pi)) < 0)
panic ("unw_get_proc_info(ip=0x%lx) failed: ret=%d\n", (long) ip, ret);
else if (verbose)
printf ("\tproc=%016lx-%016lx\n\thandler=%lx lsda=%lx",
(long) pi.start_ip, (long) pi.end_ip,
(long) pi.handler, (long) pi.lsda);
#if UNW_TARGET_IA64
{
unw_word_t bsp;
if ((ret = unw_get_reg (&c, UNW_IA64_BSP, &bsp)) < 0)
panic ("unw_get_reg() failed: ret=%d\n", ret);
else if (verbose)
printf (" bsp=%lx", bsp);
}
#endif
if (verbose)
printf ("\n");
ret = unw_step (&c);
if (ret < 0)
{
unw_get_reg (&c, UNW_REG_IP, &ip);
panic ("FAILURE: unw_step() returned %d for ip=%lx (start ip=%lx)\n",
ret, (long) ip, (long) start_ip);
}
if (++n > 64)
{
/* guard against bad unwind info in old libraries... */
panic ("too deeply nested---assuming bogus unwind (start ip=%lx)\n",
(long) start_ip);
break;
}
if (nerrors > nerrors_max)
{
panic ("Too many errors (%d)!\n", nerrors);
break;
}
}
while (ret > 0);
if (ret < 0)
panic ("unwind failed with ret=%d\n", ret);
if (verbose)
printf ("================\n\n");
}
static pid_t target_pid;
static void target_pid_kill (void)
{
kill (target_pid, SIGKILL);
}
int
main (int argc, char **argv)
{
int status, pid, pending_sig, optind = 1, state = 1;
as = unw_create_addr_space (&_UPT_accessors, 0);
if (!as)
panic ("unw_create_addr_space() failed");
if (argc == 1)
{
static char *args[] = { "self", "ls", "/", NULL };
/* automated test case */
argv = args;
/* Unless the args array is 'walked' the child
process is unable to access it and dies with a segfault */
fprintf(stderr, "Automated test (%s,%s,%s,%s)\n",
args[0],args[1],args[2],args[3]);
}
else if (argc > 1)
while (argv[optind][0] == '-')
{
if (strcmp (argv[optind], "-v") == 0)
++optind, verbose = 1;
else if (strcmp (argv[optind], "-i") == 0)
++optind, trace_mode = INSTRUCTION; /* backtrace at each insn */
else if (strcmp (argv[optind], "-s") == 0)
++optind, trace_mode = SYSCALL; /* backtrace at each syscall */
else if (strcmp (argv[optind], "-t") == 0)
/* Execute until raise(SIGUSR1), then backtrace at each insn
until raise(SIGUSR2). */
++optind, trace_mode = TRIGGER;
else if (strcmp (argv[optind], "-c") == 0)
/* Enable caching of unwind-info. */
++optind, unw_set_caching_policy (as, UNW_CACHE_GLOBAL);
else if (strcmp (argv[optind], "-n") == 0)
/* Don't look-up and print symbol names. */
++optind, print_names = 0;
else
fprintf(stderr, "unrecognized option: %s\n", argv[optind++]);
if (optind >= argc)
break;
}
target_pid = fork ();
if (!target_pid)
{
/* child */
if (!verbose)
dup2 (open ("/dev/null", O_WRONLY), 1);
#if HAVE_DECL_PTRACE_TRACEME
ptrace (PTRACE_TRACEME, 0, 0, 0);
#elif HAVE_DECL_PT_TRACE_ME
ptrace (PT_TRACE_ME, 0, 0, 0);
#else
#error Trace me
#endif
if ((argc > 1) && (optind == argc)) {
fprintf(stderr, "Need to specify a command line for the child\n");
exit (-1);
}
#ifdef __FreeBSD__
execve (argv[optind], argv + optind, environ);
#else
execvpe (argv[optind], argv + optind, environ);
#endif
_exit (-1);
}
atexit (target_pid_kill);
ui = _UPT_create (target_pid);
while (nerrors <= nerrors_max)
{
pid = wait4 (-1, &status, 0, NULL);
if (pid == -1)
{
if (errno == EINTR)
continue;
panic ("wait4() failed (errno=%d)\n", errno);
}
pending_sig = 0;
if (WIFSIGNALED (status) || WIFEXITED (status)
|| (WIFSTOPPED (status) && WSTOPSIG (status) != SIGTRAP))
{
if (WIFEXITED (status))
{
if (WEXITSTATUS (status) != 0)
panic ("child's exit status %d\n", WEXITSTATUS (status));
break;
}
else if (WIFSIGNALED (status))
{
if (!killed)
panic ("child terminated by signal %d\n", WTERMSIG (status));
break;
}
else
{
pending_sig = WSTOPSIG (status);
/* Avoid deadlock: */
if (WSTOPSIG (status) == SIGKILL)
break;
if (trace_mode == TRIGGER)
{
if (WSTOPSIG (status) == SIGUSR1)
state = 0;
else if (WSTOPSIG (status) == SIGUSR2)
state = 1;
}
if (WSTOPSIG (status) != SIGUSR1 && WSTOPSIG (status) != SIGUSR2)
{
static int count = 0;
if (count++ > 100)
{
panic ("Too many child unexpected signals (now %d)\n",
WSTOPSIG (status));
killed = 1;
}
}
}
}
switch (trace_mode)
{
case TRIGGER:
if (state)
#if HAVE_DECL_PTRACE_CONT
ptrace (PTRACE_CONT, target_pid, 0, 0);
#elif HAVE_DECL_PT_CONTINUE
ptrace (PT_CONTINUE, target_pid, (caddr_t)1, 0);
#else
#error Port me
#endif
else
{
do_backtrace ();
#if HAVE_DECL_PTRACE_SINGLESTEP
if (ptrace (PTRACE_SINGLESTEP, target_pid, 0, pending_sig) < 0)
{
panic ("ptrace(PTRACE_SINGLESTEP) failed (errno=%d)\n", errno);
killed = 1;
}
#elif HAVE_DECL_PT_STEP
if (ptrace (PT_STEP, target_pid, (caddr_t)1, pending_sig) < 0)
{
panic ("ptrace(PT_STEP) failed (errno=%d)\n", errno);
killed = 1;
}
#else
#error Singlestep me
#endif
}
break;
case SYSCALL:
if (!state)
do_backtrace ();
state ^= 1;
#if HAVE_DECL_PTRACE_SYSCALL
ptrace (PTRACE_SYSCALL, target_pid, 0, pending_sig);
#elif HAVE_DECL_PT_SYSCALL
ptrace (PT_SYSCALL, target_pid, (caddr_t)1, pending_sig);
#else
#error Syscall me
#endif
break;
case INSTRUCTION:
do_backtrace ();
#if HAVE_DECL_PTRACE_SINGLESTEP
ptrace (PTRACE_SINGLESTEP, target_pid, 0, pending_sig);
#elif HAVE_DECL_PT_STEP
ptrace (PT_STEP, target_pid, (caddr_t)1, pending_sig);
#else
#error Singlestep me
#endif
break;
}
if (killed)
kill (target_pid, SIGKILL);
}
_UPT_destroy (ui);
unw_destroy_addr_space (as);
if (nerrors)
{
printf ("FAILURE: detected %d errors\n", nerrors);
exit (-1);
}
if (verbose)
printf ("SUCCESS\n");
return 0;
}
#endif /* !HAVE_TTRACE */
| /* libunwind - a platform-independent unwind library
Copyright (C) 2003-2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <[email protected]>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <config.h>
#ifdef HAVE_TTRACE
int
main (void)
{
printf ("FAILURE: ttrace() not supported yet\n");
return -1;
}
#else /* !HAVE_TTRACE */
#include <errno.h>
#include <fcntl.h>
#include <libunwind-ptrace.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
extern char **environ;
static const int nerrors_max = 100;
int nerrors;
int verbose;
int print_names = 1;
enum
{
INSTRUCTION,
SYSCALL,
TRIGGER
}
trace_mode = SYSCALL;
#define panic(args...) \
do { fprintf (stderr, args); ++nerrors; } while (0)
static unw_addr_space_t as;
static struct UPT_info *ui;
static int killed;
void
do_backtrace (void)
{
unw_word_t ip, sp, start_ip = 0, off;
int n = 0, ret;
unw_proc_info_t pi;
unw_cursor_t c;
char buf[512];
size_t len;
ret = unw_init_remote (&c, as, ui);
if (ret < 0)
panic ("unw_init_remote() failed: ret=%d\n", ret);
do
{
if ((ret = unw_get_reg (&c, UNW_REG_IP, &ip)) < 0
|| (ret = unw_get_reg (&c, UNW_REG_SP, &sp)) < 0)
panic ("unw_get_reg/unw_get_proc_name() failed: ret=%d\n", ret);
if (n == 0)
start_ip = ip;
buf[0] = '\0';
if (print_names)
unw_get_proc_name (&c, buf, sizeof (buf), &off);
if (verbose)
{
if (off)
{
len = strlen (buf);
if (len >= sizeof (buf) - 32)
len = sizeof (buf) - 32;
sprintf (buf + len, "+0x%lx", (unsigned long) off);
}
printf ("%016lx %-32s (sp=%016lx)\n", (long) ip, buf, (long) sp);
}
if ((ret = unw_get_proc_info (&c, &pi)) < 0)
panic ("unw_get_proc_info(ip=0x%lx) failed: ret=%d\n", (long) ip, ret);
else if (verbose)
printf ("\tproc=%016lx-%016lx\n\thandler=%lx lsda=%lx",
(long) pi.start_ip, (long) pi.end_ip,
(long) pi.handler, (long) pi.lsda);
#if UNW_TARGET_IA64
{
unw_word_t bsp;
if ((ret = unw_get_reg (&c, UNW_IA64_BSP, &bsp)) < 0)
panic ("unw_get_reg() failed: ret=%d\n", ret);
else if (verbose)
printf (" bsp=%lx", bsp);
}
#endif
if (verbose)
printf ("\n");
ret = unw_step (&c);
if (ret < 0)
{
unw_get_reg (&c, UNW_REG_IP, &ip);
panic ("FAILURE: unw_step() returned %d for ip=%lx (start ip=%lx)\n",
ret, (long) ip, (long) start_ip);
}
if (++n > 64)
{
/* guard against bad unwind info in old libraries... */
panic ("too deeply nested---assuming bogus unwind (start ip=%lx)\n",
(long) start_ip);
break;
}
if (nerrors > nerrors_max)
{
panic ("Too many errors (%d)!\n", nerrors);
break;
}
}
while (ret > 0);
if (ret < 0)
panic ("unwind failed with ret=%d\n", ret);
if (verbose)
printf ("================\n\n");
}
static pid_t target_pid;
static void target_pid_kill (void)
{
kill (target_pid, SIGKILL);
}
int
main (int argc, char **argv)
{
int status, pid, pending_sig, optind = 1, state = 1;
as = unw_create_addr_space (&_UPT_accessors, 0);
if (!as)
panic ("unw_create_addr_space() failed");
if (argc == 1)
{
static char *args[] = { "self", "ls", "/", NULL };
/* automated test case */
argv = args;
/* Unless the args array is 'walked' the child
process is unable to access it and dies with a segfault */
fprintf(stderr, "Automated test (%s,%s,%s,%s)\n",
args[0],args[1],args[2],args[3]);
}
else if (argc > 1)
while (argv[optind][0] == '-')
{
if (strcmp (argv[optind], "-v") == 0)
++optind, verbose = 1;
else if (strcmp (argv[optind], "-i") == 0)
++optind, trace_mode = INSTRUCTION; /* backtrace at each insn */
else if (strcmp (argv[optind], "-s") == 0)
++optind, trace_mode = SYSCALL; /* backtrace at each syscall */
else if (strcmp (argv[optind], "-t") == 0)
/* Execute until raise(SIGUSR1), then backtrace at each insn
until raise(SIGUSR2). */
++optind, trace_mode = TRIGGER;
else if (strcmp (argv[optind], "-c") == 0)
/* Enable caching of unwind-info. */
++optind, unw_set_caching_policy (as, UNW_CACHE_GLOBAL);
else if (strcmp (argv[optind], "-n") == 0)
/* Don't look-up and print symbol names. */
++optind, print_names = 0;
else
fprintf(stderr, "unrecognized option: %s\n", argv[optind++]);
if (optind >= argc)
break;
}
target_pid = fork ();
if (!target_pid)
{
/* child */
if (!verbose)
dup2 (open ("/dev/null", O_WRONLY), 1);
#if HAVE_DECL_PTRACE_TRACEME
ptrace (PTRACE_TRACEME, 0, 0, 0);
#elif HAVE_DECL_PT_TRACE_ME
ptrace (PT_TRACE_ME, 0, 0, 0);
#else
#error Trace me
#endif
if ((argc > 1) && (optind == argc)) {
fprintf(stderr, "Need to specify a command line for the child\n");
exit (-1);
}
#ifdef __FreeBSD__
execve (argv[optind], argv + optind, environ);
#else
execvpe (argv[optind], argv + optind, environ);
#endif
_exit (-1);
}
atexit (target_pid_kill);
ui = _UPT_create (target_pid);
while (nerrors <= nerrors_max)
{
pid = wait4 (-1, &status, 0, NULL);
if (pid == -1)
{
if (errno == EINTR)
continue;
panic ("wait4() failed (errno=%d)\n", errno);
}
pending_sig = 0;
if (WIFSIGNALED (status) || WIFEXITED (status)
|| (WIFSTOPPED (status) && WSTOPSIG (status) != SIGTRAP))
{
if (WIFEXITED (status))
{
if (WEXITSTATUS (status) != 0)
panic ("child's exit status %d\n", WEXITSTATUS (status));
break;
}
else if (WIFSIGNALED (status))
{
if (!killed)
panic ("child terminated by signal %d\n", WTERMSIG (status));
break;
}
else
{
pending_sig = WSTOPSIG (status);
/* Avoid deadlock: */
if (WSTOPSIG (status) == SIGKILL)
break;
if (trace_mode == TRIGGER)
{
if (WSTOPSIG (status) == SIGUSR1)
state = 0;
else if (WSTOPSIG (status) == SIGUSR2)
state = 1;
}
if (WSTOPSIG (status) != SIGUSR1 && WSTOPSIG (status) != SIGUSR2)
{
static int count = 0;
if (count++ > 100)
{
panic ("Too many child unexpected signals (now %d)\n",
WSTOPSIG (status));
killed = 1;
}
}
}
}
switch (trace_mode)
{
case TRIGGER:
if (state)
#if HAVE_DECL_PTRACE_CONT
ptrace (PTRACE_CONT, target_pid, 0, 0);
#elif HAVE_DECL_PT_CONTINUE
ptrace (PT_CONTINUE, target_pid, (caddr_t)1, 0);
#else
#error Port me
#endif
else
{
do_backtrace ();
#if HAVE_DECL_PTRACE_SINGLESTEP
if (ptrace (PTRACE_SINGLESTEP, target_pid, 0, pending_sig) < 0)
{
panic ("ptrace(PTRACE_SINGLESTEP) failed (errno=%d)\n", errno);
killed = 1;
}
#elif HAVE_DECL_PT_STEP
if (ptrace (PT_STEP, target_pid, (caddr_t)1, pending_sig) < 0)
{
panic ("ptrace(PT_STEP) failed (errno=%d)\n", errno);
killed = 1;
}
#else
#error Singlestep me
#endif
}
break;
case SYSCALL:
if (!state)
do_backtrace ();
state ^= 1;
#if HAVE_DECL_PTRACE_SYSCALL
ptrace (PTRACE_SYSCALL, target_pid, 0, pending_sig);
#elif HAVE_DECL_PT_SYSCALL
ptrace (PT_SYSCALL, target_pid, (caddr_t)1, pending_sig);
#else
#error Syscall me
#endif
break;
case INSTRUCTION:
do_backtrace ();
#if HAVE_DECL_PTRACE_SINGLESTEP
ptrace (PTRACE_SINGLESTEP, target_pid, 0, pending_sig);
#elif HAVE_DECL_PT_STEP
ptrace (PT_STEP, target_pid, (caddr_t)1, pending_sig);
#else
#error Singlestep me
#endif
break;
}
if (killed)
kill (target_pid, SIGKILL);
}
_UPT_destroy (ui);
unw_destroy_addr_space (as);
if (nerrors)
{
printf ("FAILURE: detected %d errors\n", nerrors);
exit (-1);
}
if (verbose)
printf ("SUCCESS\n");
return 0;
}
#endif /* !HAVE_TTRACE */
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./docs/design/coreclr/botr/threading.md | CLR Threading Overview
======================
Managed vs. Native Threads
==========================
Managed code executes on "managed threads," which are distinct from the native threads provided by the operating system. A native thread is a thread of execution of native code on a physical machine; a managed thread is a virtual thread of execution on the CLR's virtual machine.
Just as the JIT compiler maps "virtual" IL instructions into native instructions that execute on the physical machine, the CLR's threading infrastructure maps "virtual" managed threads onto the native threads provided by the operating system.
At any given time, a managed thread may or may not be assigned to a native thread for execution. For example, a managed thread that has been created (via "new System.Threading.Thread") but not yet started (via System.Threading.Thread.Start) is a managed thread that has not yet been assigned to a native thread. Similarly, a managed thread may, in principle, move between multiple native threads over the course of its execution, though in practice the CLR does not currently support this.
The public Thread interface available to managed code intentionally hides the details of the underlying native threads. because:
- Managed threads are not necessarily mapped to a single native thread (and may not be mapped to a native thread at all).
- Different operating systems expose different abstractions for native threads.
- In principle, managed threads are "virtualized".
The CLR provides equivalent abstractions for managed threads, implemented by the CLR itself. For example, it does not expose the operating system's thread-local storage (TLS) mechanism, but instead provides managed "thread-static" variables. Similarly, it does not expose the native thread's "thread ID," but instead provides a "managed thread ID" which is generated independently of the OS. However, for diagnostic purposes, some details of the underlying native thread may be obtained via types in the System.Diagnostics namespace.
Managed threads require additional functionality typically not needed by native threads. First, managed threads hold GC references on their stacks, so the CLR must be able to enumerate (and possibly modify) these references every time a GC occurs. To do this, the CLR must "suspend" each managed thread (stop it at a point where all of its GC references can be found). Second, when an AppDomain is unloaded, the CLR must ensure that no thread is executing code in that AppDomain. This requires the ability to force a thread to unwind out of that AppDomain. The CLR does this by injecting a ThreadAbortException into such threads.
Data Structures
===============
Every managed thread has an associated Thread object, defined in [threads.h][threads.h]. This object tracks everything the VM needs to know about the managed thread. This includes things that are _necessary_, such as the thread's current GC mode and Frame chain, as well as many things that are allocated per-thread simply for performance reasons (such as some fast arena-style allocators).
All Thread objects are stored in the ThreadStore (also defined in [threads.h][threads.h]), which is a simple list of all known Thread objects. To enumerate all managed threads, one must first acquire the ThreadStoreLock, then use ThreadStore::GetAllThreadList to enumerate all Thread objects. This list may include managed threads which are not currently assigned to native threads (for example, they may not yet be started, or the native thread may already have exited).
[threads.h]: ../../../../src/coreclr/vm/threads.h
Each managed thread that is currently assigned to a native thread is reachable via a native thread-local storage (TLS) slot on that native thread. This allows code that is executing on that native thread to get the corresponding Thread object, via GetThread().
Additionally, many managed threads have a _managed_ Thread object (System.Threading.Thread) which is distinct from the native Thread object. The managed Thread object provides methods for managed code to interact with the thread, and is mostly a wrapper around functionality offered by the native Thread object. The current managed Thread object is reachable (from managed code) via Thread.CurrentThread.
In a debugger, the SOS extension command "!Threads" can be used to enumerate all Thread objects in the ThreadStore.
Thread Lifetimes
================
A managed thread is created in the following situations:
1. Managed code explicitly asks the CLR to create a new thread via System.Threading.Thread.
2. The CLR creates the managed thread directly (see ["special threads"](#special-threads) below).
3. Native code calls managed code on a native thread which is not yet associated with a managed thread (via "reverse p/invoke" or COM interop).
4. A managed process starts (invoking its Main method on the process' Main thread).
In cases #1 and #2, the CLR is responsible for creating a native thread to back the managed thread. This is not done until the thread is actually _started_. In such cases, the native thread is "owned" by the CLR; the CLR is responsible for the native thread's lifetime. In these cases, the CLR is aware of the existence of the thread by virtue of the fact that the CLR created it in the first place.
In cases #3 and #4, the native thread already existed prior to the creation of the managed thread, and is owned by code external to the CLR. The CLR is not responsible for the native thread's lifetime. The CLR becomes aware of these threads the first time they attempt to call managed code.
When a native thread dies, the CLR is notified via its DllMain function. This happens inside of the OS "loader lock," so there is little that can be done (safely) while processing this notification. So rather than destroying the data structures associated with the managed thread, the thread is simply marked as "dead" and signals the finalizer thread to run. The finalizer thread then sweeps through the threads in the ThreadStore and destroys any that are both dead _and_ unreachable via managed code.
Suspension
==========
The CLR must be able to find all references to managed objects in order to perform a GC. Managed code is constantly accessing the GC heap, and manipulating references stored on the stack and in registers. The CLR must ensure that all managed threads are stopped (so they aren't modifying the heap) to safely and reliably find all managed objects. It only stops at _safe points_, when registers and stack locations can be inspected for live references.
Another way of putting this is that the GC heap, and every thread's stack and register state, are "shared state," accessed by multiple threads. As with most shared state, some sort of "lock" is required to protect it. Managed code must hold this lock while accessing the heap, and can only release the lock at safe points.
The CLR refers to this "lock" as the thread's "GC mode." A thread which is in "cooperative mode" holds its lock; it must "cooperate" with the GC (by releasing the lock) in order for a GC to proceed. A thread which is in "preemptive" mode does not hold its lock – the GC may proceed "preemptively" because the thread is known to not be accessing the GC heap.
A GC may only proceed when all managed threads are in "preemptive" mode (not holding the lock). The process of moving all managed threads to preemptive mode is known as "GC suspension" or "suspending the Execution Engine (EE)."
A naïve implementation of this "lock" would be for each managed thread to actually acquire and release a real lock around each access to the GC heap. Then the GC would simply attempt to acquire the lock on each thread; once it had acquired all threads' locks, it would be safe to perform the GC.
However, this naïve approach is unsatisfactory for two reasons. First, it would require managed code to spend a lot of time acquiring and releasing the lock (or at least checking whether the GC was attempting to acquire the lock – known as "GC polling.") Second, it would require the JIT to emit "GC info" describing the layout of the stack and registers for every point in JIT'd code; this information would consume large amounts of memory.
We refined this naïve approach by separating JIT'd managed code into "partially interruptible" and "fully interruptible" code. In partially interruptible code, the only safe points are calls to other methods, and explicit "GC poll" locations where the JIT emits code to check whether a GC is pending. GC info need only be emitted for these locations. In fully interruptible code, every instruction is a safe point, and the JIT emits GC info for every instruction – but it does not emit GC polls. Instead, fully interruptible code may be "interrupted" by hijacking the thread (a process which is discussed later in this document). The JIT chooses whether to emit fully- or partially-interruptible code based on heuristics to find the best tradeoff between code quality, size of the GC info, and GC suspension latency.
Given the above, there are three fundamental operations to define: entering cooperative mode, leaving cooperative mode, and suspending the EE.
Entering Cooperative Mode
-------------------------
A thread enters cooperative mode by calling Thread::DisablePreemptiveGC. This acquires the "lock" for the current thread, as follows:
1. If a GC is in progress (the GC holds the lock) then block until the GC is complete.
2. Mark the thread as being in cooperative mode. No GC may proceed until the thread reenters preemptive mode.
These two steps proceed as if they were atomic.
Entering Preemptive Mode
------------------------
A thread enters preemptive mode (releases the lock) by calling Thread::EnablePreemptiveGC. This simply marks the thread as no longer being in cooperative mode, and informs the GC thread that it may be able to proceed.
Suspending the EE
-----------------
When a GC needs to occur, the first step is to suspend the EE. This is done by GCHeap::SuspendEE, which proceeds as follows:
1. Set a global flag (g\_fTrapReturningThreads) to indicate that a GC is in progress. Any threads that attempt to enter cooperative mode will block until the GC is complete.
2. Find all threads currently executing in cooperative mode. For each such thread, attempt to hijack the thread and force it to leave cooperative mode.
3. Repeat until no threads are running in cooperative mode.
Hijacking
---------
Hijacking for GC suspension is done by Thread::SysSuspendForGC. This method attempts to force any managed thread that is currently running in cooperative mode, to leave cooperative mode at a "safe point." It does this by enumerating all managed threads (walking the ThreadStore), and for each managed thread currently running in cooperative mode.
1. Suspend the underlying native thread. This is done with the Win32 SuspendThread API. This API forcibly stops the thread from running, at some random point in its execution (not necessarily a safe point).
2. Get the current CONTEXT for the thread, via GetThreadContext. This is an OS concept; CONTEXT represents the current register state of the thread. This allows us to inspect its instruction pointer, and thus determine what type of code it is currently executing.
3. Check again if the thread is in cooperative mode, as it may have already left cooperative mode before it could be suspended. If so, the thread is in dangerous territory: the thread may be executing arbitrary native code, and must be resumed immediately to avoid deadlocks.
4. Check if the thread is running managed code. It is possible that it is executing native VM code in cooperative mode (see Synchronization, below), in which case the thread must be immediately resumed as in the previous step.
5. Now the thread is suspended in managed code. Depending on whether that code is fully- or partially-interruptable, one of the following is performed:
* If fully interruptable, it is safe to perform a GC at any point, since the thread is, by definition, at a safe point. It is reasonable to leave the thread suspended at this point (because it's safe) but various historical OS bugs prevent this from working, because the CONTEXT retrieved earlier may be corrupt). Instead, the thread's instruction pointer is overwritten, redirecting it to a stub that will capture a more complete CONTEXT, leave cooperative mode, wait for the GC to complete, reenter cooperative mode, and restore the thread to its previous state.
* If partially-interruptable, the thread is, by definition, not at a safe point. However, the caller will be at a safe point (method transition). Using that knowledge, the CLR "hijacks" the top-most stack frame's return address (physically overwrite that location on the stack) with a stub similar to the one used for fully-interruptable code. When the method returns, it will no longer return to its actual caller, but rather to the stub (the method may also perform a GC poll, inserted by the JIT, before that point, which will cause it to leave cooperative mode and undo the hijack).
ThreadAbort / AppDomain-Unload
==============================
In order to unload an AppDomain, the CLR must ensure that no thread is running in that AppDomain. To accomplish this, all managed threads are enumerated, and "abort" any threads which have stack frames belonging to the AppDomain being unloaded. A ThreadAbortException is "injected" into the running thread, which causes the thread to unwind (executing backout code along the way) until it is no longer executing in the AppDomain, at which point the ThreadAbortException is translated into an AppDomainUnloaded exception.
ThreadAbortException is a special type of exception. It can be caught by user code, but the CLR ensures that the exception will be rethrown after the user's exception handler is executed. Thus ThreadAbortException is sometimes referred to as "uncatchable," though this is not strictly true.
A ThreadAbortException is typically 'thrown' by simply setting a bit on the managed thread marking it as "aborting." This bit is checked by various parts of the CLR (most notably, every return from a p/invoke) and often times setting this bit is all that is needed to get the thread aborted in a timely manner.
However, if the thread is, for example, executing a long-running managed loop, it may never check this bit. To get such a thread to abort faster, the thread is "hijacked" and forced to raise a ThreadAbortException. This hijacking is done in the same way as GC suspension, except that the stubs that the thread is redirected to will cause a ThreadAbortException to be raised, rather than waiting for a GC to complete.
This hijacking means that a ThreadAbortException can be raised at essentially any arbitrary point in managed code. This makes it extremely difficult for managed code to deal successfully with a ThreadAbortException. It is therefore unwise to use this mechanism for any purpose other than AppDomain-Unload, which ensures that any state corrupted by the ThreadAbort will be cleaned up along with the AppDomain.
Synchronization: Managed
========================
Managed code has access to many synchronization primitives, collected within the System.Threading namespace. These include wrappers for native OS primitives like Mutex, Event, and Semaphore objects, as well as some abstractions such as Barriers and SpinLocks. However, the primary synchronization mechanism used by most managed code is System.Threading.Monitor, which provides a high-performance locking facility on _any managed object_, and additionally provides "condition variable" semantics for signaling changes in the state protected by a lock.
Monitor is implemented as a "hybrid lock;" it has features of both a spin-lock and a kernel-based lock like a Mutex. The idea is that most locks are held only briefly, so it takes less time to simply spin-wait for the lock to be released, than it would to make a call into the kernel to block the thread. It is important not to waste CPU cycles spinning, so if the lock has not been acquired after a brief period of spinning, the implementation falls back to blocking in the kernel.
Because any object may potentially be used as a lock/condition variable, every object must have a location in which to store the lock information. This is done with "object headers" and "sync blocks."
The object header is a machine-word-sized field that precedes every managed object. It is used for many purposes, such as storing the object's hash code. One such purpose is holding the object's lock state. If more per-object data is needed than will fit in the object header, we "inflate" the object by creating a "sync block."
Sync blocks are stored in the Sync Block Table, and are addressed by sync block indexes. Each object with an associated sync block has the index of that index in the object's object header.
The details of object headers and sync blocks are defined in [syncblk.h][syncblk.h]/[.cpp][syncblk.cpp].
[syncblk.h]: ../../../../src/coreclr/vm/syncblk.h
[syncblk.cpp]: ../../../../src/coreclr/vm/syncblk.cpp
If there is room on the object header, Monitor stores the managed thread ID of the thread that currently holds the lock on the object (or zero (0) if no thread holds the lock). Acquiring the lock in this case is a simple matter of spin-waiting until the object header's thread ID is zero, and then atomically setting it to the current thread's managed thread ID.
If the lock cannot be acquired in this manner after some number of spins, or the object header is already being used for other purposes, a sync block must be created for the object. This has additional data, including an event that can be used to block the current thread, allowing us to stop spinning and efficiently wait for the lock to be released.
An object that is used as a condition variable (via Monitor.Wait and Monitor.Pulse) must always be inflated, as there is not enough room in the sync block to hold the required state.
Synchronization: Native
=======================
The native portion of the CLR must also be aware of threading, as it will be invoked by managed code on multiple threads. This requires native synchronization mechanisms, such as locks, events, etc.
The ITaskHost API allows a host to override many aspects of managed threading, including thread creation, destruction, and synchronization. The ability of a host to override native synchronization means that VM code can generally not use native synchronization primitives (Critical Sections, Mutexes, Events, etc.) directly, but rather must use the VM's wrappers over these.
Additionally, as described above, GC suspension is a special kind of "lock" that affects nearly every aspect of the CLR. Native code in the VM may enter "cooperative" mode if it must manipulate GC heap objects, and thus the "GC suspension lock" becomes one of the most important synchronization mechanisms in native VM code, as well as managed.
The major synchronization mechanisms used in native VM code are the GC mode, and Crst.
GC Mode
-------
As discussed above, all managed code runs in cooperative mode, because it may manipulate the GC heap. Generally, native code does not touch managed objects, and thus runs in preemptive mode. But some native code in the VM must access the GC heap, and thus must run in cooperative mode.
Native code generally does not manipulate the GC mode directly, but rather uses two macros: GCX\_COOP and GCX\_PREEMP. These enter the desired mode, and erect "holders" to cause the thread to revert to the previous mode when the scope is exited.
It is important to understand that GCX\_COOP effectively acquires a lock on the GC heap. No GC may proceed while the thread is in cooperative mode. And native code cannot be "hijacked" as is done for managed code, so the thread will remain in cooperative mode until it explicitly switches back to preemptive mode.
Thus entering cooperative mode in native code is discouraged. In cases where cooperative mode must be entered, it should be kept to as short a time as possible. The thread should not be blocked in this mode, and in particular cannot generally acquire locks safely.
Similarly, GCX\_PREEMP potentially _releases_ a lock that had been held by the thread. Great care must be taken to ensure that all GC references are properly protected before entering preemptive mode.
The [Rules of the Code](../../../coding-guidelines/clr-code-guide.md) document describes the disciplines needed to ensure safety around GC mode switches.
Crst
----
Just as Monitor is the preferred locking mechanism for managed code, Crst is the preferred mechanism for VM code. Like Monitor, Crst is a hybrid lock that is aware of hosts and GC modes. Crst also implements deadlock avoidance via "lock leveling," described in the [Crst Leveling chapter of the BotR](../../../coding-guidelines/clr-code-guide.md#2.6.4).
It is generally illegal to acquire a Crst while in cooperative mode, though exceptions are made where absolutely necessary.
Special Threads
===============
In addition to managing threads created by managed code, the CLR creates several "special" threads for its own use.
Finalizer Thread
----------------
This thread is created in every process that runs managed code. When the GC determines that a finalizable object is no longer reachable, it places that object on a finalization queue. At the end of a GC, the finalizer thread is signaled to process all finalizers currently in this queue. Each object is then dequeued, one by one, and its finalizer is executed.
This thread is also used to perform various CLR-internal housekeeping tasks, and to wait for notifications of some external events (such as a low-memory condition, which signals the GC to collect more aggressively). See GCHeap::FinalizerThreadStart for the details.
GC Threads
----------
When running in "concurrent" or "server" modes, the GC creates one or more background threads to perform various stages of garbage collection in parallel. These threads are wholly owned and managed by the GC, and never run managed code.
Debugger Thread
---------------
The CLR maintains a single native thread in each managed process, which performs various tasks on behalf of attached managed debuggers.
AppDomain-Unload Thread
-----------------------
This thread is responsible for unloading AppDomains. This is done on a separate, CLR-internal thread, rather than the thread that requests the AD-unload, to a) provide guaranteed stack space for the unload logic, and b) allow the thread that requested the unload to be unwound out of the AD, if needed.
ThreadPool Threads
------------------
The CLR's ThreadPool maintains a collection of managed threads for executing user "work items." These managed threads are bound to native threads owned by the ThreadPool. The ThreadPool also maintains a small number of native threads to handle functions like "thread injection," timers, and "registered waits."
| CLR Threading Overview
======================
Managed vs. Native Threads
==========================
Managed code executes on "managed threads," which are distinct from the native threads provided by the operating system. A native thread is a thread of execution of native code on a physical machine; a managed thread is a virtual thread of execution on the CLR's virtual machine.
Just as the JIT compiler maps "virtual" IL instructions into native instructions that execute on the physical machine, the CLR's threading infrastructure maps "virtual" managed threads onto the native threads provided by the operating system.
At any given time, a managed thread may or may not be assigned to a native thread for execution. For example, a managed thread that has been created (via "new System.Threading.Thread") but not yet started (via System.Threading.Thread.Start) is a managed thread that has not yet been assigned to a native thread. Similarly, a managed thread may, in principle, move between multiple native threads over the course of its execution, though in practice the CLR does not currently support this.
The public Thread interface available to managed code intentionally hides the details of the underlying native threads. because:
- Managed threads are not necessarily mapped to a single native thread (and may not be mapped to a native thread at all).
- Different operating systems expose different abstractions for native threads.
- In principle, managed threads are "virtualized".
The CLR provides equivalent abstractions for managed threads, implemented by the CLR itself. For example, it does not expose the operating system's thread-local storage (TLS) mechanism, but instead provides managed "thread-static" variables. Similarly, it does not expose the native thread's "thread ID," but instead provides a "managed thread ID" which is generated independently of the OS. However, for diagnostic purposes, some details of the underlying native thread may be obtained via types in the System.Diagnostics namespace.
Managed threads require additional functionality typically not needed by native threads. First, managed threads hold GC references on their stacks, so the CLR must be able to enumerate (and possibly modify) these references every time a GC occurs. To do this, the CLR must "suspend" each managed thread (stop it at a point where all of its GC references can be found). Second, when an AppDomain is unloaded, the CLR must ensure that no thread is executing code in that AppDomain. This requires the ability to force a thread to unwind out of that AppDomain. The CLR does this by injecting a ThreadAbortException into such threads.
Data Structures
===============
Every managed thread has an associated Thread object, defined in [threads.h][threads.h]. This object tracks everything the VM needs to know about the managed thread. This includes things that are _necessary_, such as the thread's current GC mode and Frame chain, as well as many things that are allocated per-thread simply for performance reasons (such as some fast arena-style allocators).
All Thread objects are stored in the ThreadStore (also defined in [threads.h][threads.h]), which is a simple list of all known Thread objects. To enumerate all managed threads, one must first acquire the ThreadStoreLock, then use ThreadStore::GetAllThreadList to enumerate all Thread objects. This list may include managed threads which are not currently assigned to native threads (for example, they may not yet be started, or the native thread may already have exited).
[threads.h]: ../../../../src/coreclr/vm/threads.h
Each managed thread that is currently assigned to a native thread is reachable via a native thread-local storage (TLS) slot on that native thread. This allows code that is executing on that native thread to get the corresponding Thread object, via GetThread().
Additionally, many managed threads have a _managed_ Thread object (System.Threading.Thread) which is distinct from the native Thread object. The managed Thread object provides methods for managed code to interact with the thread, and is mostly a wrapper around functionality offered by the native Thread object. The current managed Thread object is reachable (from managed code) via Thread.CurrentThread.
In a debugger, the SOS extension command "!Threads" can be used to enumerate all Thread objects in the ThreadStore.
Thread Lifetimes
================
A managed thread is created in the following situations:
1. Managed code explicitly asks the CLR to create a new thread via System.Threading.Thread.
2. The CLR creates the managed thread directly (see ["special threads"](#special-threads) below).
3. Native code calls managed code on a native thread which is not yet associated with a managed thread (via "reverse p/invoke" or COM interop).
4. A managed process starts (invoking its Main method on the process' Main thread).
In cases #1 and #2, the CLR is responsible for creating a native thread to back the managed thread. This is not done until the thread is actually _started_. In such cases, the native thread is "owned" by the CLR; the CLR is responsible for the native thread's lifetime. In these cases, the CLR is aware of the existence of the thread by virtue of the fact that the CLR created it in the first place.
In cases #3 and #4, the native thread already existed prior to the creation of the managed thread, and is owned by code external to the CLR. The CLR is not responsible for the native thread's lifetime. The CLR becomes aware of these threads the first time they attempt to call managed code.
When a native thread dies, the CLR is notified via its DllMain function. This happens inside of the OS "loader lock," so there is little that can be done (safely) while processing this notification. So rather than destroying the data structures associated with the managed thread, the thread is simply marked as "dead" and signals the finalizer thread to run. The finalizer thread then sweeps through the threads in the ThreadStore and destroys any that are both dead _and_ unreachable via managed code.
Suspension
==========
The CLR must be able to find all references to managed objects in order to perform a GC. Managed code is constantly accessing the GC heap, and manipulating references stored on the stack and in registers. The CLR must ensure that all managed threads are stopped (so they aren't modifying the heap) to safely and reliably find all managed objects. It only stops at _safe points_, when registers and stack locations can be inspected for live references.
Another way of putting this is that the GC heap, and every thread's stack and register state, are "shared state," accessed by multiple threads. As with most shared state, some sort of "lock" is required to protect it. Managed code must hold this lock while accessing the heap, and can only release the lock at safe points.
The CLR refers to this "lock" as the thread's "GC mode." A thread which is in "cooperative mode" holds its lock; it must "cooperate" with the GC (by releasing the lock) in order for a GC to proceed. A thread which is in "preemptive" mode does not hold its lock – the GC may proceed "preemptively" because the thread is known to not be accessing the GC heap.
A GC may only proceed when all managed threads are in "preemptive" mode (not holding the lock). The process of moving all managed threads to preemptive mode is known as "GC suspension" or "suspending the Execution Engine (EE)."
A naïve implementation of this "lock" would be for each managed thread to actually acquire and release a real lock around each access to the GC heap. Then the GC would simply attempt to acquire the lock on each thread; once it had acquired all threads' locks, it would be safe to perform the GC.
However, this naïve approach is unsatisfactory for two reasons. First, it would require managed code to spend a lot of time acquiring and releasing the lock (or at least checking whether the GC was attempting to acquire the lock – known as "GC polling.") Second, it would require the JIT to emit "GC info" describing the layout of the stack and registers for every point in JIT'd code; this information would consume large amounts of memory.
We refined this naïve approach by separating JIT'd managed code into "partially interruptible" and "fully interruptible" code. In partially interruptible code, the only safe points are calls to other methods, and explicit "GC poll" locations where the JIT emits code to check whether a GC is pending. GC info need only be emitted for these locations. In fully interruptible code, every instruction is a safe point, and the JIT emits GC info for every instruction – but it does not emit GC polls. Instead, fully interruptible code may be "interrupted" by hijacking the thread (a process which is discussed later in this document). The JIT chooses whether to emit fully- or partially-interruptible code based on heuristics to find the best tradeoff between code quality, size of the GC info, and GC suspension latency.
Given the above, there are three fundamental operations to define: entering cooperative mode, leaving cooperative mode, and suspending the EE.
Entering Cooperative Mode
-------------------------
A thread enters cooperative mode by calling Thread::DisablePreemptiveGC. This acquires the "lock" for the current thread, as follows:
1. If a GC is in progress (the GC holds the lock) then block until the GC is complete.
2. Mark the thread as being in cooperative mode. No GC may proceed until the thread reenters preemptive mode.
These two steps proceed as if they were atomic.
Entering Preemptive Mode
------------------------
A thread enters preemptive mode (releases the lock) by calling Thread::EnablePreemptiveGC. This simply marks the thread as no longer being in cooperative mode, and informs the GC thread that it may be able to proceed.
Suspending the EE
-----------------
When a GC needs to occur, the first step is to suspend the EE. This is done by GCHeap::SuspendEE, which proceeds as follows:
1. Set a global flag (g\_fTrapReturningThreads) to indicate that a GC is in progress. Any threads that attempt to enter cooperative mode will block until the GC is complete.
2. Find all threads currently executing in cooperative mode. For each such thread, attempt to hijack the thread and force it to leave cooperative mode.
3. Repeat until no threads are running in cooperative mode.
Hijacking
---------
Hijacking for GC suspension is done by Thread::SysSuspendForGC. This method attempts to force any managed thread that is currently running in cooperative mode, to leave cooperative mode at a "safe point." It does this by enumerating all managed threads (walking the ThreadStore), and for each managed thread currently running in cooperative mode.
1. Suspend the underlying native thread. This is done with the Win32 SuspendThread API. This API forcibly stops the thread from running, at some random point in its execution (not necessarily a safe point).
2. Get the current CONTEXT for the thread, via GetThreadContext. This is an OS concept; CONTEXT represents the current register state of the thread. This allows us to inspect its instruction pointer, and thus determine what type of code it is currently executing.
3. Check again if the thread is in cooperative mode, as it may have already left cooperative mode before it could be suspended. If so, the thread is in dangerous territory: the thread may be executing arbitrary native code, and must be resumed immediately to avoid deadlocks.
4. Check if the thread is running managed code. It is possible that it is executing native VM code in cooperative mode (see Synchronization, below), in which case the thread must be immediately resumed as in the previous step.
5. Now the thread is suspended in managed code. Depending on whether that code is fully- or partially-interruptable, one of the following is performed:
* If fully interruptable, it is safe to perform a GC at any point, since the thread is, by definition, at a safe point. It is reasonable to leave the thread suspended at this point (because it's safe) but various historical OS bugs prevent this from working, because the CONTEXT retrieved earlier may be corrupt). Instead, the thread's instruction pointer is overwritten, redirecting it to a stub that will capture a more complete CONTEXT, leave cooperative mode, wait for the GC to complete, reenter cooperative mode, and restore the thread to its previous state.
* If partially-interruptable, the thread is, by definition, not at a safe point. However, the caller will be at a safe point (method transition). Using that knowledge, the CLR "hijacks" the top-most stack frame's return address (physically overwrite that location on the stack) with a stub similar to the one used for fully-interruptable code. When the method returns, it will no longer return to its actual caller, but rather to the stub (the method may also perform a GC poll, inserted by the JIT, before that point, which will cause it to leave cooperative mode and undo the hijack).
ThreadAbort / AppDomain-Unload
==============================
In order to unload an AppDomain, the CLR must ensure that no thread is running in that AppDomain. To accomplish this, all managed threads are enumerated, and "abort" any threads which have stack frames belonging to the AppDomain being unloaded. A ThreadAbortException is "injected" into the running thread, which causes the thread to unwind (executing backout code along the way) until it is no longer executing in the AppDomain, at which point the ThreadAbortException is translated into an AppDomainUnloaded exception.
ThreadAbortException is a special type of exception. It can be caught by user code, but the CLR ensures that the exception will be rethrown after the user's exception handler is executed. Thus ThreadAbortException is sometimes referred to as "uncatchable," though this is not strictly true.
A ThreadAbortException is typically 'thrown' by simply setting a bit on the managed thread marking it as "aborting." This bit is checked by various parts of the CLR (most notably, every return from a p/invoke) and often times setting this bit is all that is needed to get the thread aborted in a timely manner.
However, if the thread is, for example, executing a long-running managed loop, it may never check this bit. To get such a thread to abort faster, the thread is "hijacked" and forced to raise a ThreadAbortException. This hijacking is done in the same way as GC suspension, except that the stubs that the thread is redirected to will cause a ThreadAbortException to be raised, rather than waiting for a GC to complete.
This hijacking means that a ThreadAbortException can be raised at essentially any arbitrary point in managed code. This makes it extremely difficult for managed code to deal successfully with a ThreadAbortException. It is therefore unwise to use this mechanism for any purpose other than AppDomain-Unload, which ensures that any state corrupted by the ThreadAbort will be cleaned up along with the AppDomain.
Synchronization: Managed
========================
Managed code has access to many synchronization primitives, collected within the System.Threading namespace. These include wrappers for native OS primitives like Mutex, Event, and Semaphore objects, as well as some abstractions such as Barriers and SpinLocks. However, the primary synchronization mechanism used by most managed code is System.Threading.Monitor, which provides a high-performance locking facility on _any managed object_, and additionally provides "condition variable" semantics for signaling changes in the state protected by a lock.
Monitor is implemented as a "hybrid lock;" it has features of both a spin-lock and a kernel-based lock like a Mutex. The idea is that most locks are held only briefly, so it takes less time to simply spin-wait for the lock to be released, than it would to make a call into the kernel to block the thread. It is important not to waste CPU cycles spinning, so if the lock has not been acquired after a brief period of spinning, the implementation falls back to blocking in the kernel.
Because any object may potentially be used as a lock/condition variable, every object must have a location in which to store the lock information. This is done with "object headers" and "sync blocks."
The object header is a machine-word-sized field that precedes every managed object. It is used for many purposes, such as storing the object's hash code. One such purpose is holding the object's lock state. If more per-object data is needed than will fit in the object header, we "inflate" the object by creating a "sync block."
Sync blocks are stored in the Sync Block Table, and are addressed by sync block indexes. Each object with an associated sync block has the index of that index in the object's object header.
The details of object headers and sync blocks are defined in [syncblk.h][syncblk.h]/[.cpp][syncblk.cpp].
[syncblk.h]: ../../../../src/coreclr/vm/syncblk.h
[syncblk.cpp]: ../../../../src/coreclr/vm/syncblk.cpp
If there is room on the object header, Monitor stores the managed thread ID of the thread that currently holds the lock on the object (or zero (0) if no thread holds the lock). Acquiring the lock in this case is a simple matter of spin-waiting until the object header's thread ID is zero, and then atomically setting it to the current thread's managed thread ID.
If the lock cannot be acquired in this manner after some number of spins, or the object header is already being used for other purposes, a sync block must be created for the object. This has additional data, including an event that can be used to block the current thread, allowing us to stop spinning and efficiently wait for the lock to be released.
An object that is used as a condition variable (via Monitor.Wait and Monitor.Pulse) must always be inflated, as there is not enough room in the sync block to hold the required state.
Synchronization: Native
=======================
The native portion of the CLR must also be aware of threading, as it will be invoked by managed code on multiple threads. This requires native synchronization mechanisms, such as locks, events, etc.
The ITaskHost API allows a host to override many aspects of managed threading, including thread creation, destruction, and synchronization. The ability of a host to override native synchronization means that VM code can generally not use native synchronization primitives (Critical Sections, Mutexes, Events, etc.) directly, but rather must use the VM's wrappers over these.
Additionally, as described above, GC suspension is a special kind of "lock" that affects nearly every aspect of the CLR. Native code in the VM may enter "cooperative" mode if it must manipulate GC heap objects, and thus the "GC suspension lock" becomes one of the most important synchronization mechanisms in native VM code, as well as managed.
The major synchronization mechanisms used in native VM code are the GC mode, and Crst.
GC Mode
-------
As discussed above, all managed code runs in cooperative mode, because it may manipulate the GC heap. Generally, native code does not touch managed objects, and thus runs in preemptive mode. But some native code in the VM must access the GC heap, and thus must run in cooperative mode.
Native code generally does not manipulate the GC mode directly, but rather uses two macros: GCX\_COOP and GCX\_PREEMP. These enter the desired mode, and erect "holders" to cause the thread to revert to the previous mode when the scope is exited.
It is important to understand that GCX\_COOP effectively acquires a lock on the GC heap. No GC may proceed while the thread is in cooperative mode. And native code cannot be "hijacked" as is done for managed code, so the thread will remain in cooperative mode until it explicitly switches back to preemptive mode.
Thus entering cooperative mode in native code is discouraged. In cases where cooperative mode must be entered, it should be kept to as short a time as possible. The thread should not be blocked in this mode, and in particular cannot generally acquire locks safely.
Similarly, GCX\_PREEMP potentially _releases_ a lock that had been held by the thread. Great care must be taken to ensure that all GC references are properly protected before entering preemptive mode.
The [Rules of the Code](../../../coding-guidelines/clr-code-guide.md) document describes the disciplines needed to ensure safety around GC mode switches.
Crst
----
Just as Monitor is the preferred locking mechanism for managed code, Crst is the preferred mechanism for VM code. Like Monitor, Crst is a hybrid lock that is aware of hosts and GC modes. Crst also implements deadlock avoidance via "lock leveling," described in the [Crst Leveling chapter of the BotR](../../../coding-guidelines/clr-code-guide.md#2.6.4).
It is generally illegal to acquire a Crst while in cooperative mode, though exceptions are made where absolutely necessary.
Special Threads
===============
In addition to managing threads created by managed code, the CLR creates several "special" threads for its own use.
Finalizer Thread
----------------
This thread is created in every process that runs managed code. When the GC determines that a finalizable object is no longer reachable, it places that object on a finalization queue. At the end of a GC, the finalizer thread is signaled to process all finalizers currently in this queue. Each object is then dequeued, one by one, and its finalizer is executed.
This thread is also used to perform various CLR-internal housekeeping tasks, and to wait for notifications of some external events (such as a low-memory condition, which signals the GC to collect more aggressively). See GCHeap::FinalizerThreadStart for the details.
GC Threads
----------
When running in "concurrent" or "server" modes, the GC creates one or more background threads to perform various stages of garbage collection in parallel. These threads are wholly owned and managed by the GC, and never run managed code.
Debugger Thread
---------------
The CLR maintains a single native thread in each managed process, which performs various tasks on behalf of attached managed debuggers.
AppDomain-Unload Thread
-----------------------
This thread is responsible for unloading AppDomains. This is done on a separate, CLR-internal thread, rather than the thread that requests the AD-unload, to a) provide guaranteed stack space for the unload logic, and b) allow the thread that requested the unload to be unwound out of the AD, if needed.
ThreadPool Threads
------------------
The CLR's ThreadPool maintains a collection of managed threads for executing user "work items." These managed threads are bound to native threads owned by the ThreadPool. The ThreadPool also maintains a small number of native threads to handle functions like "thread injection," timers, and "registered waits."
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/JIT/Methodical/VT/callconv/jumper4_il_r.ilproj | <Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Include="jumper4.il" />
</ItemGroup>
</Project>
| <Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Include="jumper4.il" />
</ItemGroup>
</Project>
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/libraries/System.Text.Encoding/tests/CustomEncoderReplacementFallback.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Xunit;
namespace System.Text.Encodings.Tests
{
// A custom encoder fallback which substitutes unknown chars with "[xxxx]" (the code point as hex)
internal sealed class CustomEncoderReplacementFallback : EncoderFallback
{
public override int MaxCharCount => 8; // = "[10FFFF]".Length
public override EncoderFallbackBuffer CreateFallbackBuffer()
{
return new CustomEncoderFallbackBuffer();
}
private sealed class CustomEncoderFallbackBuffer : EncoderFallbackBuffer
{
private string _remaining = string.Empty;
private int _remainingIdx = 0;
public override int Remaining => _remaining.Length - _remainingIdx;
public override bool Fallback(char charUnknownHigh, char charUnknownLow, int index)
=> FallbackCommon((uint)char.ConvertToUtf32(charUnknownHigh, charUnknownLow));
public override bool Fallback(char charUnknown, int index)
=> FallbackCommon(charUnknown);
private bool FallbackCommon(uint codePoint)
{
Assert.True(codePoint <= 0x10FFFF);
_remaining = FormattableString.Invariant($"[{codePoint:X4}]");
_remainingIdx = 0;
return true;
}
public override char GetNextChar()
{
return (_remainingIdx < _remaining.Length)
? _remaining[_remainingIdx++]
: '\0' /* end of string reached */;
}
public override bool MovePrevious()
{
if (_remainingIdx == 0)
{
return false;
}
_remainingIdx--;
return true;
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Xunit;
namespace System.Text.Encodings.Tests
{
// A custom encoder fallback which substitutes unknown chars with "[xxxx]" (the code point as hex)
internal sealed class CustomEncoderReplacementFallback : EncoderFallback
{
public override int MaxCharCount => 8; // = "[10FFFF]".Length
public override EncoderFallbackBuffer CreateFallbackBuffer()
{
return new CustomEncoderFallbackBuffer();
}
private sealed class CustomEncoderFallbackBuffer : EncoderFallbackBuffer
{
private string _remaining = string.Empty;
private int _remainingIdx = 0;
public override int Remaining => _remaining.Length - _remainingIdx;
public override bool Fallback(char charUnknownHigh, char charUnknownLow, int index)
=> FallbackCommon((uint)char.ConvertToUtf32(charUnknownHigh, charUnknownLow));
public override bool Fallback(char charUnknown, int index)
=> FallbackCommon(charUnknown);
private bool FallbackCommon(uint codePoint)
{
Assert.True(codePoint <= 0x10FFFF);
_remaining = FormattableString.Invariant($"[{codePoint:X4}]");
_remainingIdx = 0;
return true;
}
public override char GetNextChar()
{
return (_remainingIdx < _remaining.Length)
? _remaining[_remainingIdx++]
: '\0' /* end of string reached */;
}
public override bool MovePrevious()
{
if (_remainingIdx == 0)
{
return false;
}
_remainingIdx--;
return true;
}
}
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/System.Private.CoreLib/src/System/Buffer.CoreCLR.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System
{
public partial class Buffer
{
// Non-inlinable wrapper around the QCall that avoids polluting the fast path
// with P/Invoke prolog/epilog.
[MethodImpl(MethodImplOptions.NoInlining)]
internal static unsafe void _ZeroMemory(ref byte b, nuint byteLength)
{
fixed (byte* bytePointer = &b)
{
__ZeroMemory(bytePointer, byteLength);
}
}
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "Buffer_Clear")]
private static unsafe partial void __ZeroMemory(void* b, nuint byteLength);
// The maximum block size to for __BulkMoveWithWriteBarrier FCall. This is required to avoid GC starvation.
#if DEBUG // Stress the mechanism in debug builds
private const uint BulkMoveWithWriteBarrierChunk = 0x400;
#else
private const uint BulkMoveWithWriteBarrierChunk = 0x4000;
#endif
internal static void BulkMoveWithWriteBarrier(ref byte destination, ref byte source, nuint byteCount)
{
if (byteCount <= BulkMoveWithWriteBarrierChunk)
__BulkMoveWithWriteBarrier(ref destination, ref source, byteCount);
else
_BulkMoveWithWriteBarrier(ref destination, ref source, byteCount);
}
// Non-inlinable wrapper around the loop for copying large blocks in chunks
[MethodImpl(MethodImplOptions.NoInlining)]
private static void _BulkMoveWithWriteBarrier(ref byte destination, ref byte source, nuint byteCount)
{
Debug.Assert(byteCount > BulkMoveWithWriteBarrierChunk);
if (Unsafe.AreSame(ref source, ref destination))
return;
// This is equivalent to: (destination - source) >= byteCount || (destination - source) < 0
if ((nuint)(nint)Unsafe.ByteOffset(ref source, ref destination) >= byteCount)
{
// Copy forwards
do
{
byteCount -= BulkMoveWithWriteBarrierChunk;
__BulkMoveWithWriteBarrier(ref destination, ref source, BulkMoveWithWriteBarrierChunk);
destination = ref Unsafe.AddByteOffset(ref destination, BulkMoveWithWriteBarrierChunk);
source = ref Unsafe.AddByteOffset(ref source, BulkMoveWithWriteBarrierChunk);
}
while (byteCount > BulkMoveWithWriteBarrierChunk);
}
else
{
// Copy backwards
do
{
byteCount -= BulkMoveWithWriteBarrierChunk;
__BulkMoveWithWriteBarrier(ref Unsafe.AddByteOffset(ref destination, byteCount), ref Unsafe.AddByteOffset(ref source, byteCount), BulkMoveWithWriteBarrierChunk);
}
while (byteCount > BulkMoveWithWriteBarrierChunk);
}
__BulkMoveWithWriteBarrier(ref destination, ref source, byteCount);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void __BulkMoveWithWriteBarrier(ref byte destination, ref byte source, nuint byteCount);
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "Buffer_MemMove")]
private static unsafe partial void __Memmove(byte* dest, byte* src, nuint len);
// Used by ilmarshalers.cpp
internal static unsafe void Memcpy(byte* dest, byte* src, int len)
{
Debug.Assert(len >= 0, "Negative length in memcpy!");
Memmove(ref *dest, ref *src, (nuint)(uint)len /* force zero-extension */);
}
// Used by ilmarshalers.cpp
internal static unsafe void Memcpy(byte* pDest, int destIndex, byte[] src, int srcIndex, int len)
{
Debug.Assert((srcIndex >= 0) && (destIndex >= 0) && (len >= 0), "Index and length must be non-negative!");
Debug.Assert(src.Length - srcIndex >= len, "not enough bytes in src");
Memmove(ref *(pDest + (uint)destIndex), ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(src), (nint)(uint)srcIndex /* force zero-extension */), (uint)len);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void Memmove<T>(ref T destination, ref T source, nuint elementCount)
{
if (!RuntimeHelpers.IsReferenceOrContainsReferences<T>())
{
// Blittable memmove
Memmove(
ref Unsafe.As<T, byte>(ref destination),
ref Unsafe.As<T, byte>(ref source),
elementCount * (nuint)Unsafe.SizeOf<T>());
}
else
{
// Non-blittable memmove
BulkMoveWithWriteBarrier(
ref Unsafe.As<T, byte>(ref destination),
ref Unsafe.As<T, byte>(ref source),
elementCount * (nuint)Unsafe.SizeOf<T>());
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System
{
public partial class Buffer
{
// Non-inlinable wrapper around the QCall that avoids polluting the fast path
// with P/Invoke prolog/epilog.
[MethodImpl(MethodImplOptions.NoInlining)]
internal static unsafe void _ZeroMemory(ref byte b, nuint byteLength)
{
fixed (byte* bytePointer = &b)
{
__ZeroMemory(bytePointer, byteLength);
}
}
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "Buffer_Clear")]
private static unsafe partial void __ZeroMemory(void* b, nuint byteLength);
// The maximum block size to for __BulkMoveWithWriteBarrier FCall. This is required to avoid GC starvation.
#if DEBUG // Stress the mechanism in debug builds
private const uint BulkMoveWithWriteBarrierChunk = 0x400;
#else
private const uint BulkMoveWithWriteBarrierChunk = 0x4000;
#endif
internal static void BulkMoveWithWriteBarrier(ref byte destination, ref byte source, nuint byteCount)
{
if (byteCount <= BulkMoveWithWriteBarrierChunk)
__BulkMoveWithWriteBarrier(ref destination, ref source, byteCount);
else
_BulkMoveWithWriteBarrier(ref destination, ref source, byteCount);
}
// Non-inlinable wrapper around the loop for copying large blocks in chunks
[MethodImpl(MethodImplOptions.NoInlining)]
private static void _BulkMoveWithWriteBarrier(ref byte destination, ref byte source, nuint byteCount)
{
Debug.Assert(byteCount > BulkMoveWithWriteBarrierChunk);
if (Unsafe.AreSame(ref source, ref destination))
return;
// This is equivalent to: (destination - source) >= byteCount || (destination - source) < 0
if ((nuint)(nint)Unsafe.ByteOffset(ref source, ref destination) >= byteCount)
{
// Copy forwards
do
{
byteCount -= BulkMoveWithWriteBarrierChunk;
__BulkMoveWithWriteBarrier(ref destination, ref source, BulkMoveWithWriteBarrierChunk);
destination = ref Unsafe.AddByteOffset(ref destination, BulkMoveWithWriteBarrierChunk);
source = ref Unsafe.AddByteOffset(ref source, BulkMoveWithWriteBarrierChunk);
}
while (byteCount > BulkMoveWithWriteBarrierChunk);
}
else
{
// Copy backwards
do
{
byteCount -= BulkMoveWithWriteBarrierChunk;
__BulkMoveWithWriteBarrier(ref Unsafe.AddByteOffset(ref destination, byteCount), ref Unsafe.AddByteOffset(ref source, byteCount), BulkMoveWithWriteBarrierChunk);
}
while (byteCount > BulkMoveWithWriteBarrierChunk);
}
__BulkMoveWithWriteBarrier(ref destination, ref source, byteCount);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void __BulkMoveWithWriteBarrier(ref byte destination, ref byte source, nuint byteCount);
[GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "Buffer_MemMove")]
private static unsafe partial void __Memmove(byte* dest, byte* src, nuint len);
// Used by ilmarshalers.cpp
internal static unsafe void Memcpy(byte* dest, byte* src, int len)
{
Debug.Assert(len >= 0, "Negative length in memcpy!");
Memmove(ref *dest, ref *src, (nuint)(uint)len /* force zero-extension */);
}
// Used by ilmarshalers.cpp
internal static unsafe void Memcpy(byte* pDest, int destIndex, byte[] src, int srcIndex, int len)
{
Debug.Assert((srcIndex >= 0) && (destIndex >= 0) && (len >= 0), "Index and length must be non-negative!");
Debug.Assert(src.Length - srcIndex >= len, "not enough bytes in src");
Memmove(ref *(pDest + (uint)destIndex), ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(src), (nint)(uint)srcIndex /* force zero-extension */), (uint)len);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void Memmove<T>(ref T destination, ref T source, nuint elementCount)
{
if (!RuntimeHelpers.IsReferenceOrContainsReferences<T>())
{
// Blittable memmove
Memmove(
ref Unsafe.As<T, byte>(ref destination),
ref Unsafe.As<T, byte>(ref source),
elementCount * (nuint)Unsafe.SizeOf<T>());
}
else
{
// Non-blittable memmove
BulkMoveWithWriteBarrier(
ref Unsafe.As<T, byte>(ref destination),
ref Unsafe.As<T, byte>(ref source),
elementCount * (nuint)Unsafe.SizeOf<T>());
}
}
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/Loader/classloader/TypeGeneratorTests/TypeGeneratorTest287/Generated287.ilproj | <Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<ItemGroup>
<Compile Include="Generated287.il" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TestFramework\TestFramework.csproj" />
</ItemGroup>
</Project>
| <Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<ItemGroup>
<Compile Include="Generated287.il" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TestFramework\TestFramework.csproj" />
</ItemGroup>
</Project>
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/libraries/Microsoft.VisualBasic.Core/tests/CharTypeTests.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.VisualBasic.Tests;
using System;
using System.Collections.Generic;
using Xunit;
namespace Microsoft.VisualBasic.CompilerServices.Tests
{
public class CharTypeTests
{
[Theory]
[MemberData(nameof(FromObject_TestData))]
[MemberData(nameof(FromString_TestData))]
public void FromObject(object value, char expected)
{
Assert.Equal(expected, CharType.FromObject(value));
}
[Theory]
[MemberData(nameof(FromObject_Invalid_TestData))]
public void FromObject_ThrowsInvalidCastException(object value)
{
Assert.Throws<InvalidCastException>(() => CharType.FromObject(value));
}
[Theory]
[MemberData(nameof(FromString_TestData))]
public void FromString(string value, char expected)
{
Assert.Equal(expected, CharType.FromString(value));
}
public static IEnumerable<object[]> FromObject_TestData()
{
// char.
yield return new object[] { char.MinValue, char.MinValue };
yield return new object[] { (char)1, (char)1 };
yield return new object[] { char.MaxValue, char.MaxValue };
// null.
yield return new object[] { null, char.MinValue };
}
public static IEnumerable<object[]> FromObject_Invalid_TestData()
{
yield return new object[] { byte.MinValue };
yield return new object[] { (byte)1 };
yield return new object[] { byte.MaxValue };
yield return new object[] { (ByteEnum)byte.MinValue };
yield return new object[] { (ByteEnum)1 };
yield return new object[] { (ByteEnum)byte.MaxValue };
yield return new object[] { sbyte.MinValue };
yield return new object[] { (sbyte)(-1) };
yield return new object[] { (sbyte)0 };
yield return new object[] { (sbyte)1 };
yield return new object[] { (sbyte)1 };
yield return new object[] { sbyte.MaxValue };
yield return new object[] { (SByteEnum)sbyte.MinValue };
yield return new object[] { (SByteEnum)(-1) };
yield return new object[] { (SByteEnum)0 };
yield return new object[] { (SByteEnum)1 };
yield return new object[] { (SByteEnum)1 };
yield return new object[] { (SByteEnum)sbyte.MaxValue };
yield return new object[] { ushort.MinValue };
yield return new object[] { (ushort)1 };
yield return new object[] { ushort.MaxValue };
yield return new object[] { (UShortEnum)ushort.MinValue };
yield return new object[] { (UShortEnum)1 };
yield return new object[] { (UShortEnum)ushort.MaxValue };
yield return new object[] { short.MinValue };
yield return new object[] { (short)(-1) };
yield return new object[] { (short)0 };
yield return new object[] { (short)1 };
yield return new object[] { short.MaxValue };
yield return new object[] { (ShortEnum)short.MinValue };
yield return new object[] { (ShortEnum)(-1) };
yield return new object[] { (ShortEnum)0 };
yield return new object[] { (ShortEnum)1 };
yield return new object[] { (ShortEnum)short.MaxValue };
yield return new object[] { uint.MinValue };
yield return new object[] { (uint)1 };
yield return new object[] { uint.MaxValue };
yield return new object[] { (UIntEnum)uint.MinValue };
yield return new object[] { (UIntEnum)1 };
yield return new object[] { (UIntEnum)uint.MaxValue };
yield return new object[] { int.MinValue };
yield return new object[] { -1 };
yield return new object[] { 0 };
yield return new object[] { 1 };
yield return new object[] { int.MaxValue };
yield return new object[] { (IntEnum)int.MinValue };
yield return new object[] { (IntEnum)(-1) };
yield return new object[] { (IntEnum)0 };
yield return new object[] { (IntEnum)1 };
yield return new object[] { (IntEnum)int.MaxValue };
yield return new object[] { ulong.MinValue };
yield return new object[] { (ulong)1 };
yield return new object[] { ulong.MaxValue };
yield return new object[] { (ULongEnum)ulong.MinValue };
yield return new object[] { (ULongEnum)1 };
yield return new object[] { (ULongEnum)ulong.MaxValue };
yield return new object[] { long.MinValue };
yield return new object[] { (long)(-1) };
yield return new object[] { (long)0 };
yield return new object[] { (long)1 };
yield return new object[] { long.MaxValue };
yield return new object[] { (LongEnum)long.MinValue };
yield return new object[] { (LongEnum)(-1) };
yield return new object[] { (LongEnum)0 };
yield return new object[] { (LongEnum)1 };
yield return new object[] { (LongEnum)long.MaxValue };
yield return new object[] { float.MinValue };
yield return new object[] { (float)(-1) };
yield return new object[] { (float)0 };
yield return new object[] { (float)1 };
yield return new object[] { float.MaxValue };
yield return new object[] { float.PositiveInfinity };
yield return new object[] { float.NegativeInfinity };
yield return new object[] { float.NaN };
yield return new object[] { double.MinValue };
yield return new object[] { (double)(-1) };
yield return new object[] { (double)0 };
yield return new object[] { (double)1 };
yield return new object[] { double.MaxValue };
yield return new object[] { double.PositiveInfinity };
yield return new object[] { double.NegativeInfinity };
yield return new object[] { double.NaN };
yield return new object[] { decimal.MinValue };
yield return new object[] { (decimal)(-1) };
yield return new object[] { (decimal)0 };
yield return new object[] { (decimal)1 };
yield return new object[] { decimal.MaxValue };
yield return new object[] { true };
yield return new object[] { false };
yield return new object[] { new DateTime(10) };
yield return new object[] { new object() };
}
public static IEnumerable<object[]> FromString_TestData()
{
yield return new object[] { null, char.MinValue };
yield return new object[] { "", char.MinValue };
yield return new object[] { "-1", (char)45 };
yield return new object[] { "0", '0' };
yield return new object[] { "1", '1' };
yield return new object[] { "&h5", (char)38 };
yield return new object[] { "&h0", (char)38 };
yield return new object[] { "&o5", (char)38 };
yield return new object[] { " &o5", (char)32 };
yield return new object[] { "&o0", (char)38 };
yield return new object[] { "&", (char)38 };
yield return new object[] { "&a", (char)38 };
yield return new object[] { "&a0", (char)38 };
yield return new object[] { 1.1.ToString(), '1' };
yield return new object[] { "true", 't' };
yield return new object[] { "false", 'f' };
yield return new object[] { "invalid", 'i' };
yield return new object[] { "18446744073709551616", '1' };
yield return new object[] { "1844674407370955161618446744073709551616", '1' };
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.VisualBasic.Tests;
using System;
using System.Collections.Generic;
using Xunit;
namespace Microsoft.VisualBasic.CompilerServices.Tests
{
public class CharTypeTests
{
[Theory]
[MemberData(nameof(FromObject_TestData))]
[MemberData(nameof(FromString_TestData))]
public void FromObject(object value, char expected)
{
Assert.Equal(expected, CharType.FromObject(value));
}
[Theory]
[MemberData(nameof(FromObject_Invalid_TestData))]
public void FromObject_ThrowsInvalidCastException(object value)
{
Assert.Throws<InvalidCastException>(() => CharType.FromObject(value));
}
[Theory]
[MemberData(nameof(FromString_TestData))]
public void FromString(string value, char expected)
{
Assert.Equal(expected, CharType.FromString(value));
}
public static IEnumerable<object[]> FromObject_TestData()
{
// char.
yield return new object[] { char.MinValue, char.MinValue };
yield return new object[] { (char)1, (char)1 };
yield return new object[] { char.MaxValue, char.MaxValue };
// null.
yield return new object[] { null, char.MinValue };
}
public static IEnumerable<object[]> FromObject_Invalid_TestData()
{
yield return new object[] { byte.MinValue };
yield return new object[] { (byte)1 };
yield return new object[] { byte.MaxValue };
yield return new object[] { (ByteEnum)byte.MinValue };
yield return new object[] { (ByteEnum)1 };
yield return new object[] { (ByteEnum)byte.MaxValue };
yield return new object[] { sbyte.MinValue };
yield return new object[] { (sbyte)(-1) };
yield return new object[] { (sbyte)0 };
yield return new object[] { (sbyte)1 };
yield return new object[] { (sbyte)1 };
yield return new object[] { sbyte.MaxValue };
yield return new object[] { (SByteEnum)sbyte.MinValue };
yield return new object[] { (SByteEnum)(-1) };
yield return new object[] { (SByteEnum)0 };
yield return new object[] { (SByteEnum)1 };
yield return new object[] { (SByteEnum)1 };
yield return new object[] { (SByteEnum)sbyte.MaxValue };
yield return new object[] { ushort.MinValue };
yield return new object[] { (ushort)1 };
yield return new object[] { ushort.MaxValue };
yield return new object[] { (UShortEnum)ushort.MinValue };
yield return new object[] { (UShortEnum)1 };
yield return new object[] { (UShortEnum)ushort.MaxValue };
yield return new object[] { short.MinValue };
yield return new object[] { (short)(-1) };
yield return new object[] { (short)0 };
yield return new object[] { (short)1 };
yield return new object[] { short.MaxValue };
yield return new object[] { (ShortEnum)short.MinValue };
yield return new object[] { (ShortEnum)(-1) };
yield return new object[] { (ShortEnum)0 };
yield return new object[] { (ShortEnum)1 };
yield return new object[] { (ShortEnum)short.MaxValue };
yield return new object[] { uint.MinValue };
yield return new object[] { (uint)1 };
yield return new object[] { uint.MaxValue };
yield return new object[] { (UIntEnum)uint.MinValue };
yield return new object[] { (UIntEnum)1 };
yield return new object[] { (UIntEnum)uint.MaxValue };
yield return new object[] { int.MinValue };
yield return new object[] { -1 };
yield return new object[] { 0 };
yield return new object[] { 1 };
yield return new object[] { int.MaxValue };
yield return new object[] { (IntEnum)int.MinValue };
yield return new object[] { (IntEnum)(-1) };
yield return new object[] { (IntEnum)0 };
yield return new object[] { (IntEnum)1 };
yield return new object[] { (IntEnum)int.MaxValue };
yield return new object[] { ulong.MinValue };
yield return new object[] { (ulong)1 };
yield return new object[] { ulong.MaxValue };
yield return new object[] { (ULongEnum)ulong.MinValue };
yield return new object[] { (ULongEnum)1 };
yield return new object[] { (ULongEnum)ulong.MaxValue };
yield return new object[] { long.MinValue };
yield return new object[] { (long)(-1) };
yield return new object[] { (long)0 };
yield return new object[] { (long)1 };
yield return new object[] { long.MaxValue };
yield return new object[] { (LongEnum)long.MinValue };
yield return new object[] { (LongEnum)(-1) };
yield return new object[] { (LongEnum)0 };
yield return new object[] { (LongEnum)1 };
yield return new object[] { (LongEnum)long.MaxValue };
yield return new object[] { float.MinValue };
yield return new object[] { (float)(-1) };
yield return new object[] { (float)0 };
yield return new object[] { (float)1 };
yield return new object[] { float.MaxValue };
yield return new object[] { float.PositiveInfinity };
yield return new object[] { float.NegativeInfinity };
yield return new object[] { float.NaN };
yield return new object[] { double.MinValue };
yield return new object[] { (double)(-1) };
yield return new object[] { (double)0 };
yield return new object[] { (double)1 };
yield return new object[] { double.MaxValue };
yield return new object[] { double.PositiveInfinity };
yield return new object[] { double.NegativeInfinity };
yield return new object[] { double.NaN };
yield return new object[] { decimal.MinValue };
yield return new object[] { (decimal)(-1) };
yield return new object[] { (decimal)0 };
yield return new object[] { (decimal)1 };
yield return new object[] { decimal.MaxValue };
yield return new object[] { true };
yield return new object[] { false };
yield return new object[] { new DateTime(10) };
yield return new object[] { new object() };
}
public static IEnumerable<object[]> FromString_TestData()
{
yield return new object[] { null, char.MinValue };
yield return new object[] { "", char.MinValue };
yield return new object[] { "-1", (char)45 };
yield return new object[] { "0", '0' };
yield return new object[] { "1", '1' };
yield return new object[] { "&h5", (char)38 };
yield return new object[] { "&h0", (char)38 };
yield return new object[] { "&o5", (char)38 };
yield return new object[] { " &o5", (char)32 };
yield return new object[] { "&o0", (char)38 };
yield return new object[] { "&", (char)38 };
yield return new object[] { "&a", (char)38 };
yield return new object[] { "&a0", (char)38 };
yield return new object[] { 1.1.ToString(), '1' };
yield return new object[] { "true", 't' };
yield return new object[] { "false", 'f' };
yield return new object[] { "invalid", 'i' };
yield return new object[] { "18446744073709551616", '1' };
yield return new object[] { "1844674407370955161618446744073709551616", '1' };
}
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/Loader/classloader/TypeGeneratorTests/TypeGeneratorTest781/Generated781.ilproj | <Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<ItemGroup>
<Compile Include="Generated781.il" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TestFramework\TestFramework.csproj" />
</ItemGroup>
</Project>
| <Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<ItemGroup>
<Compile Include="Generated781.il" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TestFramework\TestFramework.csproj" />
</ItemGroup>
</Project>
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/Loader/classloader/TypeGeneratorTests/TypeGeneratorTest679/Generated679.ilproj | <Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<ItemGroup>
<Compile Include="Generated679.il" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TestFramework\TestFramework.csproj" />
</ItemGroup>
</Project>
| <Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<ItemGroup>
<Compile Include="Generated679.il" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TestFramework\TestFramework.csproj" />
</ItemGroup>
</Project>
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/Interop/PInvoke/Miscellaneous/CopyCtor/CopyCtorUtil.ilproj | <Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<OutputType>library</OutputType>
<CLRTestKind>SharedLibrary</CLRTestKind>
</PropertyGroup>
<ItemGroup>
<Compile Include="CopyCtorUtil.il" />
</ItemGroup>
</Project>
| <Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<OutputType>library</OutputType>
<CLRTestKind>SharedLibrary</CLRTestKind>
</PropertyGroup>
<ItemGroup>
<Compile Include="CopyCtorUtil.il" />
</ItemGroup>
</Project>
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/libraries/System.Runtime.Intrinsics/System.Runtime.Intrinsics.sln | Microsoft Visual Studio Solution File, Format Version 12.00
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib", "..\..\coreclr\System.Private.CoreLib\System.Private.CoreLib.csproj", "{5965CFFE-886A-418C-854F-5967D91DE914}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities.Unicode", "..\Common\tests\TestUtilities.Unicode\TestUtilities.Unicode.csproj", "{2644B828-C37C-45C1-933D-27E82DA0A098}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{EFF55B56-D92B-4573-94EA-AF5B3B001C34}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib.Generators", "..\System.Private.CoreLib\gen\System.Private.CoreLib.Generators.csproj", "{A4058388-97C1-492A-86A4-5240C4166BFF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryImportGenerator", "..\System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj", "{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Intrinsics", "ref\System.Runtime.Intrinsics.csproj", "{28B808CE-B1F8-4B05-9ADA-8884525BD87F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Intrinsics", "src\System.Runtime.Intrinsics.csproj", "{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Intrinsics.Tests", "tests\System.Runtime.Intrinsics.Tests.csproj", "{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F110DBFA-22D7-486A-993D-5461A57A1D50}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{C5014AA7-5C35-45D5-B7C6-48A5E93A758E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{A499E9EC-3C82-4B0A-AC49-111C706B1835}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{E7A9B89D-A9F5-40FD-93CA-CAF4522A80E0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
Checked|Any CPU = Checked|Any CPU
Checked|x64 = Checked|x64
Checked|x86 = Checked|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5965CFFE-886A-418C-854F-5967D91DE914}.Debug|Any CPU.ActiveCfg = Debug|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Debug|Any CPU.Build.0 = Debug|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Debug|x64.ActiveCfg = Debug|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Debug|x64.Build.0 = Debug|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Debug|x86.ActiveCfg = Debug|x86
{5965CFFE-886A-418C-854F-5967D91DE914}.Debug|x86.Build.0 = Debug|x86
{5965CFFE-886A-418C-854F-5967D91DE914}.Release|Any CPU.ActiveCfg = Release|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Release|Any CPU.Build.0 = Release|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Release|x64.ActiveCfg = Release|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Release|x64.Build.0 = Release|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Release|x86.ActiveCfg = Release|x86
{5965CFFE-886A-418C-854F-5967D91DE914}.Release|x86.Build.0 = Release|x86
{5965CFFE-886A-418C-854F-5967D91DE914}.Checked|Any CPU.ActiveCfg = Checked|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Checked|Any CPU.Build.0 = Checked|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x64.ActiveCfg = Checked|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x64.Build.0 = Checked|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x86.ActiveCfg = Checked|x86
{5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x86.Build.0 = Checked|x86
{2644B828-C37C-45C1-933D-27E82DA0A098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Debug|x64.ActiveCfg = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Debug|x64.Build.0 = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Debug|x86.ActiveCfg = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Debug|x86.Build.0 = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Release|Any CPU.Build.0 = Release|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Release|x64.ActiveCfg = Release|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Release|x64.Build.0 = Release|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Release|x86.ActiveCfg = Release|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Release|x86.Build.0 = Release|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Checked|Any CPU.Build.0 = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Checked|x64.ActiveCfg = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Checked|x64.Build.0 = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Checked|x86.ActiveCfg = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Checked|x86.Build.0 = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Debug|x64.ActiveCfg = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Debug|x64.Build.0 = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Debug|x86.ActiveCfg = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Debug|x86.Build.0 = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Release|Any CPU.Build.0 = Release|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Release|x64.ActiveCfg = Release|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Release|x64.Build.0 = Release|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Release|x86.ActiveCfg = Release|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Release|x86.Build.0 = Release|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Checked|Any CPU.Build.0 = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Checked|x64.ActiveCfg = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Checked|x64.Build.0 = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Checked|x86.ActiveCfg = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Checked|x86.Build.0 = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Debug|x64.ActiveCfg = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Debug|x64.Build.0 = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Debug|x86.ActiveCfg = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Debug|x86.Build.0 = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Release|Any CPU.Build.0 = Release|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Release|x64.ActiveCfg = Release|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Release|x64.Build.0 = Release|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Release|x86.ActiveCfg = Release|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Release|x86.Build.0 = Release|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Checked|Any CPU.Build.0 = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Checked|x64.ActiveCfg = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Checked|x64.Build.0 = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Checked|x86.ActiveCfg = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Checked|x86.Build.0 = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Debug|x64.ActiveCfg = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Debug|x64.Build.0 = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Debug|x86.ActiveCfg = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Debug|x86.Build.0 = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Release|Any CPU.Build.0 = Release|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Release|x64.ActiveCfg = Release|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Release|x64.Build.0 = Release|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Release|x86.ActiveCfg = Release|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Release|x86.Build.0 = Release|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Checked|Any CPU.Build.0 = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Checked|x64.ActiveCfg = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Checked|x64.Build.0 = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Checked|x86.ActiveCfg = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Checked|x86.Build.0 = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Debug|x64.ActiveCfg = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Debug|x64.Build.0 = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Debug|x86.ActiveCfg = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Debug|x86.Build.0 = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Release|Any CPU.Build.0 = Release|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Release|x64.ActiveCfg = Release|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Release|x64.Build.0 = Release|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Release|x86.ActiveCfg = Release|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Release|x86.Build.0 = Release|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Checked|Any CPU.Build.0 = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Checked|x64.ActiveCfg = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Checked|x64.Build.0 = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Checked|x86.ActiveCfg = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Checked|x86.Build.0 = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|x64.ActiveCfg = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|x64.Build.0 = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|x86.ActiveCfg = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|x86.Build.0 = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Release|Any CPU.Build.0 = Release|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Release|x64.ActiveCfg = Release|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Release|x64.Build.0 = Release|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Release|x86.ActiveCfg = Release|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Release|x86.Build.0 = Release|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Checked|Any CPU.Build.0 = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Checked|x64.ActiveCfg = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Checked|x64.Build.0 = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Checked|x86.ActiveCfg = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Checked|x86.Build.0 = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Debug|x64.ActiveCfg = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Debug|x64.Build.0 = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Debug|x86.ActiveCfg = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Debug|x86.Build.0 = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Release|Any CPU.Build.0 = Release|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Release|x64.ActiveCfg = Release|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Release|x64.Build.0 = Release|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Release|x86.ActiveCfg = Release|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Release|x86.Build.0 = Release|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Checked|Any CPU.Build.0 = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Checked|x64.ActiveCfg = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Checked|x64.Build.0 = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Checked|x86.ActiveCfg = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Checked|x86.Build.0 = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Debug|x64.ActiveCfg = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Debug|x64.Build.0 = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Debug|x86.ActiveCfg = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Debug|x86.Build.0 = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Release|Any CPU.Build.0 = Release|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Release|x64.ActiveCfg = Release|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Release|x64.Build.0 = Release|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Release|x86.ActiveCfg = Release|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Release|x86.Build.0 = Release|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Checked|Any CPU.Build.0 = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Checked|x64.ActiveCfg = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Checked|x64.Build.0 = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Checked|x86.ActiveCfg = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Checked|x86.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5965CFFE-886A-418C-854F-5967D91DE914} = {F110DBFA-22D7-486A-993D-5461A57A1D50}
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C} = {F110DBFA-22D7-486A-993D-5461A57A1D50}
{2644B828-C37C-45C1-933D-27E82DA0A098} = {C5014AA7-5C35-45D5-B7C6-48A5E93A758E}
{EFF55B56-D92B-4573-94EA-AF5B3B001C34} = {C5014AA7-5C35-45D5-B7C6-48A5E93A758E}
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19} = {C5014AA7-5C35-45D5-B7C6-48A5E93A758E}
{A4058388-97C1-492A-86A4-5240C4166BFF} = {A499E9EC-3C82-4B0A-AC49-111C706B1835}
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF} = {A499E9EC-3C82-4B0A-AC49-111C706B1835}
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7} = {A499E9EC-3C82-4B0A-AC49-111C706B1835}
{28B808CE-B1F8-4B05-9ADA-8884525BD87F} = {E7A9B89D-A9F5-40FD-93CA-CAF4522A80E0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9205DA5F-88A2-4045-9B31-9CC53CCF7550}
EndGlobalSection
EndGlobal
| Microsoft Visual Studio Solution File, Format Version 12.00
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib", "..\..\coreclr\System.Private.CoreLib\System.Private.CoreLib.csproj", "{5965CFFE-886A-418C-854F-5967D91DE914}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities.Unicode", "..\Common\tests\TestUtilities.Unicode\TestUtilities.Unicode.csproj", "{2644B828-C37C-45C1-933D-27E82DA0A098}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{EFF55B56-D92B-4573-94EA-AF5B3B001C34}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib.Generators", "..\System.Private.CoreLib\gen\System.Private.CoreLib.Generators.csproj", "{A4058388-97C1-492A-86A4-5240C4166BFF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryImportGenerator", "..\System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj", "{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Intrinsics", "ref\System.Runtime.Intrinsics.csproj", "{28B808CE-B1F8-4B05-9ADA-8884525BD87F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Intrinsics", "src\System.Runtime.Intrinsics.csproj", "{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.Intrinsics.Tests", "tests\System.Runtime.Intrinsics.Tests.csproj", "{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F110DBFA-22D7-486A-993D-5461A57A1D50}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{C5014AA7-5C35-45D5-B7C6-48A5E93A758E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{A499E9EC-3C82-4B0A-AC49-111C706B1835}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{E7A9B89D-A9F5-40FD-93CA-CAF4522A80E0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
Checked|Any CPU = Checked|Any CPU
Checked|x64 = Checked|x64
Checked|x86 = Checked|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5965CFFE-886A-418C-854F-5967D91DE914}.Debug|Any CPU.ActiveCfg = Debug|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Debug|Any CPU.Build.0 = Debug|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Debug|x64.ActiveCfg = Debug|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Debug|x64.Build.0 = Debug|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Debug|x86.ActiveCfg = Debug|x86
{5965CFFE-886A-418C-854F-5967D91DE914}.Debug|x86.Build.0 = Debug|x86
{5965CFFE-886A-418C-854F-5967D91DE914}.Release|Any CPU.ActiveCfg = Release|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Release|Any CPU.Build.0 = Release|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Release|x64.ActiveCfg = Release|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Release|x64.Build.0 = Release|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Release|x86.ActiveCfg = Release|x86
{5965CFFE-886A-418C-854F-5967D91DE914}.Release|x86.Build.0 = Release|x86
{5965CFFE-886A-418C-854F-5967D91DE914}.Checked|Any CPU.ActiveCfg = Checked|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Checked|Any CPU.Build.0 = Checked|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x64.ActiveCfg = Checked|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x64.Build.0 = Checked|x64
{5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x86.ActiveCfg = Checked|x86
{5965CFFE-886A-418C-854F-5967D91DE914}.Checked|x86.Build.0 = Checked|x86
{2644B828-C37C-45C1-933D-27E82DA0A098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Debug|x64.ActiveCfg = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Debug|x64.Build.0 = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Debug|x86.ActiveCfg = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Debug|x86.Build.0 = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Release|Any CPU.Build.0 = Release|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Release|x64.ActiveCfg = Release|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Release|x64.Build.0 = Release|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Release|x86.ActiveCfg = Release|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Release|x86.Build.0 = Release|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Checked|Any CPU.Build.0 = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Checked|x64.ActiveCfg = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Checked|x64.Build.0 = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Checked|x86.ActiveCfg = Debug|Any CPU
{2644B828-C37C-45C1-933D-27E82DA0A098}.Checked|x86.Build.0 = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Debug|x64.ActiveCfg = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Debug|x64.Build.0 = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Debug|x86.ActiveCfg = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Debug|x86.Build.0 = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Release|Any CPU.Build.0 = Release|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Release|x64.ActiveCfg = Release|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Release|x64.Build.0 = Release|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Release|x86.ActiveCfg = Release|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Release|x86.Build.0 = Release|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Checked|Any CPU.Build.0 = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Checked|x64.ActiveCfg = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Checked|x64.Build.0 = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Checked|x86.ActiveCfg = Debug|Any CPU
{EFF55B56-D92B-4573-94EA-AF5B3B001C34}.Checked|x86.Build.0 = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Debug|x64.ActiveCfg = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Debug|x64.Build.0 = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Debug|x86.ActiveCfg = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Debug|x86.Build.0 = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Release|Any CPU.Build.0 = Release|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Release|x64.ActiveCfg = Release|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Release|x64.Build.0 = Release|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Release|x86.ActiveCfg = Release|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Release|x86.Build.0 = Release|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Checked|Any CPU.Build.0 = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Checked|x64.ActiveCfg = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Checked|x64.Build.0 = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Checked|x86.ActiveCfg = Debug|Any CPU
{A4058388-97C1-492A-86A4-5240C4166BFF}.Checked|x86.Build.0 = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Debug|x64.ActiveCfg = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Debug|x64.Build.0 = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Debug|x86.ActiveCfg = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Debug|x86.Build.0 = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Release|Any CPU.Build.0 = Release|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Release|x64.ActiveCfg = Release|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Release|x64.Build.0 = Release|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Release|x86.ActiveCfg = Release|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Release|x86.Build.0 = Release|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Checked|Any CPU.Build.0 = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Checked|x64.ActiveCfg = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Checked|x64.Build.0 = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Checked|x86.ActiveCfg = Debug|Any CPU
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF}.Checked|x86.Build.0 = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Debug|x64.ActiveCfg = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Debug|x64.Build.0 = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Debug|x86.ActiveCfg = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Debug|x86.Build.0 = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Release|Any CPU.Build.0 = Release|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Release|x64.ActiveCfg = Release|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Release|x64.Build.0 = Release|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Release|x86.ActiveCfg = Release|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Release|x86.Build.0 = Release|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Checked|Any CPU.Build.0 = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Checked|x64.ActiveCfg = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Checked|x64.Build.0 = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Checked|x86.ActiveCfg = Debug|Any CPU
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7}.Checked|x86.Build.0 = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|x64.ActiveCfg = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|x64.Build.0 = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|x86.ActiveCfg = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Debug|x86.Build.0 = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Release|Any CPU.Build.0 = Release|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Release|x64.ActiveCfg = Release|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Release|x64.Build.0 = Release|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Release|x86.ActiveCfg = Release|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Release|x86.Build.0 = Release|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Checked|Any CPU.Build.0 = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Checked|x64.ActiveCfg = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Checked|x64.Build.0 = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Checked|x86.ActiveCfg = Debug|Any CPU
{28B808CE-B1F8-4B05-9ADA-8884525BD87F}.Checked|x86.Build.0 = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Debug|x64.ActiveCfg = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Debug|x64.Build.0 = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Debug|x86.ActiveCfg = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Debug|x86.Build.0 = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Release|Any CPU.Build.0 = Release|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Release|x64.ActiveCfg = Release|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Release|x64.Build.0 = Release|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Release|x86.ActiveCfg = Release|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Release|x86.Build.0 = Release|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Checked|Any CPU.Build.0 = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Checked|x64.ActiveCfg = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Checked|x64.Build.0 = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Checked|x86.ActiveCfg = Debug|Any CPU
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C}.Checked|x86.Build.0 = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Debug|x64.ActiveCfg = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Debug|x64.Build.0 = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Debug|x86.ActiveCfg = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Debug|x86.Build.0 = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Release|Any CPU.Build.0 = Release|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Release|x64.ActiveCfg = Release|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Release|x64.Build.0 = Release|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Release|x86.ActiveCfg = Release|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Release|x86.Build.0 = Release|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Checked|Any CPU.Build.0 = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Checked|x64.ActiveCfg = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Checked|x64.Build.0 = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Checked|x86.ActiveCfg = Debug|Any CPU
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19}.Checked|x86.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5965CFFE-886A-418C-854F-5967D91DE914} = {F110DBFA-22D7-486A-993D-5461A57A1D50}
{5AD79501-BEA5-48C7-B466-021A9DCB9D5C} = {F110DBFA-22D7-486A-993D-5461A57A1D50}
{2644B828-C37C-45C1-933D-27E82DA0A098} = {C5014AA7-5C35-45D5-B7C6-48A5E93A758E}
{EFF55B56-D92B-4573-94EA-AF5B3B001C34} = {C5014AA7-5C35-45D5-B7C6-48A5E93A758E}
{80AFB6EB-AB23-48A1-951C-76E6FEA29D19} = {C5014AA7-5C35-45D5-B7C6-48A5E93A758E}
{A4058388-97C1-492A-86A4-5240C4166BFF} = {A499E9EC-3C82-4B0A-AC49-111C706B1835}
{FE8C7C64-1759-4175-BA6E-03F8D6B7C6EF} = {A499E9EC-3C82-4B0A-AC49-111C706B1835}
{9A0BF7EC-AD07-44C8-9B70-9DACB2C894C7} = {A499E9EC-3C82-4B0A-AC49-111C706B1835}
{28B808CE-B1F8-4B05-9ADA-8884525BD87F} = {E7A9B89D-A9F5-40FD-93CA-CAF4522A80E0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9205DA5F-88A2-4045-9B31-9CC53CCF7550}
EndGlobalSection
EndGlobal
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/libraries/System.Private.Xml/tests/XmlSchema/TestFiles/TestData/bug338038_v3xml2.xsd | <xs:schema xmlns:xml="http://www.w3.org/XML/1998/namespace" targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:attribute name="lang" type="xs:language" />
<xs:attribute name="base" type="xs:anyURI" />
<xs:attribute default="preserve" name="space">
<xs:simpleType>
<xs:restriction base="xs:NCName">
<xs:enumeration value="default" />
<xs:enumeration value="preserve" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attributeGroup name="specialAttrs">
<xs:attribute ref="xml:lang" />
<xs:attribute ref="xml:space" />
<xs:attribute ref="xml:base" />
</xs:attributeGroup>
</xs:schema> | <xs:schema xmlns:xml="http://www.w3.org/XML/1998/namespace" targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:attribute name="lang" type="xs:language" />
<xs:attribute name="base" type="xs:anyURI" />
<xs:attribute default="preserve" name="space">
<xs:simpleType>
<xs:restriction base="xs:NCName">
<xs:enumeration value="default" />
<xs:enumeration value="preserve" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attributeGroup name="specialAttrs">
<xs:attribute ref="xml:lang" />
<xs:attribute ref="xml:space" />
<xs:attribute ref="xml:base" />
</xs:attributeGroup>
</xs:schema> | -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd.Arm64/MinAcross.Vector128.Int32.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/******************************************************************************
* This file is auto-generated from a template file by the GenerateTests.csx *
* script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make *
* changes, please update the corresponding template and run according to the *
* directions listed in the file. *
******************************************************************************/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
namespace JIT.HardwareIntrinsics.Arm
{
public static partial class Program
{
private static void MinAcross_Vector128_Int32()
{
var test = new SimpleUnaryOpTest__MinAcross_Vector128_Int32();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates basic functionality works, using Load
test.RunBasicScenario_Load();
}
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates calling via reflection works, using Load
test.RunReflectionScenario_Load();
}
// Validates passing a static member works
test.RunClsVarScenario();
if (AdvSimd.IsSupported)
{
// Validates passing a static member works, using pinning and Load
test.RunClsVarScenario_Load();
}
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates passing a local works, using Load
test.RunLclVarScenario_Load();
}
// Validates passing the field of a local class works
test.RunClassLclFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing the field of a local class works, using pinning and Load
test.RunClassLclFldScenario_Load();
}
// Validates passing an instance member of a class works
test.RunClassFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing an instance member of a class works, using pinning and Load
test.RunClassFldScenario_Load();
}
// Validates passing the field of a local struct works
test.RunStructLclFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing the field of a local struct works, using pinning and Load
test.RunStructLclFldScenario_Load();
}
// Validates passing an instance member of a struct works
test.RunStructFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing an instance member of a struct works, using pinning and Load
test.RunStructFldScenario_Load();
}
}
else
{
// Validates we throw on unsupported hardware
test.RunUnsupportedScenario();
}
if (!test.Succeeded)
{
throw new Exception("One or more scenarios did not complete as expected.");
}
}
}
public sealed unsafe class SimpleUnaryOpTest__MinAcross_Vector128_Int32
{
private struct DataTable
{
private byte[] inArray1;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Int32[] inArray1, Int32[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int32>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int32, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector128<Int32> _fld1;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref testStruct._fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>());
return testStruct;
}
public void RunStructFldScenario(SimpleUnaryOpTest__MinAcross_Vector128_Int32 testClass)
{
var result = AdvSimd.Arm64.MinAcross(_fld1);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(SimpleUnaryOpTest__MinAcross_Vector128_Int32 testClass)
{
fixed (Vector128<Int32>* pFld1 = &_fld1)
{
var result = AdvSimd.Arm64.MinAcross(
AdvSimd.LoadVector128((Int32*)(pFld1))
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32);
private static Int32[] _data1 = new Int32[Op1ElementCount];
private static Vector128<Int32> _clsVar1;
private Vector128<Int32> _fld1;
private DataTable _dataTable;
static SimpleUnaryOpTest__MinAcross_Vector128_Int32()
{
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>());
}
public SimpleUnaryOpTest__MinAcross_Vector128_Int32()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>());
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
_dataTable = new DataTable(_data1, new Int32[RetElementCount], LargestVectorSize);
}
public bool IsSupported => AdvSimd.Arm64.IsSupported;
public bool Succeeded { get; set; }
public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
var result = AdvSimd.Arm64.MinAcross(
Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
var result = AdvSimd.Arm64.MinAcross(
AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.MinAcross), new Type[] { typeof(Vector128<Int32>) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr)
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.MinAcross), new Type[] { typeof(Vector128<Int32>) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr))
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.Arm64.MinAcross(
_clsVar1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<Int32>* pClsVar1 = &_clsVar1)
{
var result = AdvSimd.Arm64.MinAcross(
AdvSimd.LoadVector128((Int32*)(pClsVar1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _dataTable.outArrayPtr);
}
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr);
var result = AdvSimd.Arm64.MinAcross(op1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var op1 = AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr));
var result = AdvSimd.Arm64.MinAcross(op1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new SimpleUnaryOpTest__MinAcross_Vector128_Int32();
var result = AdvSimd.Arm64.MinAcross(test._fld1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new SimpleUnaryOpTest__MinAcross_Vector128_Int32();
fixed (Vector128<Int32>* pFld1 = &test._fld1)
{
var result = AdvSimd.Arm64.MinAcross(
AdvSimd.LoadVector128((Int32*)(pFld1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.Arm64.MinAcross(_fld1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<Int32>* pFld1 = &_fld1)
{
var result = AdvSimd.Arm64.MinAcross(
AdvSimd.LoadVector128((Int32*)(pFld1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.Arm64.MinAcross(test._fld1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.Arm64.MinAcross(
AdvSimd.LoadVector128((Int32*)(&test._fld1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunStructFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
var test = TestStruct.Create();
test.RunStructFldScenario(this);
}
public void RunStructFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load));
var test = TestStruct.Create();
test.RunStructFldScenario_Load(this);
}
public void RunUnsupportedScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario));
bool succeeded = false;
try
{
RunBasicScenario_UnsafeRead();
}
catch (PlatformNotSupportedException)
{
succeeded = true;
}
if (!succeeded)
{
Succeeded = false;
}
}
private void ValidateResult(Vector128<Int32> op1, void* result, [CallerMemberName] string method = "")
{
Int32[] inArray1 = new Int32[Op1ElementCount];
Int32[] outArray = new Int32[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), op1);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>());
ValidateResult(inArray1, outArray, method);
}
private void ValidateResult(void* op1, void* result, [CallerMemberName] string method = "")
{
Int32[] inArray1 = new Int32[Op1ElementCount];
Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int32>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>());
ValidateResult(inArray1, outArray, method);
}
private void ValidateResult(Int32[] firstOp, Int32[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
if (Helpers.MinAcross(firstOp) != result[0])
{
succeeded = false;
}
else
{
for (int i = 1; i < RetElementCount; i++)
{
if (result[i] != 0)
{
succeeded = false;
break;
}
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.MinAcross)}<Int32>(Vector128<Int32>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/******************************************************************************
* This file is auto-generated from a template file by the GenerateTests.csx *
* script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make *
* changes, please update the corresponding template and run according to the *
* directions listed in the file. *
******************************************************************************/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
namespace JIT.HardwareIntrinsics.Arm
{
public static partial class Program
{
private static void MinAcross_Vector128_Int32()
{
var test = new SimpleUnaryOpTest__MinAcross_Vector128_Int32();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates basic functionality works, using Load
test.RunBasicScenario_Load();
}
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates calling via reflection works, using Load
test.RunReflectionScenario_Load();
}
// Validates passing a static member works
test.RunClsVarScenario();
if (AdvSimd.IsSupported)
{
// Validates passing a static member works, using pinning and Load
test.RunClsVarScenario_Load();
}
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates passing a local works, using Load
test.RunLclVarScenario_Load();
}
// Validates passing the field of a local class works
test.RunClassLclFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing the field of a local class works, using pinning and Load
test.RunClassLclFldScenario_Load();
}
// Validates passing an instance member of a class works
test.RunClassFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing an instance member of a class works, using pinning and Load
test.RunClassFldScenario_Load();
}
// Validates passing the field of a local struct works
test.RunStructLclFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing the field of a local struct works, using pinning and Load
test.RunStructLclFldScenario_Load();
}
// Validates passing an instance member of a struct works
test.RunStructFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing an instance member of a struct works, using pinning and Load
test.RunStructFldScenario_Load();
}
}
else
{
// Validates we throw on unsupported hardware
test.RunUnsupportedScenario();
}
if (!test.Succeeded)
{
throw new Exception("One or more scenarios did not complete as expected.");
}
}
}
public sealed unsafe class SimpleUnaryOpTest__MinAcross_Vector128_Int32
{
private struct DataTable
{
private byte[] inArray1;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Int32[] inArray1, Int32[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int32>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int32, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector128<Int32> _fld1;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref testStruct._fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>());
return testStruct;
}
public void RunStructFldScenario(SimpleUnaryOpTest__MinAcross_Vector128_Int32 testClass)
{
var result = AdvSimd.Arm64.MinAcross(_fld1);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(SimpleUnaryOpTest__MinAcross_Vector128_Int32 testClass)
{
fixed (Vector128<Int32>* pFld1 = &_fld1)
{
var result = AdvSimd.Arm64.MinAcross(
AdvSimd.LoadVector128((Int32*)(pFld1))
);
Unsafe.Write(testClass._dataTable.outArrayPtr, result);
testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32);
private static Int32[] _data1 = new Int32[Op1ElementCount];
private static Vector128<Int32> _clsVar1;
private Vector128<Int32> _fld1;
private DataTable _dataTable;
static SimpleUnaryOpTest__MinAcross_Vector128_Int32()
{
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>());
}
public SimpleUnaryOpTest__MinAcross_Vector128_Int32()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>());
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
_dataTable = new DataTable(_data1, new Int32[RetElementCount], LargestVectorSize);
}
public bool IsSupported => AdvSimd.Arm64.IsSupported;
public bool Succeeded { get; set; }
public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
var result = AdvSimd.Arm64.MinAcross(
Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
var result = AdvSimd.Arm64.MinAcross(
AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.MinAcross), new Type[] { typeof(Vector128<Int32>) })
.Invoke(null, new object[] {
Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr)
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.MinAcross), new Type[] { typeof(Vector128<Int32>) })
.Invoke(null, new object[] {
AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr))
});
Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
var result = AdvSimd.Arm64.MinAcross(
_clsVar1
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<Int32>* pClsVar1 = &_clsVar1)
{
var result = AdvSimd.Arm64.MinAcross(
AdvSimd.LoadVector128((Int32*)(pClsVar1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_clsVar1, _dataTable.outArrayPtr);
}
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr);
var result = AdvSimd.Arm64.MinAcross(op1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var op1 = AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr));
var result = AdvSimd.Arm64.MinAcross(op1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(op1, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new SimpleUnaryOpTest__MinAcross_Vector128_Int32();
var result = AdvSimd.Arm64.MinAcross(test._fld1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new SimpleUnaryOpTest__MinAcross_Vector128_Int32();
fixed (Vector128<Int32>* pFld1 = &test._fld1)
{
var result = AdvSimd.Arm64.MinAcross(
AdvSimd.LoadVector128((Int32*)(pFld1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
var result = AdvSimd.Arm64.MinAcross(_fld1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<Int32>* pFld1 = &_fld1)
{
var result = AdvSimd.Arm64.MinAcross(
AdvSimd.LoadVector128((Int32*)(pFld1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(_fld1, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
var result = AdvSimd.Arm64.MinAcross(test._fld1);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
var result = AdvSimd.Arm64.MinAcross(
AdvSimd.LoadVector128((Int32*)(&test._fld1))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunStructFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
var test = TestStruct.Create();
test.RunStructFldScenario(this);
}
public void RunStructFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load));
var test = TestStruct.Create();
test.RunStructFldScenario_Load(this);
}
public void RunUnsupportedScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario));
bool succeeded = false;
try
{
RunBasicScenario_UnsafeRead();
}
catch (PlatformNotSupportedException)
{
succeeded = true;
}
if (!succeeded)
{
Succeeded = false;
}
}
private void ValidateResult(Vector128<Int32> op1, void* result, [CallerMemberName] string method = "")
{
Int32[] inArray1 = new Int32[Op1ElementCount];
Int32[] outArray = new Int32[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), op1);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>());
ValidateResult(inArray1, outArray, method);
}
private void ValidateResult(void* op1, void* result, [CallerMemberName] string method = "")
{
Int32[] inArray1 = new Int32[Op1ElementCount];
Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int32>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>());
ValidateResult(inArray1, outArray, method);
}
private void ValidateResult(Int32[] firstOp, Int32[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
if (Helpers.MinAcross(firstOp) != result[0])
{
succeeded = false;
}
else
{
for (int i = 1; i < RetElementCount; i++)
{
if (result[i] != 0)
{
succeeded = false;
break;
}
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.MinAcross)}<Int32>(Vector128<Int32>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/JIT/Regression/Dev11/External/Dev11_243742/app.csproj | <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
<Optimize>False</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="app.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="dll.csproj" />
</ItemGroup>
</Project>
| <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
<Optimize>False</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="app.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="dll.csproj" />
</ItemGroup>
</Project>
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/JIT/Methodical/tailcall/test_3b_il_r.ilproj | <Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Include="test_3b.il" />
</ItemGroup>
</Project>
| <Project Sdk="Microsoft.NET.Sdk.IL">
<PropertyGroup>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Include="test_3b.il" />
</ItemGroup>
</Project>
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/mono/tests/generic-tailcall2.2.il | .assembly extern mscorlib
{
.ver 2:0:0:0
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
}
.assembly 'generic-tailcall2.2'
{
.custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = (
01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module 'generic-tailcall2.2.exe' // GUID = {84BAE15D-0B00-4F8D-8A54-1C09F6F10C96}
.class private auto ansi beforefieldinit Gen`1<T>
extends [mscorlib]System.Object
{
// method line 1
.method public hidebysig specialname rtspecialname
instance default void '.ctor' () cil managed
{
// Method begins at RVA 0x20ec
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void object::'.ctor'()
IL_0006: ret
} // end of method Gen`1::.ctor
// method line 2
.method public static hidebysig
default !T[] newArr () cil managed
{
// Method begins at RVA 0x20f4
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldc.i4.3
IL_0001: newarr !0
IL_0006: ret
} // end of method Gen`1::newArr
} // end of class Gen`1
.class public auto ansi beforefieldinit main
extends [mscorlib]System.Object
{
// method line 3
.method public hidebysig specialname rtspecialname
instance default void '.ctor' () cil managed
{
// Method begins at RVA 0x20fc
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void object::'.ctor'()
IL_0006: ret
} // end of method main::.ctor
// method line 4
.method public static hidebysig
default string[] work () cil managed
{
// Method begins at RVA 0x2104
// Code size 6 (0x6)
.maxstack 8
tail.
IL_0000: call !0[] class Gen`1<string>::newArr()
IL_0005: ret
} // end of method main::work
// method line 5
.method public static hidebysig
default int32 Main () cil managed
{
// Method begins at RVA 0x210c
.entrypoint
// Code size 31 (0x1f)
.maxstack 6
.locals init (
string[] V_0)
IL_0000: call string[] class main::work()
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: callvirt instance class [mscorlib]System.Type object::GetType()
IL_000c: ldtoken string[]
IL_0011: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0016: beq IL_001d
IL_001b: ldc.i4.1
IL_001c: ret
IL_001d: ldc.i4.0
IL_001e: ret
} // end of method main::Main
} // end of class main
| .assembly extern mscorlib
{
.ver 2:0:0:0
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
}
.assembly 'generic-tailcall2.2'
{
.custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = (
01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module 'generic-tailcall2.2.exe' // GUID = {84BAE15D-0B00-4F8D-8A54-1C09F6F10C96}
.class private auto ansi beforefieldinit Gen`1<T>
extends [mscorlib]System.Object
{
// method line 1
.method public hidebysig specialname rtspecialname
instance default void '.ctor' () cil managed
{
// Method begins at RVA 0x20ec
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void object::'.ctor'()
IL_0006: ret
} // end of method Gen`1::.ctor
// method line 2
.method public static hidebysig
default !T[] newArr () cil managed
{
// Method begins at RVA 0x20f4
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldc.i4.3
IL_0001: newarr !0
IL_0006: ret
} // end of method Gen`1::newArr
} // end of class Gen`1
.class public auto ansi beforefieldinit main
extends [mscorlib]System.Object
{
// method line 3
.method public hidebysig specialname rtspecialname
instance default void '.ctor' () cil managed
{
// Method begins at RVA 0x20fc
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void object::'.ctor'()
IL_0006: ret
} // end of method main::.ctor
// method line 4
.method public static hidebysig
default string[] work () cil managed
{
// Method begins at RVA 0x2104
// Code size 6 (0x6)
.maxstack 8
tail.
IL_0000: call !0[] class Gen`1<string>::newArr()
IL_0005: ret
} // end of method main::work
// method line 5
.method public static hidebysig
default int32 Main () cil managed
{
// Method begins at RVA 0x210c
.entrypoint
// Code size 31 (0x1f)
.maxstack 6
.locals init (
string[] V_0)
IL_0000: call string[] class main::work()
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: callvirt instance class [mscorlib]System.Type object::GetType()
IL_000c: ldtoken string[]
IL_0011: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
IL_0016: beq IL_001d
IL_001b: ldc.i4.1
IL_001c: ret
IL_001d: ldc.i4.0
IL_001e: ret
} // end of method main::Main
} // end of class main
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.SetProtocolOptions.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
using System.Security.Authentication;
using Microsoft.Win32.SafeHandles;
internal static partial class Interop
{
internal static partial class Ssl
{
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetProtocolOptions")]
internal static partial void SslCtxSetProtocolOptions(IntPtr ctx, SslProtocols protocols);
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetProtocolOptions")]
internal static partial void SslCtxSetProtocolOptions(SafeSslContextHandle ctx, SslProtocols protocols);
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
using System.Security.Authentication;
using Microsoft.Win32.SafeHandles;
internal static partial class Interop
{
internal static partial class Ssl
{
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetProtocolOptions")]
internal static partial void SslCtxSetProtocolOptions(IntPtr ctx, SslProtocols protocols);
[GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_SslCtxSetProtocolOptions")]
internal static partial void SslCtxSetProtocolOptions(SafeSslContextHandle ctx, SslProtocols protocols);
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/JIT/jit64/valuetypes/nullable/box-unbox/value/box-unbox-value029.csproj | <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Include="box-unbox-value029.cs" />
<Compile Include="..\structdef.cs" />
</ItemGroup>
</Project>
| <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Include="box-unbox-value029.cs" />
<Compile Include="..\structdef.cs" />
</ItemGroup>
</Project>
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//Internal.Runtime.Augments
//-------------------------------------------------
// Why does this exist?:
// Reflection.Execution cannot physically live in System.Private.CoreLib.dll
// as it has a dependency on System.Reflection.Metadata. Its inherently
// low-level nature means, however, it is closely tied to System.Private.CoreLib.dll.
// This contract provides the two-communication between those two .dll's.
//
//
// Implemented by:
// System.Private.CoreLib.dll
//
// Consumed by:
// Reflection.Execution.dll
using System;
using System.Runtime;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Threading;
using Internal.Runtime.CompilerHelpers;
using Internal.Runtime.CompilerServices;
namespace Internal.Runtime.Augments
{
using BinderBundle = System.Reflection.BinderBundle;
using Pointer = System.Reflection.Pointer;
[ReflectionBlocked]
public static class RuntimeAugments
{
/// <summary>
/// Callbacks used for metadata-based stack trace resolution.
/// </summary>
private static StackTraceMetadataCallbacks s_stackTraceMetadataCallbacks;
//==============================================================================================
// One-time initialization.
//==============================================================================================
[CLSCompliant(false)]
public static void Initialize(ReflectionExecutionDomainCallbacks callbacks)
{
s_reflectionExecutionDomainCallbacks = callbacks;
}
[CLSCompliant(false)]
public static void InitializeLookups(TypeLoaderCallbacks callbacks)
{
s_typeLoaderCallbacks = callbacks;
}
[CLSCompliant(false)]
public static void InitializeInteropLookups(InteropCallbacks callbacks)
{
s_interopCallbacks = callbacks;
}
[CLSCompliant(false)]
public static void InitializeStackTraceMetadataSupport(StackTraceMetadataCallbacks callbacks)
{
s_stackTraceMetadataCallbacks = callbacks;
}
//==============================================================================================
// Access to the underlying execution engine's object allocation routines.
//==============================================================================================
//
// Perform the equivalent of a "newobj", but without invoking any constructors. Other than the MethodTable, the result object is zero-initialized.
//
// Special cases:
//
// Strings: The .ctor performs both the construction and initialization
// and compiler special cases these.
//
// Nullable<T>: the boxed result is the underlying type rather than Nullable so the constructor
// cannot truly initialize it.
//
// In these cases, this helper returns "null" and ConstructorInfo.Invoke() must deal with these specially.
//
public static object NewObject(RuntimeTypeHandle typeHandle)
{
EETypePtr eeType = typeHandle.ToEETypePtr();
if (eeType.IsNullable
|| eeType == EETypePtr.EETypePtrOf<string>()
)
return null;
return RuntimeImports.RhNewObject(eeType);
}
//
// Helper API to perform the equivalent of a "newobj" for any MethodTable.
// Unlike the NewObject API, this is the raw version that does not special case any MethodTable, and should be used with
// caution for very specific scenarios.
//
public static object RawNewObject(RuntimeTypeHandle typeHandle)
{
return RuntimeImports.RhNewObject(typeHandle.ToEETypePtr());
}
//
// Perform the equivalent of a "newarr" The resulting array is zero-initialized.
//
public static Array NewArray(RuntimeTypeHandle typeHandleForArrayType, int count)
{
// Don't make the easy mistake of passing in the element MethodTable rather than the "array of element" MethodTable.
Debug.Assert(typeHandleForArrayType.ToEETypePtr().IsSzArray);
return RuntimeImports.RhNewArray(typeHandleForArrayType.ToEETypePtr(), count);
}
//
// Perform the equivalent of a "newarr" The resulting array is zero-initialized.
//
// Note that invoking NewMultiDimArray on a rank-1 array type is not the same thing as invoking NewArray().
//
// As a concession to the fact that we don't actually support non-zero lower bounds, "lowerBounds" accepts "null"
// to avoid unnecessary array allocations by the caller.
//
[UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode",
Justification = "The compiler ensures that if we have a TypeHandle of a Rank-1 MdArray, we also generated the SzArray.")]
public static unsafe Array NewMultiDimArray(RuntimeTypeHandle typeHandleForArrayType, int[] lengths, int[]? lowerBounds)
{
Debug.Assert(lengths != null);
Debug.Assert(lowerBounds == null || lowerBounds.Length == lengths.Length);
if (lowerBounds != null)
{
foreach (int lowerBound in lowerBounds)
{
if (lowerBound != 0)
throw new PlatformNotSupportedException(SR.PlatformNotSupported_NonZeroLowerBound);
}
}
if (lengths.Length == 1)
{
// We just checked above that all lower bounds are zero. In that case, we should actually allocate
// a new SzArray instead.
RuntimeTypeHandle elementTypeHandle = new RuntimeTypeHandle(typeHandleForArrayType.ToEETypePtr().ArrayElementType);
int length = lengths[0];
if (length < 0)
throw new OverflowException(); // For compat: we need to throw OverflowException(): Array.CreateInstance throws ArgumentOutOfRangeException()
return Array.CreateInstance(Type.GetTypeFromHandle(elementTypeHandle), length);
}
// Create a local copy of the lenghts that cannot be motified by the caller
int* pLengths = stackalloc int[lengths.Length];
for (int i = 0; i < lengths.Length; i++)
pLengths[i] = lengths[i];
return Array.NewMultiDimArray(typeHandleForArrayType.ToEETypePtr(), pLengths, lengths.Length);
}
//
// Helper to create an array from a newobj instruction
//
public static unsafe Array NewObjArray(RuntimeTypeHandle typeHandleForArrayType, int[] arguments)
{
EETypePtr eeTypePtr = typeHandleForArrayType.ToEETypePtr();
Debug.Assert(eeTypePtr.IsArray);
fixed (int* pArguments = arguments)
{
return ArrayHelpers.NewObjArray((IntPtr)eeTypePtr.ToPointer(), arguments.Length, pArguments);
}
}
public static ref byte GetSzArrayElementAddress(Array array, int index)
{
if ((uint)index >= (uint)array.Length)
throw new IndexOutOfRangeException();
ref byte start = ref Unsafe.As<RawArrayData>(array).Data;
return ref Unsafe.Add(ref start, (IntPtr)(nint)((nuint)index * array.ElementSize));
}
public static IntPtr GetAllocateObjectHelperForType(RuntimeTypeHandle type)
{
return RuntimeImports.RhGetRuntimeHelperForType(CreateEETypePtr(type), RuntimeHelperKind.AllocateObject);
}
public static IntPtr GetAllocateArrayHelperForType(RuntimeTypeHandle type)
{
return RuntimeImports.RhGetRuntimeHelperForType(CreateEETypePtr(type), RuntimeHelperKind.AllocateArray);
}
public static IntPtr GetCastingHelperForType(RuntimeTypeHandle type, bool throwing)
{
return RuntimeImports.RhGetRuntimeHelperForType(CreateEETypePtr(type),
throwing ? RuntimeHelperKind.CastClass : RuntimeHelperKind.IsInst);
}
public static IntPtr GetDispatchMapForType(RuntimeTypeHandle typeHandle)
{
return CreateEETypePtr(typeHandle).DispatchMap;
}
public static IntPtr GetFallbackDefaultConstructor()
{
return Activator.GetFallbackDefaultConstructor();
}
//
// Helper to create a delegate on a runtime-supplied type.
//
public static Delegate CreateDelegate(RuntimeTypeHandle typeHandleForDelegate, IntPtr ldftnResult, object thisObject, bool isStatic, bool isOpen)
{
return Delegate.CreateDelegate(typeHandleForDelegate.ToEETypePtr(), ldftnResult, thisObject, isStatic: isStatic, isOpen: isOpen);
}
//
// Helper to extract the artifact that uniquely identifies a method in the runtime mapping tables.
//
public static IntPtr GetDelegateLdFtnResult(Delegate d, out RuntimeTypeHandle typeOfFirstParameterIfInstanceDelegate, out bool isOpenResolver, out bool isInterpreterEntrypoint)
{
return d.GetFunctionPointer(out typeOfFirstParameterIfInstanceDelegate, out isOpenResolver, out isInterpreterEntrypoint);
}
public static void GetDelegateData(Delegate delegateObj, out object firstParameter, out object helperObject, out IntPtr extraFunctionPointerOrData, out IntPtr functionPointer)
{
firstParameter = delegateObj.m_firstParameter;
helperObject = delegateObj.m_helperObject;
extraFunctionPointerOrData = delegateObj.m_extraFunctionPointerOrData;
functionPointer = delegateObj.m_functionPointer;
}
public static int GetLoadedModules(TypeManagerHandle[] resultArray)
{
return Internal.Runtime.CompilerHelpers.StartupCodeHelpers.GetLoadedModules(resultArray);
}
public static IntPtr GetOSModuleFromPointer(IntPtr pointerVal)
{
return RuntimeImports.RhGetOSModuleFromPointer(pointerVal);
}
public static unsafe bool FindBlob(TypeManagerHandle typeManager, int blobId, IntPtr ppbBlob, IntPtr pcbBlob)
{
return RuntimeImports.RhFindBlob(typeManager, (uint)blobId, (byte**)ppbBlob, (uint*)pcbBlob);
}
public static IntPtr GetPointerFromTypeHandle(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().RawValue;
}
public static TypeManagerHandle GetModuleFromTypeHandle(RuntimeTypeHandle typeHandle)
{
return RuntimeImports.RhGetModuleFromEEType(GetPointerFromTypeHandle(typeHandle));
}
public static RuntimeTypeHandle CreateRuntimeTypeHandle(IntPtr ldTokenResult)
{
return new RuntimeTypeHandle(new EETypePtr(ldTokenResult));
}
public static unsafe void StoreValueTypeField(IntPtr address, object fieldValue, RuntimeTypeHandle fieldType)
{
RuntimeImports.RhUnbox(fieldValue, ref *(byte*)address, fieldType.ToEETypePtr());
}
public static unsafe ref byte GetRawData(object obj)
{
return ref obj.GetRawData();
}
public static unsafe object LoadValueTypeField(IntPtr address, RuntimeTypeHandle fieldType)
{
return RuntimeImports.RhBox(fieldType.ToEETypePtr(), ref *(byte*)address);
}
public static unsafe object LoadPointerTypeField(IntPtr address, RuntimeTypeHandle fieldType)
{
return Pointer.Box(*(void**)address, Type.GetTypeFromHandle(fieldType));
}
public static unsafe void StoreValueTypeField(ref byte address, object fieldValue, RuntimeTypeHandle fieldType)
{
RuntimeImports.RhUnbox(fieldValue, ref address, fieldType.ToEETypePtr());
}
public static unsafe void StoreValueTypeField(object obj, int fieldOffset, object fieldValue, RuntimeTypeHandle fieldType)
{
ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize));
RuntimeImports.RhUnbox(fieldValue, ref address, fieldType.ToEETypePtr());
}
public static unsafe object LoadValueTypeField(object obj, int fieldOffset, RuntimeTypeHandle fieldType)
{
ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize));
return RuntimeImports.RhBox(fieldType.ToEETypePtr(), ref address);
}
public static unsafe object LoadPointerTypeField(object obj, int fieldOffset, RuntimeTypeHandle fieldType)
{
ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize));
return Pointer.Box((void*)Unsafe.As<byte, IntPtr>(ref address), Type.GetTypeFromHandle(fieldType));
}
public static unsafe void StoreReferenceTypeField(IntPtr address, object fieldValue)
{
Volatile.Write<object>(ref Unsafe.As<IntPtr, object>(ref *(IntPtr*)address), fieldValue);
}
public static unsafe object LoadReferenceTypeField(IntPtr address)
{
return Volatile.Read<object>(ref Unsafe.As<IntPtr, object>(ref *(IntPtr*)address));
}
public static void StoreReferenceTypeField(object obj, int fieldOffset, object fieldValue)
{
ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize));
Volatile.Write<object>(ref Unsafe.As<byte, object>(ref address), fieldValue);
}
public static object LoadReferenceTypeField(object obj, int fieldOffset)
{
ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize));
return Unsafe.As<byte, object>(ref address);
}
[CLSCompliant(false)]
public static void StoreValueTypeFieldValueIntoValueType(TypedReference typedReference, int fieldOffset, object fieldValue, RuntimeTypeHandle fieldTypeHandle)
{
Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType);
RuntimeImports.RhUnbox(fieldValue, ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset), fieldTypeHandle.ToEETypePtr());
}
[CLSCompliant(false)]
public static object LoadValueTypeFieldValueFromValueType(TypedReference typedReference, int fieldOffset, RuntimeTypeHandle fieldTypeHandle)
{
Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType);
Debug.Assert(fieldTypeHandle.ToEETypePtr().IsValueType);
return RuntimeImports.RhBox(fieldTypeHandle.ToEETypePtr(), ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset));
}
[CLSCompliant(false)]
public static void StoreReferenceTypeFieldValueIntoValueType(TypedReference typedReference, int fieldOffset, object fieldValue)
{
Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType);
Unsafe.As<byte, object>(ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset)) = fieldValue;
}
[CLSCompliant(false)]
public static object LoadReferenceTypeFieldValueFromValueType(TypedReference typedReference, int fieldOffset)
{
Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType);
return Unsafe.As<byte, object>(ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset));
}
[CLSCompliant(false)]
public static unsafe object LoadPointerTypeFieldValueFromValueType(TypedReference typedReference, int fieldOffset, RuntimeTypeHandle fieldTypeHandle)
{
Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType);
Debug.Assert(fieldTypeHandle.ToEETypePtr().IsPointer);
IntPtr ptrValue = Unsafe.As<byte, IntPtr>(ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset));
return Pointer.Box((void*)ptrValue, Type.GetTypeFromHandle(fieldTypeHandle));
}
public static unsafe object GetThreadStaticBase(IntPtr cookie)
{
return ThreadStatics.GetThreadStaticBaseForType(*(TypeManagerSlot**)cookie, (int)*((IntPtr*)(cookie) + 1));
}
public static unsafe int ObjectHeaderSize => sizeof(EETypePtr);
[DebuggerGuidedStepThroughAttribute]
public static object CallDynamicInvokeMethod(
object thisPtr,
IntPtr methodToCall,
IntPtr dynamicInvokeHelperMethod,
IntPtr dynamicInvokeHelperGenericDictionary,
object defaultParametersContext,
object[] parameters,
BinderBundle binderBundle,
bool wrapInTargetInvocationException,
bool methodToCallIsThisCall)
{
object result = InvokeUtils.CallDynamicInvokeMethod(
thisPtr,
methodToCall,
dynamicInvokeHelperMethod,
dynamicInvokeHelperGenericDictionary,
defaultParametersContext,
parameters,
binderBundle,
wrapInTargetInvocationException,
methodToCallIsThisCall);
System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
return result;
}
public static unsafe void EnsureClassConstructorRun(IntPtr staticClassConstructionContext)
{
StaticClassConstructionContext* context = (StaticClassConstructionContext*)staticClassConstructionContext;
ClassConstructorRunner.EnsureClassConstructorRun(context);
}
public static object GetEnumValue(Enum e)
{
return e.GetValue();
}
public static Type GetEnumUnderlyingType(RuntimeTypeHandle enumTypeHandle)
{
Debug.Assert(enumTypeHandle.ToEETypePtr().IsEnum);
EETypeElementType elementType = enumTypeHandle.ToEETypePtr().ElementType;
switch (elementType)
{
case EETypeElementType.Boolean:
return typeof(bool);
case EETypeElementType.Char:
return typeof(char);
case EETypeElementType.SByte:
return typeof(sbyte);
case EETypeElementType.Byte:
return typeof(byte);
case EETypeElementType.Int16:
return typeof(short);
case EETypeElementType.UInt16:
return typeof(ushort);
case EETypeElementType.Int32:
return typeof(int);
case EETypeElementType.UInt32:
return typeof(uint);
case EETypeElementType.Int64:
return typeof(long);
case EETypeElementType.UInt64:
return typeof(ulong);
default:
throw new NotSupportedException();
}
}
public static RuntimeTypeHandle GetRelatedParameterTypeHandle(RuntimeTypeHandle parameterTypeHandle)
{
EETypePtr elementType = parameterTypeHandle.ToEETypePtr().ArrayElementType;
return new RuntimeTypeHandle(elementType);
}
public static bool IsValueType(RuntimeTypeHandle type)
{
return type.ToEETypePtr().IsValueType;
}
public static bool IsInterface(RuntimeTypeHandle type)
{
return type.ToEETypePtr().IsInterface;
}
public static unsafe object Box(RuntimeTypeHandle type, IntPtr address)
{
return RuntimeImports.RhBox(type.ToEETypePtr(), ref *(byte*)address);
}
// Used to mutate the first parameter in a closed static delegate. Note that this does no synchronization of any kind;
// use only on delegate instances you're sure nobody else is using.
public static void SetClosedStaticDelegateFirstParameter(Delegate del, object firstParameter)
{
del.SetClosedStaticFirstParameter(firstParameter);
}
//==============================================================================================
// Execution engine policies.
//==============================================================================================
//
// This returns a generic type with one generic parameter (representing the array element type)
// whose base type and interface list determines what TypeInfo.BaseType and TypeInfo.ImplementedInterfaces
// return for types that return true for IsArray.
//
public static RuntimeTypeHandle ProjectionTypeForArrays
{
get
{
return typeof(Array<>).TypeHandle;
}
}
//
// Returns the name of a virtual assembly we dump types private class library-Reflectable ty[es for internal class library use.
// The assembly binder visible to apps will never reveal this assembly.
//
// Note that this is not versionable as it is exposed as a const (and needs to be a const so we can used as a custom attribute argument - which
// is the other reason this string is not versionable.)
//
public const string HiddenScopeAssemblyName = "HiddenScope, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
//
// This implements the "IsAssignableFrom()" api for runtime-created types. By policy, we let the underlying runtime decide assignability.
//
public static bool IsAssignableFrom(RuntimeTypeHandle dstType, RuntimeTypeHandle srcType)
{
EETypePtr dstEEType = dstType.ToEETypePtr();
EETypePtr srcEEType = srcType.ToEETypePtr();
return RuntimeImports.AreTypesAssignable(srcEEType, dstEEType);
}
public static bool IsInstanceOfInterface(object obj, RuntimeTypeHandle interfaceTypeHandle)
{
return (null != RuntimeImports.IsInstanceOfInterface(interfaceTypeHandle.ToEETypePtr(), obj));
}
//
// Return a type's base type using the runtime type system. If the underlying runtime type system does not support
// this operation, return false and TypeInfo.BaseType will fall back to metadata.
//
// Note that "default(RuntimeTypeHandle)" is a valid result that will map to a null result. (For example, System.Object has a "null" base type.)
//
public static bool TryGetBaseType(RuntimeTypeHandle typeHandle, out RuntimeTypeHandle baseTypeHandle)
{
EETypePtr eeType = typeHandle.ToEETypePtr();
if (eeType.IsGenericTypeDefinition || eeType.IsPointer || eeType.IsByRef)
{
baseTypeHandle = default(RuntimeTypeHandle);
return false;
}
baseTypeHandle = new RuntimeTypeHandle(eeType.BaseType);
return true;
}
//
// Return a type's transitive implemeted interface list using the runtime type system. If the underlying runtime type system does not support
// this operation, return null and TypeInfo.ImplementedInterfaces will fall back to metadata. Note that returning null is not the same thing
// as returning a 0-length enumerable.
//
public static IEnumerable<RuntimeTypeHandle> TryGetImplementedInterfaces(RuntimeTypeHandle typeHandle)
{
EETypePtr eeType = typeHandle.ToEETypePtr();
if (eeType.IsGenericTypeDefinition || eeType.IsPointer || eeType.IsByRef)
return null;
LowLevelList<RuntimeTypeHandle> implementedInterfaces = new LowLevelList<RuntimeTypeHandle>();
for (int i = 0; i < eeType.Interfaces.Count; i++)
{
EETypePtr ifcEEType = eeType.Interfaces[i];
RuntimeTypeHandle ifcrth = new RuntimeTypeHandle(ifcEEType);
if (Callbacks.IsReflectionBlocked(ifcrth))
continue;
implementedInterfaces.Add(ifcrth);
}
return implementedInterfaces.ToArray();
}
private static RuntimeTypeHandle CreateRuntimeTypeHandle(EETypePtr eeType)
{
return new RuntimeTypeHandle(eeType);
}
private static EETypePtr CreateEETypePtr(RuntimeTypeHandle runtimeTypeHandle)
{
return runtimeTypeHandle.ToEETypePtr();
}
public static int GetGCDescSize(RuntimeTypeHandle typeHandle)
{
EETypePtr eeType = CreateEETypePtr(typeHandle);
return RuntimeImports.RhGetGCDescSize(eeType);
}
public static int GetInterfaceCount(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().Interfaces.Count;
}
public static RuntimeTypeHandle GetInterface(RuntimeTypeHandle typeHandle, int index)
{
EETypePtr eeInterface = typeHandle.ToEETypePtr().Interfaces[index];
return CreateRuntimeTypeHandle(eeInterface);
}
public static IntPtr NewInterfaceDispatchCell(RuntimeTypeHandle interfaceTypeHandle, int slotNumber)
{
EETypePtr eeInterfaceType = CreateEETypePtr(interfaceTypeHandle);
IntPtr cell = RuntimeImports.RhNewInterfaceDispatchCell(eeInterfaceType, slotNumber);
if (cell == IntPtr.Zero)
throw new OutOfMemoryException();
return cell;
}
public static int GetValueTypeSize(RuntimeTypeHandle typeHandle)
{
return (int)typeHandle.ToEETypePtr().ValueTypeSize;
}
[Intrinsic]
public static RuntimeTypeHandle GetCanonType(CanonTypeKind kind)
{
// Compiler needs to expand this. This is not expressible in IL.
throw new NotSupportedException();
}
public static RuntimeTypeHandle GetGenericDefinition(RuntimeTypeHandle typeHandle)
{
EETypePtr eeType = typeHandle.ToEETypePtr();
Debug.Assert(eeType.IsGeneric);
return new RuntimeTypeHandle(eeType.GenericDefinition);
}
public static RuntimeTypeHandle GetGenericArgument(RuntimeTypeHandle typeHandle, int argumentIndex)
{
EETypePtr eeType = typeHandle.ToEETypePtr();
Debug.Assert(eeType.IsGeneric);
return new RuntimeTypeHandle(eeType.Instantiation[argumentIndex]);
}
public static RuntimeTypeHandle GetGenericInstantiation(RuntimeTypeHandle typeHandle, out RuntimeTypeHandle[] genericTypeArgumentHandles)
{
EETypePtr eeType = typeHandle.ToEETypePtr();
Debug.Assert(eeType.IsGeneric);
var instantiation = eeType.Instantiation;
genericTypeArgumentHandles = new RuntimeTypeHandle[instantiation.Length];
for (int i = 0; i < instantiation.Length; i++)
{
genericTypeArgumentHandles[i] = new RuntimeTypeHandle(instantiation[i]);
}
return new RuntimeTypeHandle(eeType.GenericDefinition);
}
public static bool IsGenericType(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsGeneric;
}
public static bool IsArrayType(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsArray;
}
public static bool IsByRefLike(RuntimeTypeHandle typeHandle) => typeHandle.ToEETypePtr().IsByRefLike;
public static bool IsDynamicType(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsDynamicType;
}
public static bool HasCctor(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().HasCctor;
}
public static RuntimeTypeHandle RuntimeTypeHandleOf<T>()
{
return new RuntimeTypeHandle(EETypePtr.EETypePtrOf<T>());
}
public static IntPtr ResolveDispatchOnType(RuntimeTypeHandle instanceType, RuntimeTypeHandle interfaceType, int slot)
{
return RuntimeImports.RhResolveDispatchOnType(CreateEETypePtr(instanceType), CreateEETypePtr(interfaceType), checked((ushort)slot));
}
public static IntPtr ResolveDispatch(object instance, RuntimeTypeHandle interfaceType, int slot)
{
return RuntimeImports.RhResolveDispatch(instance, CreateEETypePtr(interfaceType), checked((ushort)slot));
}
public static IntPtr GVMLookupForSlot(RuntimeTypeHandle type, RuntimeMethodHandle slot)
{
return GenericVirtualMethodSupport.GVMLookupForSlot(type, slot);
}
public static bool IsUnmanagedPointerType(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsPointer;
}
public static bool IsByRefType(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsByRef;
}
public static bool IsGenericTypeDefinition(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsGenericTypeDefinition;
}
//
// This implements the equivalent of the desktop's InvokeUtil::CanPrimitiveWiden() routine.
//
public static bool CanPrimitiveWiden(RuntimeTypeHandle srcType, RuntimeTypeHandle dstType)
{
EETypePtr srcEEType = srcType.ToEETypePtr();
EETypePtr dstEEType = dstType.ToEETypePtr();
if (srcEEType.IsGenericTypeDefinition || dstEEType.IsGenericTypeDefinition)
return false;
if (srcEEType.IsPointer || dstEEType.IsPointer)
return false;
if (srcEEType.IsByRef || dstEEType.IsByRef)
return false;
if (!srcEEType.IsPrimitive)
return false;
if (!dstEEType.IsPrimitive)
return false;
if (!srcEEType.CorElementTypeInfo.CanWidenTo(dstEEType.CorElementType))
return false;
return true;
}
public static object CheckArgument(object srcObject, RuntimeTypeHandle dstType, BinderBundle binderBundle)
{
return InvokeUtils.CheckArgument(srcObject, dstType, binderBundle);
}
// FieldInfo.SetValueDirect() has a completely different set of rules on how to coerce the argument from
// the other Reflection api.
public static object CheckArgumentForDirectFieldAccess(object srcObject, RuntimeTypeHandle dstType)
{
return InvokeUtils.CheckArgument(srcObject, dstType.ToEETypePtr(), InvokeUtils.CheckArgumentSemantics.SetFieldDirect, binderBundle: null);
}
public static bool IsAssignable(object srcObject, RuntimeTypeHandle dstType)
{
EETypePtr srcEEType = srcObject.EETypePtr;
return RuntimeImports.AreTypesAssignable(srcEEType, dstType.ToEETypePtr());
}
//==============================================================================================
// Nullable<> support
//==============================================================================================
public static bool IsNullable(RuntimeTypeHandle declaringTypeHandle)
{
return declaringTypeHandle.ToEETypePtr().IsNullable;
}
public static RuntimeTypeHandle GetNullableType(RuntimeTypeHandle nullableType)
{
EETypePtr theT = nullableType.ToEETypePtr().NullableType;
return new RuntimeTypeHandle(theT);
}
/// <summary>
/// Locate the file path for a given native application module.
/// </summary>
/// <param name="ip">Address inside the module</param>
/// <param name="moduleBase">Module base address</param>
public static unsafe string TryGetFullPathToApplicationModule(IntPtr ip, out IntPtr moduleBase)
{
moduleBase = RuntimeImports.RhGetOSModuleFromPointer(ip);
if (moduleBase == IntPtr.Zero)
return null;
#if TARGET_UNIX
// RhGetModuleFileName on Unix calls dladdr that accepts any ip. Avoid the redundant lookup
// and pass the ip into RhGetModuleFileName directly. Also, older versions of Musl have a bug
// that leads to crash with the redundant lookup.
byte* pModuleNameUtf8;
int numUtf8Chars = RuntimeImports.RhGetModuleFileName(ip, out pModuleNameUtf8);
string modulePath = System.Text.Encoding.UTF8.GetString(pModuleNameUtf8, numUtf8Chars);
#else // TARGET_UNIX
char* pModuleName;
int numChars = RuntimeImports.RhGetModuleFileName(moduleBase, out pModuleName);
string modulePath = new string(pModuleName, 0, numChars);
#endif // TARGET_UNIX
return modulePath;
}
public static IntPtr GetRuntimeTypeHandleRawValue(RuntimeTypeHandle runtimeTypeHandle)
{
return runtimeTypeHandle.RawValue;
}
// if functionPointer points at an import or unboxing stub, find the target of the stub
public static IntPtr GetCodeTarget(IntPtr functionPointer)
{
return RuntimeImports.RhGetCodeTarget(functionPointer);
}
public static IntPtr GetTargetOfUnboxingAndInstantiatingStub(IntPtr functionPointer)
{
return RuntimeImports.RhGetTargetOfUnboxingAndInstantiatingStub(functionPointer);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static IntPtr RuntimeCacheLookup(IntPtr context, IntPtr signature, RuntimeObjectFactory factory, object contextObject, out IntPtr auxResult)
{
return TypeLoaderExports.RuntimeCacheLookupInCache(context, signature, factory, contextObject, out auxResult);
}
//==============================================================================================
// Internals
//==============================================================================================
[CLSCompliant(false)]
public static ReflectionExecutionDomainCallbacks CallbacksIfAvailable
{
get
{
return s_reflectionExecutionDomainCallbacks;
}
}
[CLSCompliant(false)]
public static ReflectionExecutionDomainCallbacks Callbacks
{
get
{
ReflectionExecutionDomainCallbacks callbacks = s_reflectionExecutionDomainCallbacks;
Debug.Assert(callbacks != null);
return callbacks;
}
}
internal static TypeLoaderCallbacks TypeLoaderCallbacksIfAvailable
{
get
{
return s_typeLoaderCallbacks;
}
}
internal static TypeLoaderCallbacks TypeLoaderCallbacks
{
get
{
TypeLoaderCallbacks callbacks = s_typeLoaderCallbacks;
Debug.Assert(callbacks != null);
return callbacks;
}
}
internal static InteropCallbacks InteropCallbacks
{
get
{
InteropCallbacks callbacks = s_interopCallbacks;
Debug.Assert(callbacks != null);
return callbacks;
}
}
internal static StackTraceMetadataCallbacks StackTraceCallbacksIfAvailable
{
get
{
return s_stackTraceMetadataCallbacks;
}
}
public static string TryGetMethodDisplayStringFromIp(IntPtr ip)
{
StackTraceMetadataCallbacks callbacks = StackTraceCallbacksIfAvailable;
if (callbacks == null)
return null;
ip = RuntimeImports.RhFindMethodStartAddress(ip);
if (ip == IntPtr.Zero)
return null;
return callbacks.TryGetMethodNameFromStartAddress(ip);
}
private static volatile ReflectionExecutionDomainCallbacks s_reflectionExecutionDomainCallbacks;
private static TypeLoaderCallbacks s_typeLoaderCallbacks;
private static InteropCallbacks s_interopCallbacks;
public static void ReportUnhandledException(Exception exception)
{
RuntimeExceptionHelpers.ReportUnhandledException(exception);
}
public static unsafe RuntimeTypeHandle GetRuntimeTypeHandleFromObjectReference(object obj)
{
return new RuntimeTypeHandle(obj.EETypePtr);
}
// Move memory which may be on the heap which may have object references in it.
// In general, a memcpy on the heap is unsafe, but this is able to perform the
// correct write barrier such that the GC is not incorrectly impacted.
public static unsafe void BulkMoveWithWriteBarrier(IntPtr dmem, IntPtr smem, int size)
{
RuntimeImports.RhBulkMoveWithWriteBarrier(ref *(byte*)dmem.ToPointer(), ref *(byte*)smem.ToPointer(), (uint)size);
}
public static IntPtr GetUniversalTransitionThunk()
{
return RuntimeImports.RhGetUniversalTransitionThunk();
}
public static object CreateThunksHeap(IntPtr commonStubAddress)
{
object newHeap = RuntimeImports.RhCreateThunksHeap(commonStubAddress);
if (newHeap == null)
throw new OutOfMemoryException();
return newHeap;
}
public static IntPtr AllocateThunk(object thunksHeap)
{
IntPtr newThunk = RuntimeImports.RhAllocateThunk(thunksHeap);
if (newThunk == IntPtr.Zero)
throw new OutOfMemoryException();
TypeLoaderCallbacks.RegisterThunk(newThunk);
return newThunk;
}
public static void FreeThunk(object thunksHeap, IntPtr thunkAddress)
{
RuntimeImports.RhFreeThunk(thunksHeap, thunkAddress);
}
public static void SetThunkData(object thunksHeap, IntPtr thunkAddress, IntPtr context, IntPtr target)
{
RuntimeImports.RhSetThunkData(thunksHeap, thunkAddress, context, target);
}
public static bool TryGetThunkData(object thunksHeap, IntPtr thunkAddress, out IntPtr context, out IntPtr target)
{
return RuntimeImports.RhTryGetThunkData(thunksHeap, thunkAddress, out context, out target);
}
public static int GetThunkSize()
{
return RuntimeImports.RhGetThunkSize();
}
[DebuggerStepThrough]
/* TEMP workaround due to bug 149078 */
[MethodImpl(MethodImplOptions.NoInlining)]
public static void CallDescrWorker(IntPtr callDescr)
{
RuntimeImports.RhCallDescrWorker(callDescr);
}
[DebuggerStepThrough]
/* TEMP workaround due to bug 149078 */
[MethodImpl(MethodImplOptions.NoInlining)]
public static void CallDescrWorkerNative(IntPtr callDescr)
{
RuntimeImports.RhCallDescrWorkerNative(callDescr);
}
public static Delegate CreateObjectArrayDelegate(Type delegateType, Func<object?[], object?> invoker)
{
return Delegate.CreateObjectArrayDelegate(delegateType, invoker);
}
internal static class RawCalliHelper
{
[DebuggerHidden]
[DebuggerStepThrough]
[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
public static unsafe void Call<T>(System.IntPtr pfn, void* arg1, ref T arg2)
=> ((delegate*<void*, ref T, void>)pfn)(arg1, ref arg2);
[DebuggerHidden]
[DebuggerStepThrough]
[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
public static unsafe void Call<T, U>(System.IntPtr pfn, void* arg1, ref T arg2, ref U arg3)
=> ((delegate*<void*, ref T, ref U, void>)pfn)(arg1, ref arg2, ref arg3);
}
/// <summary>
/// This method creates a conservatively reported region and calls a function
/// while that region is conservatively reported.
/// </summary>
/// <param name="cbBuffer">size of buffer to allocated (buffer size described in bytes)</param>
/// <param name="pfnTargetToInvoke">function pointer to execute.</param>
/// <param name="context">context to pass to inner function. Passed by-ref to allow for efficient use of a struct as a context.</param>
[DebuggerGuidedStepThroughAttribute]
[CLSCompliant(false)]
public static unsafe void RunFunctionWithConservativelyReportedBuffer<T>(int cbBuffer, delegate*<void*, ref T, void> pfnTargetToInvoke, ref T context)
{
RuntimeImports.ConservativelyReportedRegionDesc regionDesc = default;
RunFunctionWithConservativelyReportedBufferInternal(cbBuffer, pfnTargetToInvoke, ref context, ref regionDesc);
System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
}
// Marked as no-inlining so optimizer won't decide to optimize away the fact that pRegionDesc is a pinned interior pointer.
// This function must also not make a p/invoke transition, or the fixed statement reporting of the ConservativelyReportedRegionDesc
// will be ignored.
[DebuggerGuidedStepThroughAttribute]
[MethodImpl(MethodImplOptions.NoInlining)]
private static unsafe void RunFunctionWithConservativelyReportedBufferInternal<T>(int cbBuffer, delegate*<void*, ref T, void> pfnTargetToInvoke, ref T context, ref RuntimeImports.ConservativelyReportedRegionDesc regionDesc)
{
fixed (RuntimeImports.ConservativelyReportedRegionDesc* pRegionDesc = ®ionDesc)
{
int cbBufferAligned = (cbBuffer + (sizeof(IntPtr) - 1)) & ~(sizeof(IntPtr) - 1);
// The conservative region must be IntPtr aligned, and a multiple of IntPtr in size
void* region = stackalloc IntPtr[cbBufferAligned / sizeof(IntPtr)];
Buffer.ZeroMemory((byte*)region, (nuint)cbBufferAligned);
RuntimeImports.RhInitializeConservativeReportingRegion(pRegionDesc, region, cbBufferAligned);
RawCalliHelper.Call<T>((IntPtr)pfnTargetToInvoke, region, ref context);
System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
RuntimeImports.RhDisableConservativeReportingRegion(pRegionDesc);
}
}
/// <summary>
/// This method creates a conservatively reported region and calls a function
/// while that region is conservatively reported.
/// </summary>
/// <param name="cbBuffer">size of buffer to allocated (buffer size described in bytes)</param>
/// <param name="pfnTargetToInvoke">function pointer to execute.</param>
/// <param name="context">context to pass to inner function. Passed by-ref to allow for efficient use of a struct as a context.</param>
/// <param name="context2">context2 to pass to inner function. Passed by-ref to allow for efficient use of a struct as a context.</param>
[DebuggerGuidedStepThroughAttribute]
[CLSCompliant(false)]
public static unsafe void RunFunctionWithConservativelyReportedBuffer<T, U>(int cbBuffer, delegate*<void*, ref T, ref U, void> pfnTargetToInvoke, ref T context, ref U context2)
{
RuntimeImports.ConservativelyReportedRegionDesc regionDesc = default;
RunFunctionWithConservativelyReportedBufferInternal(cbBuffer, pfnTargetToInvoke, ref context, ref context2, ref regionDesc);
System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
}
// Marked as no-inlining so optimizer won't decide to optimize away the fact that pRegionDesc is a pinned interior pointer.
// This function must also not make a p/invoke transition, or the fixed statement reporting of the ConservativelyReportedRegionDesc
// will be ignored.
[DebuggerGuidedStepThroughAttribute]
[MethodImpl(MethodImplOptions.NoInlining)]
private static unsafe void RunFunctionWithConservativelyReportedBufferInternal<T, U>(int cbBuffer, delegate*<void*, ref T, ref U, void> pfnTargetToInvoke, ref T context, ref U context2, ref RuntimeImports.ConservativelyReportedRegionDesc regionDesc)
{
fixed (RuntimeImports.ConservativelyReportedRegionDesc* pRegionDesc = ®ionDesc)
{
int cbBufferAligned = (cbBuffer + (sizeof(IntPtr) - 1)) & ~(sizeof(IntPtr) - 1);
// The conservative region must be IntPtr aligned, and a multiple of IntPtr in size
void* region = stackalloc IntPtr[cbBufferAligned / sizeof(IntPtr)];
Buffer.ZeroMemory((byte*)region, (nuint)cbBufferAligned);
RuntimeImports.RhInitializeConservativeReportingRegion(pRegionDesc, region, cbBufferAligned);
RawCalliHelper.Call<T, U>((IntPtr)pfnTargetToInvoke, region, ref context, ref context2);
System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
RuntimeImports.RhDisableConservativeReportingRegion(pRegionDesc);
}
}
public static string GetLastResortString(RuntimeTypeHandle typeHandle)
{
return typeHandle.LastResortToString;
}
public static IntPtr RhHandleAlloc(object value, GCHandleType type)
{
return RuntimeImports.RhHandleAlloc(value, type);
}
public static void RhHandleFree(IntPtr handle)
{
RuntimeImports.RhHandleFree(handle);
}
public static IntPtr RhpGetCurrentThread()
{
return RuntimeImports.RhpGetCurrentThread();
}
public static void RhpInitiateThreadAbort(IntPtr thread, bool rude)
{
Exception ex = new ThreadAbortException();
RuntimeImports.RhpInitiateThreadAbort(thread, ex, rude);
}
public static void RhpCancelThreadAbort(IntPtr thread)
{
RuntimeImports.RhpCancelThreadAbort(thread);
}
public static void RhYield()
{
RuntimeImports.RhYield();
}
public static bool SupportsRelativePointers
{
get
{
return Internal.Runtime.MethodTable.SupportsRelativePointers;
}
}
public static bool IsPrimitive(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsPrimitive && !typeHandle.ToEETypePtr().IsEnum;
}
public static byte[] ComputePublicKeyToken(byte[] publicKey)
{
return System.Reflection.AssemblyNameHelpers.ComputePublicKeyToken(publicKey);
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//Internal.Runtime.Augments
//-------------------------------------------------
// Why does this exist?:
// Reflection.Execution cannot physically live in System.Private.CoreLib.dll
// as it has a dependency on System.Reflection.Metadata. Its inherently
// low-level nature means, however, it is closely tied to System.Private.CoreLib.dll.
// This contract provides the two-communication between those two .dll's.
//
//
// Implemented by:
// System.Private.CoreLib.dll
//
// Consumed by:
// Reflection.Execution.dll
using System;
using System.Runtime;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Threading;
using Internal.Runtime.CompilerHelpers;
using Internal.Runtime.CompilerServices;
namespace Internal.Runtime.Augments
{
using BinderBundle = System.Reflection.BinderBundle;
using Pointer = System.Reflection.Pointer;
[ReflectionBlocked]
public static class RuntimeAugments
{
/// <summary>
/// Callbacks used for metadata-based stack trace resolution.
/// </summary>
private static StackTraceMetadataCallbacks s_stackTraceMetadataCallbacks;
//==============================================================================================
// One-time initialization.
//==============================================================================================
[CLSCompliant(false)]
public static void Initialize(ReflectionExecutionDomainCallbacks callbacks)
{
s_reflectionExecutionDomainCallbacks = callbacks;
}
[CLSCompliant(false)]
public static void InitializeLookups(TypeLoaderCallbacks callbacks)
{
s_typeLoaderCallbacks = callbacks;
}
[CLSCompliant(false)]
public static void InitializeInteropLookups(InteropCallbacks callbacks)
{
s_interopCallbacks = callbacks;
}
[CLSCompliant(false)]
public static void InitializeStackTraceMetadataSupport(StackTraceMetadataCallbacks callbacks)
{
s_stackTraceMetadataCallbacks = callbacks;
}
//==============================================================================================
// Access to the underlying execution engine's object allocation routines.
//==============================================================================================
//
// Perform the equivalent of a "newobj", but without invoking any constructors. Other than the MethodTable, the result object is zero-initialized.
//
// Special cases:
//
// Strings: The .ctor performs both the construction and initialization
// and compiler special cases these.
//
// Nullable<T>: the boxed result is the underlying type rather than Nullable so the constructor
// cannot truly initialize it.
//
// In these cases, this helper returns "null" and ConstructorInfo.Invoke() must deal with these specially.
//
public static object NewObject(RuntimeTypeHandle typeHandle)
{
EETypePtr eeType = typeHandle.ToEETypePtr();
if (eeType.IsNullable
|| eeType == EETypePtr.EETypePtrOf<string>()
)
return null;
return RuntimeImports.RhNewObject(eeType);
}
//
// Helper API to perform the equivalent of a "newobj" for any MethodTable.
// Unlike the NewObject API, this is the raw version that does not special case any MethodTable, and should be used with
// caution for very specific scenarios.
//
public static object RawNewObject(RuntimeTypeHandle typeHandle)
{
return RuntimeImports.RhNewObject(typeHandle.ToEETypePtr());
}
//
// Perform the equivalent of a "newarr" The resulting array is zero-initialized.
//
public static Array NewArray(RuntimeTypeHandle typeHandleForArrayType, int count)
{
// Don't make the easy mistake of passing in the element MethodTable rather than the "array of element" MethodTable.
Debug.Assert(typeHandleForArrayType.ToEETypePtr().IsSzArray);
return RuntimeImports.RhNewArray(typeHandleForArrayType.ToEETypePtr(), count);
}
//
// Perform the equivalent of a "newarr" The resulting array is zero-initialized.
//
// Note that invoking NewMultiDimArray on a rank-1 array type is not the same thing as invoking NewArray().
//
// As a concession to the fact that we don't actually support non-zero lower bounds, "lowerBounds" accepts "null"
// to avoid unnecessary array allocations by the caller.
//
[UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode",
Justification = "The compiler ensures that if we have a TypeHandle of a Rank-1 MdArray, we also generated the SzArray.")]
public static unsafe Array NewMultiDimArray(RuntimeTypeHandle typeHandleForArrayType, int[] lengths, int[]? lowerBounds)
{
Debug.Assert(lengths != null);
Debug.Assert(lowerBounds == null || lowerBounds.Length == lengths.Length);
if (lowerBounds != null)
{
foreach (int lowerBound in lowerBounds)
{
if (lowerBound != 0)
throw new PlatformNotSupportedException(SR.PlatformNotSupported_NonZeroLowerBound);
}
}
if (lengths.Length == 1)
{
// We just checked above that all lower bounds are zero. In that case, we should actually allocate
// a new SzArray instead.
RuntimeTypeHandle elementTypeHandle = new RuntimeTypeHandle(typeHandleForArrayType.ToEETypePtr().ArrayElementType);
int length = lengths[0];
if (length < 0)
throw new OverflowException(); // For compat: we need to throw OverflowException(): Array.CreateInstance throws ArgumentOutOfRangeException()
return Array.CreateInstance(Type.GetTypeFromHandle(elementTypeHandle), length);
}
// Create a local copy of the lenghts that cannot be motified by the caller
int* pLengths = stackalloc int[lengths.Length];
for (int i = 0; i < lengths.Length; i++)
pLengths[i] = lengths[i];
return Array.NewMultiDimArray(typeHandleForArrayType.ToEETypePtr(), pLengths, lengths.Length);
}
//
// Helper to create an array from a newobj instruction
//
public static unsafe Array NewObjArray(RuntimeTypeHandle typeHandleForArrayType, int[] arguments)
{
EETypePtr eeTypePtr = typeHandleForArrayType.ToEETypePtr();
Debug.Assert(eeTypePtr.IsArray);
fixed (int* pArguments = arguments)
{
return ArrayHelpers.NewObjArray((IntPtr)eeTypePtr.ToPointer(), arguments.Length, pArguments);
}
}
public static ref byte GetSzArrayElementAddress(Array array, int index)
{
if ((uint)index >= (uint)array.Length)
throw new IndexOutOfRangeException();
ref byte start = ref Unsafe.As<RawArrayData>(array).Data;
return ref Unsafe.Add(ref start, (IntPtr)(nint)((nuint)index * array.ElementSize));
}
public static IntPtr GetAllocateObjectHelperForType(RuntimeTypeHandle type)
{
return RuntimeImports.RhGetRuntimeHelperForType(CreateEETypePtr(type), RuntimeHelperKind.AllocateObject);
}
public static IntPtr GetAllocateArrayHelperForType(RuntimeTypeHandle type)
{
return RuntimeImports.RhGetRuntimeHelperForType(CreateEETypePtr(type), RuntimeHelperKind.AllocateArray);
}
public static IntPtr GetCastingHelperForType(RuntimeTypeHandle type, bool throwing)
{
return RuntimeImports.RhGetRuntimeHelperForType(CreateEETypePtr(type),
throwing ? RuntimeHelperKind.CastClass : RuntimeHelperKind.IsInst);
}
public static IntPtr GetDispatchMapForType(RuntimeTypeHandle typeHandle)
{
return CreateEETypePtr(typeHandle).DispatchMap;
}
public static IntPtr GetFallbackDefaultConstructor()
{
return Activator.GetFallbackDefaultConstructor();
}
//
// Helper to create a delegate on a runtime-supplied type.
//
public static Delegate CreateDelegate(RuntimeTypeHandle typeHandleForDelegate, IntPtr ldftnResult, object thisObject, bool isStatic, bool isOpen)
{
return Delegate.CreateDelegate(typeHandleForDelegate.ToEETypePtr(), ldftnResult, thisObject, isStatic: isStatic, isOpen: isOpen);
}
//
// Helper to extract the artifact that uniquely identifies a method in the runtime mapping tables.
//
public static IntPtr GetDelegateLdFtnResult(Delegate d, out RuntimeTypeHandle typeOfFirstParameterIfInstanceDelegate, out bool isOpenResolver, out bool isInterpreterEntrypoint)
{
return d.GetFunctionPointer(out typeOfFirstParameterIfInstanceDelegate, out isOpenResolver, out isInterpreterEntrypoint);
}
public static void GetDelegateData(Delegate delegateObj, out object firstParameter, out object helperObject, out IntPtr extraFunctionPointerOrData, out IntPtr functionPointer)
{
firstParameter = delegateObj.m_firstParameter;
helperObject = delegateObj.m_helperObject;
extraFunctionPointerOrData = delegateObj.m_extraFunctionPointerOrData;
functionPointer = delegateObj.m_functionPointer;
}
public static int GetLoadedModules(TypeManagerHandle[] resultArray)
{
return Internal.Runtime.CompilerHelpers.StartupCodeHelpers.GetLoadedModules(resultArray);
}
public static IntPtr GetOSModuleFromPointer(IntPtr pointerVal)
{
return RuntimeImports.RhGetOSModuleFromPointer(pointerVal);
}
public static unsafe bool FindBlob(TypeManagerHandle typeManager, int blobId, IntPtr ppbBlob, IntPtr pcbBlob)
{
return RuntimeImports.RhFindBlob(typeManager, (uint)blobId, (byte**)ppbBlob, (uint*)pcbBlob);
}
public static IntPtr GetPointerFromTypeHandle(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().RawValue;
}
public static TypeManagerHandle GetModuleFromTypeHandle(RuntimeTypeHandle typeHandle)
{
return RuntimeImports.RhGetModuleFromEEType(GetPointerFromTypeHandle(typeHandle));
}
public static RuntimeTypeHandle CreateRuntimeTypeHandle(IntPtr ldTokenResult)
{
return new RuntimeTypeHandle(new EETypePtr(ldTokenResult));
}
public static unsafe void StoreValueTypeField(IntPtr address, object fieldValue, RuntimeTypeHandle fieldType)
{
RuntimeImports.RhUnbox(fieldValue, ref *(byte*)address, fieldType.ToEETypePtr());
}
public static unsafe ref byte GetRawData(object obj)
{
return ref obj.GetRawData();
}
public static unsafe object LoadValueTypeField(IntPtr address, RuntimeTypeHandle fieldType)
{
return RuntimeImports.RhBox(fieldType.ToEETypePtr(), ref *(byte*)address);
}
public static unsafe object LoadPointerTypeField(IntPtr address, RuntimeTypeHandle fieldType)
{
return Pointer.Box(*(void**)address, Type.GetTypeFromHandle(fieldType));
}
public static unsafe void StoreValueTypeField(ref byte address, object fieldValue, RuntimeTypeHandle fieldType)
{
RuntimeImports.RhUnbox(fieldValue, ref address, fieldType.ToEETypePtr());
}
public static unsafe void StoreValueTypeField(object obj, int fieldOffset, object fieldValue, RuntimeTypeHandle fieldType)
{
ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize));
RuntimeImports.RhUnbox(fieldValue, ref address, fieldType.ToEETypePtr());
}
public static unsafe object LoadValueTypeField(object obj, int fieldOffset, RuntimeTypeHandle fieldType)
{
ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize));
return RuntimeImports.RhBox(fieldType.ToEETypePtr(), ref address);
}
public static unsafe object LoadPointerTypeField(object obj, int fieldOffset, RuntimeTypeHandle fieldType)
{
ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize));
return Pointer.Box((void*)Unsafe.As<byte, IntPtr>(ref address), Type.GetTypeFromHandle(fieldType));
}
public static unsafe void StoreReferenceTypeField(IntPtr address, object fieldValue)
{
Volatile.Write<object>(ref Unsafe.As<IntPtr, object>(ref *(IntPtr*)address), fieldValue);
}
public static unsafe object LoadReferenceTypeField(IntPtr address)
{
return Volatile.Read<object>(ref Unsafe.As<IntPtr, object>(ref *(IntPtr*)address));
}
public static void StoreReferenceTypeField(object obj, int fieldOffset, object fieldValue)
{
ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize));
Volatile.Write<object>(ref Unsafe.As<byte, object>(ref address), fieldValue);
}
public static object LoadReferenceTypeField(object obj, int fieldOffset)
{
ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize));
return Unsafe.As<byte, object>(ref address);
}
[CLSCompliant(false)]
public static void StoreValueTypeFieldValueIntoValueType(TypedReference typedReference, int fieldOffset, object fieldValue, RuntimeTypeHandle fieldTypeHandle)
{
Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType);
RuntimeImports.RhUnbox(fieldValue, ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset), fieldTypeHandle.ToEETypePtr());
}
[CLSCompliant(false)]
public static object LoadValueTypeFieldValueFromValueType(TypedReference typedReference, int fieldOffset, RuntimeTypeHandle fieldTypeHandle)
{
Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType);
Debug.Assert(fieldTypeHandle.ToEETypePtr().IsValueType);
return RuntimeImports.RhBox(fieldTypeHandle.ToEETypePtr(), ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset));
}
[CLSCompliant(false)]
public static void StoreReferenceTypeFieldValueIntoValueType(TypedReference typedReference, int fieldOffset, object fieldValue)
{
Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType);
Unsafe.As<byte, object>(ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset)) = fieldValue;
}
[CLSCompliant(false)]
public static object LoadReferenceTypeFieldValueFromValueType(TypedReference typedReference, int fieldOffset)
{
Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType);
return Unsafe.As<byte, object>(ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset));
}
[CLSCompliant(false)]
public static unsafe object LoadPointerTypeFieldValueFromValueType(TypedReference typedReference, int fieldOffset, RuntimeTypeHandle fieldTypeHandle)
{
Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType);
Debug.Assert(fieldTypeHandle.ToEETypePtr().IsPointer);
IntPtr ptrValue = Unsafe.As<byte, IntPtr>(ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset));
return Pointer.Box((void*)ptrValue, Type.GetTypeFromHandle(fieldTypeHandle));
}
public static unsafe object GetThreadStaticBase(IntPtr cookie)
{
return ThreadStatics.GetThreadStaticBaseForType(*(TypeManagerSlot**)cookie, (int)*((IntPtr*)(cookie) + 1));
}
public static unsafe int ObjectHeaderSize => sizeof(EETypePtr);
[DebuggerGuidedStepThroughAttribute]
public static object CallDynamicInvokeMethod(
object thisPtr,
IntPtr methodToCall,
IntPtr dynamicInvokeHelperMethod,
IntPtr dynamicInvokeHelperGenericDictionary,
object defaultParametersContext,
object[] parameters,
BinderBundle binderBundle,
bool wrapInTargetInvocationException,
bool methodToCallIsThisCall)
{
object result = InvokeUtils.CallDynamicInvokeMethod(
thisPtr,
methodToCall,
dynamicInvokeHelperMethod,
dynamicInvokeHelperGenericDictionary,
defaultParametersContext,
parameters,
binderBundle,
wrapInTargetInvocationException,
methodToCallIsThisCall);
System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
return result;
}
public static unsafe void EnsureClassConstructorRun(IntPtr staticClassConstructionContext)
{
StaticClassConstructionContext* context = (StaticClassConstructionContext*)staticClassConstructionContext;
ClassConstructorRunner.EnsureClassConstructorRun(context);
}
public static object GetEnumValue(Enum e)
{
return e.GetValue();
}
public static Type GetEnumUnderlyingType(RuntimeTypeHandle enumTypeHandle)
{
Debug.Assert(enumTypeHandle.ToEETypePtr().IsEnum);
EETypeElementType elementType = enumTypeHandle.ToEETypePtr().ElementType;
switch (elementType)
{
case EETypeElementType.Boolean:
return typeof(bool);
case EETypeElementType.Char:
return typeof(char);
case EETypeElementType.SByte:
return typeof(sbyte);
case EETypeElementType.Byte:
return typeof(byte);
case EETypeElementType.Int16:
return typeof(short);
case EETypeElementType.UInt16:
return typeof(ushort);
case EETypeElementType.Int32:
return typeof(int);
case EETypeElementType.UInt32:
return typeof(uint);
case EETypeElementType.Int64:
return typeof(long);
case EETypeElementType.UInt64:
return typeof(ulong);
default:
throw new NotSupportedException();
}
}
public static RuntimeTypeHandle GetRelatedParameterTypeHandle(RuntimeTypeHandle parameterTypeHandle)
{
EETypePtr elementType = parameterTypeHandle.ToEETypePtr().ArrayElementType;
return new RuntimeTypeHandle(elementType);
}
public static bool IsValueType(RuntimeTypeHandle type)
{
return type.ToEETypePtr().IsValueType;
}
public static bool IsInterface(RuntimeTypeHandle type)
{
return type.ToEETypePtr().IsInterface;
}
public static unsafe object Box(RuntimeTypeHandle type, IntPtr address)
{
return RuntimeImports.RhBox(type.ToEETypePtr(), ref *(byte*)address);
}
// Used to mutate the first parameter in a closed static delegate. Note that this does no synchronization of any kind;
// use only on delegate instances you're sure nobody else is using.
public static void SetClosedStaticDelegateFirstParameter(Delegate del, object firstParameter)
{
del.SetClosedStaticFirstParameter(firstParameter);
}
//==============================================================================================
// Execution engine policies.
//==============================================================================================
//
// This returns a generic type with one generic parameter (representing the array element type)
// whose base type and interface list determines what TypeInfo.BaseType and TypeInfo.ImplementedInterfaces
// return for types that return true for IsArray.
//
public static RuntimeTypeHandle ProjectionTypeForArrays
{
get
{
return typeof(Array<>).TypeHandle;
}
}
//
// Returns the name of a virtual assembly we dump types private class library-Reflectable ty[es for internal class library use.
// The assembly binder visible to apps will never reveal this assembly.
//
// Note that this is not versionable as it is exposed as a const (and needs to be a const so we can used as a custom attribute argument - which
// is the other reason this string is not versionable.)
//
public const string HiddenScopeAssemblyName = "HiddenScope, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
//
// This implements the "IsAssignableFrom()" api for runtime-created types. By policy, we let the underlying runtime decide assignability.
//
public static bool IsAssignableFrom(RuntimeTypeHandle dstType, RuntimeTypeHandle srcType)
{
EETypePtr dstEEType = dstType.ToEETypePtr();
EETypePtr srcEEType = srcType.ToEETypePtr();
return RuntimeImports.AreTypesAssignable(srcEEType, dstEEType);
}
public static bool IsInstanceOfInterface(object obj, RuntimeTypeHandle interfaceTypeHandle)
{
return (null != RuntimeImports.IsInstanceOfInterface(interfaceTypeHandle.ToEETypePtr(), obj));
}
//
// Return a type's base type using the runtime type system. If the underlying runtime type system does not support
// this operation, return false and TypeInfo.BaseType will fall back to metadata.
//
// Note that "default(RuntimeTypeHandle)" is a valid result that will map to a null result. (For example, System.Object has a "null" base type.)
//
public static bool TryGetBaseType(RuntimeTypeHandle typeHandle, out RuntimeTypeHandle baseTypeHandle)
{
EETypePtr eeType = typeHandle.ToEETypePtr();
if (eeType.IsGenericTypeDefinition || eeType.IsPointer || eeType.IsByRef)
{
baseTypeHandle = default(RuntimeTypeHandle);
return false;
}
baseTypeHandle = new RuntimeTypeHandle(eeType.BaseType);
return true;
}
//
// Return a type's transitive implemeted interface list using the runtime type system. If the underlying runtime type system does not support
// this operation, return null and TypeInfo.ImplementedInterfaces will fall back to metadata. Note that returning null is not the same thing
// as returning a 0-length enumerable.
//
public static IEnumerable<RuntimeTypeHandle> TryGetImplementedInterfaces(RuntimeTypeHandle typeHandle)
{
EETypePtr eeType = typeHandle.ToEETypePtr();
if (eeType.IsGenericTypeDefinition || eeType.IsPointer || eeType.IsByRef)
return null;
LowLevelList<RuntimeTypeHandle> implementedInterfaces = new LowLevelList<RuntimeTypeHandle>();
for (int i = 0; i < eeType.Interfaces.Count; i++)
{
EETypePtr ifcEEType = eeType.Interfaces[i];
RuntimeTypeHandle ifcrth = new RuntimeTypeHandle(ifcEEType);
if (Callbacks.IsReflectionBlocked(ifcrth))
continue;
implementedInterfaces.Add(ifcrth);
}
return implementedInterfaces.ToArray();
}
private static RuntimeTypeHandle CreateRuntimeTypeHandle(EETypePtr eeType)
{
return new RuntimeTypeHandle(eeType);
}
private static EETypePtr CreateEETypePtr(RuntimeTypeHandle runtimeTypeHandle)
{
return runtimeTypeHandle.ToEETypePtr();
}
public static int GetGCDescSize(RuntimeTypeHandle typeHandle)
{
EETypePtr eeType = CreateEETypePtr(typeHandle);
return RuntimeImports.RhGetGCDescSize(eeType);
}
public static int GetInterfaceCount(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().Interfaces.Count;
}
public static RuntimeTypeHandle GetInterface(RuntimeTypeHandle typeHandle, int index)
{
EETypePtr eeInterface = typeHandle.ToEETypePtr().Interfaces[index];
return CreateRuntimeTypeHandle(eeInterface);
}
public static IntPtr NewInterfaceDispatchCell(RuntimeTypeHandle interfaceTypeHandle, int slotNumber)
{
EETypePtr eeInterfaceType = CreateEETypePtr(interfaceTypeHandle);
IntPtr cell = RuntimeImports.RhNewInterfaceDispatchCell(eeInterfaceType, slotNumber);
if (cell == IntPtr.Zero)
throw new OutOfMemoryException();
return cell;
}
public static int GetValueTypeSize(RuntimeTypeHandle typeHandle)
{
return (int)typeHandle.ToEETypePtr().ValueTypeSize;
}
[Intrinsic]
public static RuntimeTypeHandle GetCanonType(CanonTypeKind kind)
{
// Compiler needs to expand this. This is not expressible in IL.
throw new NotSupportedException();
}
public static RuntimeTypeHandle GetGenericDefinition(RuntimeTypeHandle typeHandle)
{
EETypePtr eeType = typeHandle.ToEETypePtr();
Debug.Assert(eeType.IsGeneric);
return new RuntimeTypeHandle(eeType.GenericDefinition);
}
public static RuntimeTypeHandle GetGenericArgument(RuntimeTypeHandle typeHandle, int argumentIndex)
{
EETypePtr eeType = typeHandle.ToEETypePtr();
Debug.Assert(eeType.IsGeneric);
return new RuntimeTypeHandle(eeType.Instantiation[argumentIndex]);
}
public static RuntimeTypeHandle GetGenericInstantiation(RuntimeTypeHandle typeHandle, out RuntimeTypeHandle[] genericTypeArgumentHandles)
{
EETypePtr eeType = typeHandle.ToEETypePtr();
Debug.Assert(eeType.IsGeneric);
var instantiation = eeType.Instantiation;
genericTypeArgumentHandles = new RuntimeTypeHandle[instantiation.Length];
for (int i = 0; i < instantiation.Length; i++)
{
genericTypeArgumentHandles[i] = new RuntimeTypeHandle(instantiation[i]);
}
return new RuntimeTypeHandle(eeType.GenericDefinition);
}
public static bool IsGenericType(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsGeneric;
}
public static bool IsArrayType(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsArray;
}
public static bool IsByRefLike(RuntimeTypeHandle typeHandle) => typeHandle.ToEETypePtr().IsByRefLike;
public static bool IsDynamicType(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsDynamicType;
}
public static bool HasCctor(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().HasCctor;
}
public static RuntimeTypeHandle RuntimeTypeHandleOf<T>()
{
return new RuntimeTypeHandle(EETypePtr.EETypePtrOf<T>());
}
public static IntPtr ResolveDispatchOnType(RuntimeTypeHandle instanceType, RuntimeTypeHandle interfaceType, int slot)
{
return RuntimeImports.RhResolveDispatchOnType(CreateEETypePtr(instanceType), CreateEETypePtr(interfaceType), checked((ushort)slot));
}
public static IntPtr ResolveDispatch(object instance, RuntimeTypeHandle interfaceType, int slot)
{
return RuntimeImports.RhResolveDispatch(instance, CreateEETypePtr(interfaceType), checked((ushort)slot));
}
public static IntPtr GVMLookupForSlot(RuntimeTypeHandle type, RuntimeMethodHandle slot)
{
return GenericVirtualMethodSupport.GVMLookupForSlot(type, slot);
}
public static bool IsUnmanagedPointerType(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsPointer;
}
public static bool IsByRefType(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsByRef;
}
public static bool IsGenericTypeDefinition(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsGenericTypeDefinition;
}
//
// This implements the equivalent of the desktop's InvokeUtil::CanPrimitiveWiden() routine.
//
public static bool CanPrimitiveWiden(RuntimeTypeHandle srcType, RuntimeTypeHandle dstType)
{
EETypePtr srcEEType = srcType.ToEETypePtr();
EETypePtr dstEEType = dstType.ToEETypePtr();
if (srcEEType.IsGenericTypeDefinition || dstEEType.IsGenericTypeDefinition)
return false;
if (srcEEType.IsPointer || dstEEType.IsPointer)
return false;
if (srcEEType.IsByRef || dstEEType.IsByRef)
return false;
if (!srcEEType.IsPrimitive)
return false;
if (!dstEEType.IsPrimitive)
return false;
if (!srcEEType.CorElementTypeInfo.CanWidenTo(dstEEType.CorElementType))
return false;
return true;
}
public static object CheckArgument(object srcObject, RuntimeTypeHandle dstType, BinderBundle binderBundle)
{
return InvokeUtils.CheckArgument(srcObject, dstType, binderBundle);
}
// FieldInfo.SetValueDirect() has a completely different set of rules on how to coerce the argument from
// the other Reflection api.
public static object CheckArgumentForDirectFieldAccess(object srcObject, RuntimeTypeHandle dstType)
{
return InvokeUtils.CheckArgument(srcObject, dstType.ToEETypePtr(), InvokeUtils.CheckArgumentSemantics.SetFieldDirect, binderBundle: null);
}
public static bool IsAssignable(object srcObject, RuntimeTypeHandle dstType)
{
EETypePtr srcEEType = srcObject.EETypePtr;
return RuntimeImports.AreTypesAssignable(srcEEType, dstType.ToEETypePtr());
}
//==============================================================================================
// Nullable<> support
//==============================================================================================
public static bool IsNullable(RuntimeTypeHandle declaringTypeHandle)
{
return declaringTypeHandle.ToEETypePtr().IsNullable;
}
public static RuntimeTypeHandle GetNullableType(RuntimeTypeHandle nullableType)
{
EETypePtr theT = nullableType.ToEETypePtr().NullableType;
return new RuntimeTypeHandle(theT);
}
/// <summary>
/// Locate the file path for a given native application module.
/// </summary>
/// <param name="ip">Address inside the module</param>
/// <param name="moduleBase">Module base address</param>
public static unsafe string TryGetFullPathToApplicationModule(IntPtr ip, out IntPtr moduleBase)
{
moduleBase = RuntimeImports.RhGetOSModuleFromPointer(ip);
if (moduleBase == IntPtr.Zero)
return null;
#if TARGET_UNIX
// RhGetModuleFileName on Unix calls dladdr that accepts any ip. Avoid the redundant lookup
// and pass the ip into RhGetModuleFileName directly. Also, older versions of Musl have a bug
// that leads to crash with the redundant lookup.
byte* pModuleNameUtf8;
int numUtf8Chars = RuntimeImports.RhGetModuleFileName(ip, out pModuleNameUtf8);
string modulePath = System.Text.Encoding.UTF8.GetString(pModuleNameUtf8, numUtf8Chars);
#else // TARGET_UNIX
char* pModuleName;
int numChars = RuntimeImports.RhGetModuleFileName(moduleBase, out pModuleName);
string modulePath = new string(pModuleName, 0, numChars);
#endif // TARGET_UNIX
return modulePath;
}
public static IntPtr GetRuntimeTypeHandleRawValue(RuntimeTypeHandle runtimeTypeHandle)
{
return runtimeTypeHandle.RawValue;
}
// if functionPointer points at an import or unboxing stub, find the target of the stub
public static IntPtr GetCodeTarget(IntPtr functionPointer)
{
return RuntimeImports.RhGetCodeTarget(functionPointer);
}
public static IntPtr GetTargetOfUnboxingAndInstantiatingStub(IntPtr functionPointer)
{
return RuntimeImports.RhGetTargetOfUnboxingAndInstantiatingStub(functionPointer);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static IntPtr RuntimeCacheLookup(IntPtr context, IntPtr signature, RuntimeObjectFactory factory, object contextObject, out IntPtr auxResult)
{
return TypeLoaderExports.RuntimeCacheLookupInCache(context, signature, factory, contextObject, out auxResult);
}
//==============================================================================================
// Internals
//==============================================================================================
[CLSCompliant(false)]
public static ReflectionExecutionDomainCallbacks CallbacksIfAvailable
{
get
{
return s_reflectionExecutionDomainCallbacks;
}
}
[CLSCompliant(false)]
public static ReflectionExecutionDomainCallbacks Callbacks
{
get
{
ReflectionExecutionDomainCallbacks callbacks = s_reflectionExecutionDomainCallbacks;
Debug.Assert(callbacks != null);
return callbacks;
}
}
internal static TypeLoaderCallbacks TypeLoaderCallbacksIfAvailable
{
get
{
return s_typeLoaderCallbacks;
}
}
internal static TypeLoaderCallbacks TypeLoaderCallbacks
{
get
{
TypeLoaderCallbacks callbacks = s_typeLoaderCallbacks;
Debug.Assert(callbacks != null);
return callbacks;
}
}
internal static InteropCallbacks InteropCallbacks
{
get
{
InteropCallbacks callbacks = s_interopCallbacks;
Debug.Assert(callbacks != null);
return callbacks;
}
}
internal static StackTraceMetadataCallbacks StackTraceCallbacksIfAvailable
{
get
{
return s_stackTraceMetadataCallbacks;
}
}
public static string TryGetMethodDisplayStringFromIp(IntPtr ip)
{
StackTraceMetadataCallbacks callbacks = StackTraceCallbacksIfAvailable;
if (callbacks == null)
return null;
ip = RuntimeImports.RhFindMethodStartAddress(ip);
if (ip == IntPtr.Zero)
return null;
return callbacks.TryGetMethodNameFromStartAddress(ip);
}
private static volatile ReflectionExecutionDomainCallbacks s_reflectionExecutionDomainCallbacks;
private static TypeLoaderCallbacks s_typeLoaderCallbacks;
private static InteropCallbacks s_interopCallbacks;
public static void ReportUnhandledException(Exception exception)
{
RuntimeExceptionHelpers.ReportUnhandledException(exception);
}
public static unsafe RuntimeTypeHandle GetRuntimeTypeHandleFromObjectReference(object obj)
{
return new RuntimeTypeHandle(obj.EETypePtr);
}
// Move memory which may be on the heap which may have object references in it.
// In general, a memcpy on the heap is unsafe, but this is able to perform the
// correct write barrier such that the GC is not incorrectly impacted.
public static unsafe void BulkMoveWithWriteBarrier(IntPtr dmem, IntPtr smem, int size)
{
RuntimeImports.RhBulkMoveWithWriteBarrier(ref *(byte*)dmem.ToPointer(), ref *(byte*)smem.ToPointer(), (uint)size);
}
public static IntPtr GetUniversalTransitionThunk()
{
return RuntimeImports.RhGetUniversalTransitionThunk();
}
public static object CreateThunksHeap(IntPtr commonStubAddress)
{
object newHeap = RuntimeImports.RhCreateThunksHeap(commonStubAddress);
if (newHeap == null)
throw new OutOfMemoryException();
return newHeap;
}
public static IntPtr AllocateThunk(object thunksHeap)
{
IntPtr newThunk = RuntimeImports.RhAllocateThunk(thunksHeap);
if (newThunk == IntPtr.Zero)
throw new OutOfMemoryException();
TypeLoaderCallbacks.RegisterThunk(newThunk);
return newThunk;
}
public static void FreeThunk(object thunksHeap, IntPtr thunkAddress)
{
RuntimeImports.RhFreeThunk(thunksHeap, thunkAddress);
}
public static void SetThunkData(object thunksHeap, IntPtr thunkAddress, IntPtr context, IntPtr target)
{
RuntimeImports.RhSetThunkData(thunksHeap, thunkAddress, context, target);
}
public static bool TryGetThunkData(object thunksHeap, IntPtr thunkAddress, out IntPtr context, out IntPtr target)
{
return RuntimeImports.RhTryGetThunkData(thunksHeap, thunkAddress, out context, out target);
}
public static int GetThunkSize()
{
return RuntimeImports.RhGetThunkSize();
}
[DebuggerStepThrough]
/* TEMP workaround due to bug 149078 */
[MethodImpl(MethodImplOptions.NoInlining)]
public static void CallDescrWorker(IntPtr callDescr)
{
RuntimeImports.RhCallDescrWorker(callDescr);
}
[DebuggerStepThrough]
/* TEMP workaround due to bug 149078 */
[MethodImpl(MethodImplOptions.NoInlining)]
public static void CallDescrWorkerNative(IntPtr callDescr)
{
RuntimeImports.RhCallDescrWorkerNative(callDescr);
}
public static Delegate CreateObjectArrayDelegate(Type delegateType, Func<object?[], object?> invoker)
{
return Delegate.CreateObjectArrayDelegate(delegateType, invoker);
}
internal static class RawCalliHelper
{
[DebuggerHidden]
[DebuggerStepThrough]
[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
public static unsafe void Call<T>(System.IntPtr pfn, void* arg1, ref T arg2)
=> ((delegate*<void*, ref T, void>)pfn)(arg1, ref arg2);
[DebuggerHidden]
[DebuggerStepThrough]
[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
public static unsafe void Call<T, U>(System.IntPtr pfn, void* arg1, ref T arg2, ref U arg3)
=> ((delegate*<void*, ref T, ref U, void>)pfn)(arg1, ref arg2, ref arg3);
}
/// <summary>
/// This method creates a conservatively reported region and calls a function
/// while that region is conservatively reported.
/// </summary>
/// <param name="cbBuffer">size of buffer to allocated (buffer size described in bytes)</param>
/// <param name="pfnTargetToInvoke">function pointer to execute.</param>
/// <param name="context">context to pass to inner function. Passed by-ref to allow for efficient use of a struct as a context.</param>
[DebuggerGuidedStepThroughAttribute]
[CLSCompliant(false)]
public static unsafe void RunFunctionWithConservativelyReportedBuffer<T>(int cbBuffer, delegate*<void*, ref T, void> pfnTargetToInvoke, ref T context)
{
RuntimeImports.ConservativelyReportedRegionDesc regionDesc = default;
RunFunctionWithConservativelyReportedBufferInternal(cbBuffer, pfnTargetToInvoke, ref context, ref regionDesc);
System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
}
// Marked as no-inlining so optimizer won't decide to optimize away the fact that pRegionDesc is a pinned interior pointer.
// This function must also not make a p/invoke transition, or the fixed statement reporting of the ConservativelyReportedRegionDesc
// will be ignored.
[DebuggerGuidedStepThroughAttribute]
[MethodImpl(MethodImplOptions.NoInlining)]
private static unsafe void RunFunctionWithConservativelyReportedBufferInternal<T>(int cbBuffer, delegate*<void*, ref T, void> pfnTargetToInvoke, ref T context, ref RuntimeImports.ConservativelyReportedRegionDesc regionDesc)
{
fixed (RuntimeImports.ConservativelyReportedRegionDesc* pRegionDesc = ®ionDesc)
{
int cbBufferAligned = (cbBuffer + (sizeof(IntPtr) - 1)) & ~(sizeof(IntPtr) - 1);
// The conservative region must be IntPtr aligned, and a multiple of IntPtr in size
void* region = stackalloc IntPtr[cbBufferAligned / sizeof(IntPtr)];
Buffer.ZeroMemory((byte*)region, (nuint)cbBufferAligned);
RuntimeImports.RhInitializeConservativeReportingRegion(pRegionDesc, region, cbBufferAligned);
RawCalliHelper.Call<T>((IntPtr)pfnTargetToInvoke, region, ref context);
System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
RuntimeImports.RhDisableConservativeReportingRegion(pRegionDesc);
}
}
/// <summary>
/// This method creates a conservatively reported region and calls a function
/// while that region is conservatively reported.
/// </summary>
/// <param name="cbBuffer">size of buffer to allocated (buffer size described in bytes)</param>
/// <param name="pfnTargetToInvoke">function pointer to execute.</param>
/// <param name="context">context to pass to inner function. Passed by-ref to allow for efficient use of a struct as a context.</param>
/// <param name="context2">context2 to pass to inner function. Passed by-ref to allow for efficient use of a struct as a context.</param>
[DebuggerGuidedStepThroughAttribute]
[CLSCompliant(false)]
public static unsafe void RunFunctionWithConservativelyReportedBuffer<T, U>(int cbBuffer, delegate*<void*, ref T, ref U, void> pfnTargetToInvoke, ref T context, ref U context2)
{
RuntimeImports.ConservativelyReportedRegionDesc regionDesc = default;
RunFunctionWithConservativelyReportedBufferInternal(cbBuffer, pfnTargetToInvoke, ref context, ref context2, ref regionDesc);
System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
}
// Marked as no-inlining so optimizer won't decide to optimize away the fact that pRegionDesc is a pinned interior pointer.
// This function must also not make a p/invoke transition, or the fixed statement reporting of the ConservativelyReportedRegionDesc
// will be ignored.
[DebuggerGuidedStepThroughAttribute]
[MethodImpl(MethodImplOptions.NoInlining)]
private static unsafe void RunFunctionWithConservativelyReportedBufferInternal<T, U>(int cbBuffer, delegate*<void*, ref T, ref U, void> pfnTargetToInvoke, ref T context, ref U context2, ref RuntimeImports.ConservativelyReportedRegionDesc regionDesc)
{
fixed (RuntimeImports.ConservativelyReportedRegionDesc* pRegionDesc = ®ionDesc)
{
int cbBufferAligned = (cbBuffer + (sizeof(IntPtr) - 1)) & ~(sizeof(IntPtr) - 1);
// The conservative region must be IntPtr aligned, and a multiple of IntPtr in size
void* region = stackalloc IntPtr[cbBufferAligned / sizeof(IntPtr)];
Buffer.ZeroMemory((byte*)region, (nuint)cbBufferAligned);
RuntimeImports.RhInitializeConservativeReportingRegion(pRegionDesc, region, cbBufferAligned);
RawCalliHelper.Call<T, U>((IntPtr)pfnTargetToInvoke, region, ref context, ref context2);
System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
RuntimeImports.RhDisableConservativeReportingRegion(pRegionDesc);
}
}
public static string GetLastResortString(RuntimeTypeHandle typeHandle)
{
return typeHandle.LastResortToString;
}
public static IntPtr RhHandleAlloc(object value, GCHandleType type)
{
return RuntimeImports.RhHandleAlloc(value, type);
}
public static void RhHandleFree(IntPtr handle)
{
RuntimeImports.RhHandleFree(handle);
}
public static IntPtr RhpGetCurrentThread()
{
return RuntimeImports.RhpGetCurrentThread();
}
public static void RhpInitiateThreadAbort(IntPtr thread, bool rude)
{
Exception ex = new ThreadAbortException();
RuntimeImports.RhpInitiateThreadAbort(thread, ex, rude);
}
public static void RhpCancelThreadAbort(IntPtr thread)
{
RuntimeImports.RhpCancelThreadAbort(thread);
}
public static void RhYield()
{
RuntimeImports.RhYield();
}
public static bool SupportsRelativePointers
{
get
{
return Internal.Runtime.MethodTable.SupportsRelativePointers;
}
}
public static bool IsPrimitive(RuntimeTypeHandle typeHandle)
{
return typeHandle.ToEETypePtr().IsPrimitive && !typeHandle.ToEETypePtr().IsEnum;
}
public static byte[] ComputePublicKeyToken(byte[] publicKey)
{
return System.Reflection.AssemblyNameHelpers.ComputePublicKeyToken(publicKey);
}
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlEventChangedAction.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Xml
{
// Specifies the type of node change
public enum XmlNodeChangedAction
{
// A node is being inserted in the tree.
Insert = 0,
// A node is being removed from the tree.
Remove = 1,
// A node value is being changed.
Change = 2
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Xml
{
// Specifies the type of node change
public enum XmlNodeChangedAction
{
// A node is being inserted in the tree.
Insert = 0,
// A node is being removed from the tree.
Remove = 1,
// A node value is being changed.
Change = 2
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/JIT/Methodical/eh/basics/throwinfinallyintryfilter1.il | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
.assembly extern System.Console
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )
.ver 4:0:0:0
}
.assembly extern mscorlib {}
.assembly extern eh_common {}
.assembly 'throwinfinallyintryfilter1' {}
.class public auto ansi Test_throwinfinallyintryfilter1 extends [mscorlib] System.Object {
.method public static int32 Main()
{
.entrypoint
.maxstack 2
.locals init (
class [mscorlib]System.IO.StringWriter expectedOut,
class [eh_common]TestUtil.TestLog testLog
)
newobj instance void [mscorlib]System.IO.StringWriter::.ctor()
stloc.s expectedOut
ldloc.s expectedOut
ldstr "in try"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
ldstr " in try"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
ldstr " in try"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
ldstr " in finally"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
ldstr " in filter"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
ldstr "in finally"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
ldstr "caught an exception!"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
newobj instance void [eh_common]TestUtil.TestLog::.ctor(object)
stloc.s testLog
ldloc.s testLog
callvirt instance void [eh_common]TestUtil.TestLog::StartRecording()
.try
{
ldc.i4.0
call void func(int32)
leave.s DONE
}
catch [mscorlib]System.Exception
{
pop
ldstr "caught an exception!"
call void [System.Console]System.Console::WriteLine(string)
leave.s DONE
}
DONE:
ldloc.s testLog
callvirt instance void [eh_common]TestUtil.TestLog::StopRecording()
ldloc.s testLog
callvirt instance int32 [eh_common]TestUtil.TestLog::VerifyOutput()
ret
}
}
.method public static void func(int32 i)
{
.maxstack 1
.try
{
ldstr "in try"
call void [System.Console]System.Console::WriteLine(string)
.try
{
ldstr " in try"
call void [System.Console]System.Console::WriteLine(string)
.try
{
ldstr " in try"
call void [System.Console]System.Console::WriteLine(string)
leave.s TRY_1
}
finally
{
ldstr " in finally"
call void [System.Console]System.Console::WriteLine(string)
newobj instance void [mscorlib]System.Exception::.ctor()
throw
endfinally
}
TRY_1: leave.s TRY_0
}
filter
{
pop
ldstr " in filter"
call void [System.Console]System.Console::WriteLine(string)
ldc.i4.0
endfilter
} {
pop
ldstr " in handler"
call void [System.Console]System.Console::WriteLine(string)
leave.s TRY_0
}
TRY_0: leave.s DONE
}
finally
{
ldstr "in finally"
call void [System.Console]System.Console::WriteLine(string)
endfinally
}
DONE: ret
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
.assembly extern System.Console
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )
.ver 4:0:0:0
}
.assembly extern mscorlib {}
.assembly extern eh_common {}
.assembly 'throwinfinallyintryfilter1' {}
.class public auto ansi Test_throwinfinallyintryfilter1 extends [mscorlib] System.Object {
.method public static int32 Main()
{
.entrypoint
.maxstack 2
.locals init (
class [mscorlib]System.IO.StringWriter expectedOut,
class [eh_common]TestUtil.TestLog testLog
)
newobj instance void [mscorlib]System.IO.StringWriter::.ctor()
stloc.s expectedOut
ldloc.s expectedOut
ldstr "in try"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
ldstr " in try"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
ldstr " in try"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
ldstr " in finally"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
ldstr " in filter"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
ldstr "in finally"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
ldstr "caught an exception!"
callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string)
ldloc.s expectedOut
newobj instance void [eh_common]TestUtil.TestLog::.ctor(object)
stloc.s testLog
ldloc.s testLog
callvirt instance void [eh_common]TestUtil.TestLog::StartRecording()
.try
{
ldc.i4.0
call void func(int32)
leave.s DONE
}
catch [mscorlib]System.Exception
{
pop
ldstr "caught an exception!"
call void [System.Console]System.Console::WriteLine(string)
leave.s DONE
}
DONE:
ldloc.s testLog
callvirt instance void [eh_common]TestUtil.TestLog::StopRecording()
ldloc.s testLog
callvirt instance int32 [eh_common]TestUtil.TestLog::VerifyOutput()
ret
}
}
.method public static void func(int32 i)
{
.maxstack 1
.try
{
ldstr "in try"
call void [System.Console]System.Console::WriteLine(string)
.try
{
ldstr " in try"
call void [System.Console]System.Console::WriteLine(string)
.try
{
ldstr " in try"
call void [System.Console]System.Console::WriteLine(string)
leave.s TRY_1
}
finally
{
ldstr " in finally"
call void [System.Console]System.Console::WriteLine(string)
newobj instance void [mscorlib]System.Exception::.ctor()
throw
endfinally
}
TRY_1: leave.s TRY_0
}
filter
{
pop
ldstr " in filter"
call void [System.Console]System.Console::WriteLine(string)
ldc.i4.0
endfilter
} {
pop
ldstr " in handler"
call void [System.Console]System.Console::WriteLine(string)
leave.s TRY_0
}
TRY_0: leave.s DONE
}
finally
{
ldstr "in finally"
call void [System.Console]System.Console::WriteLine(string)
endfinally
}
DONE: ret
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/JIT/Generics/Arrays/ConstructedTypes/Jagged/struct05.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
using System;
public struct ValX1<T>
{
public T t;
public ValX1(T t)
{
this.t = t;
}
}
public class RefX1<T>
{
public T t;
public RefX1(T t)
{
this.t = t;
}
}
public struct Gen<T>
{
public T Fld1;
public Gen(T fld1)
{
Fld1 = fld1;
}
}
public class Test_struct05
{
public static int counter = 0;
public static bool result = true;
public static void Eval(bool exp)
{
counter++;
if (!exp)
{
result = exp;
Console.WriteLine("Test Failed at location: " + counter);
}
}
public static int Main()
{
int size = 10;
int i, j, k, l, m;
double sum = 0;
Gen<RefX1<string>>[][][][][] GenArray = new Gen<RefX1<string>>[size][][][][];
for (i = 0; i < size; i++)
{
GenArray[i] = new Gen<RefX1<string>>[i][][][];
for (j = 0; j < i; j++)
{
GenArray[i][j] = new Gen<RefX1<string>>[j][][];
for (k = 0; k < j; k++)
{
GenArray[i][j][k] = new Gen<RefX1<string>>[k][];
for (l = 0; l < k; l++)
{
GenArray[i][j][k][l] = new Gen<RefX1<string>>[l];
for (m = 0; m < l; m++)
{
GenArray[i][j][k][l][m] = new Gen<RefX1<string>>(new RefX1<string>((i * j * k * l * m).ToString()));
}
}
}
}
}
for (i = 0; i < size; i++)
{
for (j = 0; j < i; j++)
{
for (k = 0; k < j; k++)
{
for (l = 0; l < k; l++)
{
for (m = 0; m < l; m++)
{
sum += System.Int32.Parse(GenArray[i][j][k][l][m].Fld1.t);
}
}
}
}
}
Eval(sum == 269325);
sum = 0;
if (result)
{
Console.WriteLine("Test Passed");
return 100;
}
else
{
Console.WriteLine("Test Failed");
return 1;
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
using System;
public struct ValX1<T>
{
public T t;
public ValX1(T t)
{
this.t = t;
}
}
public class RefX1<T>
{
public T t;
public RefX1(T t)
{
this.t = t;
}
}
public struct Gen<T>
{
public T Fld1;
public Gen(T fld1)
{
Fld1 = fld1;
}
}
public class Test_struct05
{
public static int counter = 0;
public static bool result = true;
public static void Eval(bool exp)
{
counter++;
if (!exp)
{
result = exp;
Console.WriteLine("Test Failed at location: " + counter);
}
}
public static int Main()
{
int size = 10;
int i, j, k, l, m;
double sum = 0;
Gen<RefX1<string>>[][][][][] GenArray = new Gen<RefX1<string>>[size][][][][];
for (i = 0; i < size; i++)
{
GenArray[i] = new Gen<RefX1<string>>[i][][][];
for (j = 0; j < i; j++)
{
GenArray[i][j] = new Gen<RefX1<string>>[j][][];
for (k = 0; k < j; k++)
{
GenArray[i][j][k] = new Gen<RefX1<string>>[k][];
for (l = 0; l < k; l++)
{
GenArray[i][j][k][l] = new Gen<RefX1<string>>[l];
for (m = 0; m < l; m++)
{
GenArray[i][j][k][l][m] = new Gen<RefX1<string>>(new RefX1<string>((i * j * k * l * m).ToString()));
}
}
}
}
}
for (i = 0; i < size; i++)
{
for (j = 0; j < i; j++)
{
for (k = 0; k < j; k++)
{
for (l = 0; l < k; l++)
{
for (m = 0; m < l; m++)
{
sum += System.Int32.Parse(GenArray[i][j][k][l][m].Fld1.t);
}
}
}
}
}
Eval(sum == 269325);
sum = 0;
if (result)
{
Console.WriteLine("Test Passed");
return 100;
}
else
{
Console.WriteLine("Test Failed");
return 1;
}
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/mono/sample/wasm/browser-bench/Console/Wasm.Console.Bench.Sample.csproj | <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<WasmCopyAppZipToHelixTestDir Condition="'$(ArchiveTests)' == 'true'">true</WasmCopyAppZipToHelixTestDir>
<WasmMainJSPath>$(MonoProjectRoot)\wasm\test-main.js</WasmMainJSPath>
<WasmGenerateRunV8Script>true</WasmGenerateRunV8Script>
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings>
<WasmNativeStrip>false</WasmNativeStrip>
</PropertyGroup>
<PropertyGroup>
<_SampleProject>Wasm.Console.Bench.Sample.csproj</_SampleProject>
<_SampleAssembly>Wasm.Console.Bench.Sample.dll</_SampleAssembly>
<SignAssembly>False</SignAssembly>
</PropertyGroup>
<Target Name="RunSample" DependsOnTargets="RunSampleWithV8" />
<ItemGroup>
<Compile Include="../*.cs" />
<Compile Remove="../Browser.cs" />
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
</ItemGroup>
</Project>
| <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<WasmCopyAppZipToHelixTestDir Condition="'$(ArchiveTests)' == 'true'">true</WasmCopyAppZipToHelixTestDir>
<WasmMainJSPath>$(MonoProjectRoot)\wasm\test-main.js</WasmMainJSPath>
<WasmGenerateRunV8Script>true</WasmGenerateRunV8Script>
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings>
<WasmNativeStrip>false</WasmNativeStrip>
</PropertyGroup>
<PropertyGroup>
<_SampleProject>Wasm.Console.Bench.Sample.csproj</_SampleProject>
<_SampleAssembly>Wasm.Console.Bench.Sample.dll</_SampleAssembly>
<SignAssembly>False</SignAssembly>
</PropertyGroup>
<Target Name="RunSample" DependsOnTargets="RunSampleWithV8" />
<ItemGroup>
<Compile Include="../*.cs" />
<Compile Remove="../Browser.cs" />
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
</ItemGroup>
</Project>
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/installer/pkg/sfx/bundle/osx_resources/it.lproj/welcome.html | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
</head>
<body>
<br>
<div align="left" style="font-family: Helvetica;padding-left:10px">
<h2>.NET Runtime</h2>
<p>.NET is a development platform that you can use to build command-line applications, microservices and modern websites.It is open source, cross-platform, and supported by Microsoft. We hope you enjoy it!</p>
</div>
<div align="left" style="font-family: Helvetica">
<h2 style="padding-left:10px">Learn more about .NET</h2>
<ul>
<li><a href="https://aka.ms/dotnet-docs">Documentation</a></li>
<li><a href="https://aka.ms/dev-privacy">Privacy Statement</a></li>
<li><a href="https://aka.ms/dotnet-license">MIT License</a></li>
</ul>
</div>
</body>
</html>
| <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
</head>
<body>
<br>
<div align="left" style="font-family: Helvetica;padding-left:10px">
<h2>.NET Runtime</h2>
<p>.NET is a development platform that you can use to build command-line applications, microservices and modern websites.It is open source, cross-platform, and supported by Microsoft. We hope you enjoy it!</p>
</div>
<div align="left" style="font-family: Helvetica">
<h2 style="padding-left:10px">Learn more about .NET</h2>
<ul>
<li><a href="https://aka.ms/dotnet-docs">Documentation</a></li>
<li><a href="https://aka.ms/dev-privacy">Privacy Statement</a></li>
<li><a href="https://aka.ms/dotnet-license">MIT License</a></li>
</ul>
</div>
</body>
</html>
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/vm/amd64/stublinkeramd64.cpp | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include "common.h"
#include "asmconstants.h"
#include "../i386/stublinkerx86.cpp"
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include "common.h"
#include "asmconstants.h"
#include "../i386/stublinkerx86.cpp"
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/MemoryBlocks/MemoryMappedFileBlock.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
namespace System.Reflection.Internal
{
internal unsafe sealed class MemoryMappedFileBlock : AbstractMemoryBlock
{
private sealed class DisposableData : CriticalDisposableObject
{
// Usually a MemoryMappedViewAccessor, but kept
// as an IDisposable for better testability.
private IDisposable? _accessor;
private SafeBuffer? _safeBuffer;
private byte* _pointer;
public DisposableData(IDisposable accessor, SafeBuffer safeBuffer, long offset)
{
#if FEATURE_CER
// Make sure the current thread isn't aborted in between acquiring the pointer and assigning the fields.
RuntimeHelpers.PrepareConstrainedRegions();
try
{ /* intentionally left blank */ }
finally
#endif
{
byte* basePointer = null;
safeBuffer.AcquirePointer(ref basePointer);
_accessor = accessor;
_safeBuffer = safeBuffer;
_pointer = basePointer + offset;
}
}
protected override void Release()
{
#if FEATURE_CER
// Make sure the current thread isn't aborted in between zeroing the references and releasing/disposing.
// Safe buffer only frees the underlying resource if its ref count drops to zero, so we have to make sure it does.
RuntimeHelpers.PrepareConstrainedRegions();
try
{ /* intentionally left blank */ }
finally
#endif
{
Interlocked.Exchange(ref _safeBuffer, null)?.ReleasePointer();
Interlocked.Exchange(ref _accessor, null)?.Dispose();
}
_pointer = null;
}
public byte* Pointer => _pointer;
}
private readonly DisposableData _data;
private readonly int _size;
internal unsafe MemoryMappedFileBlock(IDisposable accessor, SafeBuffer safeBuffer, long offset, int size)
{
_data = new DisposableData(accessor, safeBuffer, offset);
_size = size;
}
public override void Dispose() => _data.Dispose();
public override byte* Pointer => _data.Pointer;
public override int Size => _size;
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
namespace System.Reflection.Internal
{
internal unsafe sealed class MemoryMappedFileBlock : AbstractMemoryBlock
{
private sealed class DisposableData : CriticalDisposableObject
{
// Usually a MemoryMappedViewAccessor, but kept
// as an IDisposable for better testability.
private IDisposable? _accessor;
private SafeBuffer? _safeBuffer;
private byte* _pointer;
public DisposableData(IDisposable accessor, SafeBuffer safeBuffer, long offset)
{
#if FEATURE_CER
// Make sure the current thread isn't aborted in between acquiring the pointer and assigning the fields.
RuntimeHelpers.PrepareConstrainedRegions();
try
{ /* intentionally left blank */ }
finally
#endif
{
byte* basePointer = null;
safeBuffer.AcquirePointer(ref basePointer);
_accessor = accessor;
_safeBuffer = safeBuffer;
_pointer = basePointer + offset;
}
}
protected override void Release()
{
#if FEATURE_CER
// Make sure the current thread isn't aborted in between zeroing the references and releasing/disposing.
// Safe buffer only frees the underlying resource if its ref count drops to zero, so we have to make sure it does.
RuntimeHelpers.PrepareConstrainedRegions();
try
{ /* intentionally left blank */ }
finally
#endif
{
Interlocked.Exchange(ref _safeBuffer, null)?.ReleasePointer();
Interlocked.Exchange(ref _accessor, null)?.Dispose();
}
_pointer = null;
}
public byte* Pointer => _pointer;
}
private readonly DisposableData _data;
private readonly int _size;
internal unsafe MemoryMappedFileBlock(IDisposable accessor, SafeBuffer safeBuffer, long offset, int size)
{
_data = new DisposableData(accessor, safeBuffer, offset);
_size = size;
}
public override void Dispose() => _data.Dispose();
public override byte* Pointer => _data.Pointer;
public override int Size => _size;
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/installer/pkg/sfx/bundle/theme/1055/bundle.wxl | <?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us" Language="1033" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<String Id="Caption">[WixBundleName] Yükleyicisi</String>
<String Id="Title">[BUNDLEMONIKER]</String>
<String Id="Motto">Yalnızca bir kabuğa, bir metin düzenleyicisine ve 10 dakikalık bir zamana ihtiyacınız var.
Hazır mısınız? Haydi başlayalım!</String>
<String Id="ConfirmCancelMessage">İptal etmek istediğinizden emin misiniz?</String>
<String Id="ExecuteUpgradeRelatedBundleMessage">Önceki sürüm</String>
<String Id="HelpHeader">Kurulum Yardımı</String>
<String Id="HelpText">/install | /repair | /uninstall | /layout [dizin] - yükler, onarır, kaldırır ya da
dizindeki paketin tam bir yerel kopyasını oluşturur. Varsayılan install değeridir.
/passive | /quiet - en az düzeyde istemsiz UI gösterir ya da hiç UI göstermez ve
istem yoktur. Varsayılan olarak UI ve tüm istemler görüntülenir.
/norestart - yeniden başlama denemelerini engeller. Varsayılan olarak UI yeniden başlatılmadan önce sorar.
/log log.txt - belirli bir günlük dosyası tutar. Varsayılan olarak %TEMP% içinde bir günlük dosyası oluşturulur.</String>
<String Id="HelpCloseButton">&Kapat</String>
<String Id="InstallAcceptCheckbox">Lisans &hüküm ve koşullarını kabul ediyorum</String>
<String Id="InstallOptionsButton">&Seçenekler</String>
<String Id="InstallInstallButton">&Yükle</String>
<String Id="InstallCloseButton">&Kapat</String>
<String Id="OptionsHeader">Kurulum Seçenekleri</String>
<String Id="OptionsLocationLabel">Yükleme konumu:</String>
<String Id="OptionsBrowseButton">&Gözat</String>
<String Id="OptionsOkButton">&Tamam</String>
<String Id="OptionsCancelButton">İ&ptal</String>
<String Id="ProgressHeader">Kurulum İlerleme Durumu</String>
<String Id="ProgressLabel">İşleniyor:</String>
<String Id="OverallProgressPackageText">Başlatılıyor...</String>
<String Id="ProgressCancelButton">İ&ptal</String>
<String Id="ModifyHeader">Kurulumu Değiştir</String>
<String Id="ModifyRepairButton">&Onar</String>
<String Id="ModifyUninstallButton">&Kaldır</String>
<String Id="ModifyCloseButton">&Kapat</String>
<String Id="SuccessRepairHeader">Onarım Başarıyla Tamamlandı</String>
<String Id="SuccessUninstallHeader">Kaldırma Başarıyla Tamamlandı</String>
<String Id="SuccessInstallHeader">Yükleme başarılı oldu</String>
<String Id="SuccessHeader">Kurulum Başarılı</String>
<String Id="SuccessLaunchButton">&Başlat</String>
<String Id="SuccessRestartText">Yazılımı kullanabilmek için bilgisayarınızı yeniden başlatmanız gerekiyor.</String>
<String Id="SuccessRestartButton">&Yeniden Başlat</String>
<String Id="SuccessCloseButton">&Kapat</String>
<String Id="FailureHeader">Kurulum Başarısız</String>
<String Id="FailureInstallHeader">Kurulum Başarısız</String>
<String Id="FailureUninstallHeader">Yükleme Başarısız</String>
<String Id="FailureRepairHeader">Onarım Başarısız</String>
<String Id="FailureHyperlinkLogText">En az bir sorun nedeniyle kurulum başarısız oldu. Lütfen bu sorunları düzeltin ve kurulumu yeniden deneyin. Daha fazla bilgi için <a href="#">günlük dosyasına</a> bakın.</String>
<String Id="FailureRestartText">Yazılımın geri alınmasını tamamlamak için bilgisayarınızı yeniden başlatmanız gerekiyor.</String>
<String Id="FailureRestartButton">&Yeniden Başlat</String>
<String Id="FailureCloseButton">&Kapat</String>
<String Id="FailureNotSupportedCurrentOperatingSystem">[PRODUCT_NAME] bu işletim sisteminde desteklenmiyor. Daha fazla bilgi için bkz. [LINK_PREREQ_PAGE].</String>
<String Id="FailureNotSupportedX86OperatingSystem">[PRODUCT_NAME], x86 işletim sistemlerinde desteklenmiyor. Lütfen karşılık gelen x86 yükleyicisini kullanarak yükleyin.</String>
<String Id="FilesInUseHeader">Kullanımda Olan Dosyalar</String>
<String Id="FilesInUseLabel">Şu uygulamalar güncelleştirilmesi gereken dosyaları kullanıyor:</String>
<String Id="FilesInUseCloseRadioButton">&Uygulamaları kapatın ve yeniden başlatmayı deneyin.</String>
<String Id="FilesInUseDontCloseRadioButton">&Uygulamaları kapatmayın. Sistemi yeniden başlatmanız gerekir.</String>
<String Id="FilesInUseOkButton">&Tamam</String>
<String Id="FilesInUseCancelButton">&İptal</String>
<String Id="WelcomeHeaderMessage">.NET Çalışma Zamanı</String>
<String Id="WelcomeDescription">.NET Çalışma Zamanı, Windows bilgisayarınızda .NET uygulamalarını çalıştırmak için kullanılır. .NET açık kaynaktır, platformlar arasında kullanılabilir ve Microsoft tarafından desteklenmektedir. Beğeneceğinizi umuyoruz!</String>
<String Id="LearnMoreTitle">.NET hakkında daha fazla bilgi edinin</String>
<String Id="SuccessInstallLocation">Aşağıdakiler [DOTNETHOME] konumunda yüklendi</String>
<String Id="SuccessInstallProductName"> - [BUNDLEMONIKER] </String>
<String Id="ResourcesHeader">Kaynaklar</String>
<String Id="DocumentationLink"><A HREF="https://aka.ms/dotnet-docs">Belgeler</A></String>
<String Id="RelaseNotesLink"><A HREF="https://aka.ms/20-p2-rel-notes">Sürüm Notları</A></String>
<String Id="TutorialLink"><A HREF="https://aka.ms/dotnet-tutorials">Öğreticiler</A></String>
<String Id="TelemetryLink"><A HREF="https://aka.ms/dotnet-cli-telemetry">.NET Telemetrisi</A></String>
<String Id="PrivacyStatementLink"><A HREF="https://aka.ms/dev-privacy">Gizlilik Bildirimi</A></String>
<String Id="EulaLink"><A HREF="https://aka.ms/dotnet-license-windows">.NET için Lisans Bilgileri</A></String>
<String Id="LicenseAssent">Yükle'ye tıklayarak aşağıdaki koşulları kabul etmiş olursunuz.</String>
</WixLocalization>
| <?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us" Language="1033" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<String Id="Caption">[WixBundleName] Yükleyicisi</String>
<String Id="Title">[BUNDLEMONIKER]</String>
<String Id="Motto">Yalnızca bir kabuğa, bir metin düzenleyicisine ve 10 dakikalık bir zamana ihtiyacınız var.
Hazır mısınız? Haydi başlayalım!</String>
<String Id="ConfirmCancelMessage">İptal etmek istediğinizden emin misiniz?</String>
<String Id="ExecuteUpgradeRelatedBundleMessage">Önceki sürüm</String>
<String Id="HelpHeader">Kurulum Yardımı</String>
<String Id="HelpText">/install | /repair | /uninstall | /layout [dizin] - yükler, onarır, kaldırır ya da
dizindeki paketin tam bir yerel kopyasını oluşturur. Varsayılan install değeridir.
/passive | /quiet - en az düzeyde istemsiz UI gösterir ya da hiç UI göstermez ve
istem yoktur. Varsayılan olarak UI ve tüm istemler görüntülenir.
/norestart - yeniden başlama denemelerini engeller. Varsayılan olarak UI yeniden başlatılmadan önce sorar.
/log log.txt - belirli bir günlük dosyası tutar. Varsayılan olarak %TEMP% içinde bir günlük dosyası oluşturulur.</String>
<String Id="HelpCloseButton">&Kapat</String>
<String Id="InstallAcceptCheckbox">Lisans &hüküm ve koşullarını kabul ediyorum</String>
<String Id="InstallOptionsButton">&Seçenekler</String>
<String Id="InstallInstallButton">&Yükle</String>
<String Id="InstallCloseButton">&Kapat</String>
<String Id="OptionsHeader">Kurulum Seçenekleri</String>
<String Id="OptionsLocationLabel">Yükleme konumu:</String>
<String Id="OptionsBrowseButton">&Gözat</String>
<String Id="OptionsOkButton">&Tamam</String>
<String Id="OptionsCancelButton">İ&ptal</String>
<String Id="ProgressHeader">Kurulum İlerleme Durumu</String>
<String Id="ProgressLabel">İşleniyor:</String>
<String Id="OverallProgressPackageText">Başlatılıyor...</String>
<String Id="ProgressCancelButton">İ&ptal</String>
<String Id="ModifyHeader">Kurulumu Değiştir</String>
<String Id="ModifyRepairButton">&Onar</String>
<String Id="ModifyUninstallButton">&Kaldır</String>
<String Id="ModifyCloseButton">&Kapat</String>
<String Id="SuccessRepairHeader">Onarım Başarıyla Tamamlandı</String>
<String Id="SuccessUninstallHeader">Kaldırma Başarıyla Tamamlandı</String>
<String Id="SuccessInstallHeader">Yükleme başarılı oldu</String>
<String Id="SuccessHeader">Kurulum Başarılı</String>
<String Id="SuccessLaunchButton">&Başlat</String>
<String Id="SuccessRestartText">Yazılımı kullanabilmek için bilgisayarınızı yeniden başlatmanız gerekiyor.</String>
<String Id="SuccessRestartButton">&Yeniden Başlat</String>
<String Id="SuccessCloseButton">&Kapat</String>
<String Id="FailureHeader">Kurulum Başarısız</String>
<String Id="FailureInstallHeader">Kurulum Başarısız</String>
<String Id="FailureUninstallHeader">Yükleme Başarısız</String>
<String Id="FailureRepairHeader">Onarım Başarısız</String>
<String Id="FailureHyperlinkLogText">En az bir sorun nedeniyle kurulum başarısız oldu. Lütfen bu sorunları düzeltin ve kurulumu yeniden deneyin. Daha fazla bilgi için <a href="#">günlük dosyasına</a> bakın.</String>
<String Id="FailureRestartText">Yazılımın geri alınmasını tamamlamak için bilgisayarınızı yeniden başlatmanız gerekiyor.</String>
<String Id="FailureRestartButton">&Yeniden Başlat</String>
<String Id="FailureCloseButton">&Kapat</String>
<String Id="FailureNotSupportedCurrentOperatingSystem">[PRODUCT_NAME] bu işletim sisteminde desteklenmiyor. Daha fazla bilgi için bkz. [LINK_PREREQ_PAGE].</String>
<String Id="FailureNotSupportedX86OperatingSystem">[PRODUCT_NAME], x86 işletim sistemlerinde desteklenmiyor. Lütfen karşılık gelen x86 yükleyicisini kullanarak yükleyin.</String>
<String Id="FilesInUseHeader">Kullanımda Olan Dosyalar</String>
<String Id="FilesInUseLabel">Şu uygulamalar güncelleştirilmesi gereken dosyaları kullanıyor:</String>
<String Id="FilesInUseCloseRadioButton">&Uygulamaları kapatın ve yeniden başlatmayı deneyin.</String>
<String Id="FilesInUseDontCloseRadioButton">&Uygulamaları kapatmayın. Sistemi yeniden başlatmanız gerekir.</String>
<String Id="FilesInUseOkButton">&Tamam</String>
<String Id="FilesInUseCancelButton">&İptal</String>
<String Id="WelcomeHeaderMessage">.NET Çalışma Zamanı</String>
<String Id="WelcomeDescription">.NET Çalışma Zamanı, Windows bilgisayarınızda .NET uygulamalarını çalıştırmak için kullanılır. .NET açık kaynaktır, platformlar arasında kullanılabilir ve Microsoft tarafından desteklenmektedir. Beğeneceğinizi umuyoruz!</String>
<String Id="LearnMoreTitle">.NET hakkında daha fazla bilgi edinin</String>
<String Id="SuccessInstallLocation">Aşağıdakiler [DOTNETHOME] konumunda yüklendi</String>
<String Id="SuccessInstallProductName"> - [BUNDLEMONIKER] </String>
<String Id="ResourcesHeader">Kaynaklar</String>
<String Id="DocumentationLink"><A HREF="https://aka.ms/dotnet-docs">Belgeler</A></String>
<String Id="RelaseNotesLink"><A HREF="https://aka.ms/20-p2-rel-notes">Sürüm Notları</A></String>
<String Id="TutorialLink"><A HREF="https://aka.ms/dotnet-tutorials">Öğreticiler</A></String>
<String Id="TelemetryLink"><A HREF="https://aka.ms/dotnet-cli-telemetry">.NET Telemetrisi</A></String>
<String Id="PrivacyStatementLink"><A HREF="https://aka.ms/dev-privacy">Gizlilik Bildirimi</A></String>
<String Id="EulaLink"><A HREF="https://aka.ms/dotnet-license-windows">.NET için Lisans Bilgileri</A></String>
<String Id="LicenseAssent">Yükle'ye tıklayarak aşağıdaki koşulları kabul etmiş olursunuz.</String>
</WixLocalization>
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderGetGenericTypeDefinition.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Xunit;
namespace System.Reflection.Emit.Tests
{
public class TypeBuilderGetGenericTypeDefinition
{
[Fact]
public void GetGenericTypeDefinition()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Class | TypeAttributes.Public);
type.DefineGenericParameters("T");
Type genericType = type.GetGenericTypeDefinition();
Assert.Equal("TestType", genericType.Name);
}
[Fact]
public void GetGenericTypeDefinition_NonGenericType_ThrowsInvalidOperationException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Class | TypeAttributes.Public);
Assert.Throws<InvalidOperationException>(() => type.GetGenericTypeDefinition());
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Xunit;
namespace System.Reflection.Emit.Tests
{
public class TypeBuilderGetGenericTypeDefinition
{
[Fact]
public void GetGenericTypeDefinition()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Class | TypeAttributes.Public);
type.DefineGenericParameters("T");
Type genericType = type.GetGenericTypeDefinition();
Assert.Equal("TestType", genericType.Name);
}
[Fact]
public void GetGenericTypeDefinition_NonGenericType_ThrowsInvalidOperationException()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Class | TypeAttributes.Public);
Assert.Throws<InvalidOperationException>(() => type.GetGenericTypeDefinition());
}
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/minipal/Windows/CMakeLists.txt | add_library(coreclrminipal
STATIC
doublemapping.cpp
)
| add_library(coreclrminipal
STATIC
doublemapping.cpp
)
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/installer/tests/HostActivation.Tests/TestOnlyProductBehavior.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.NET.HostModel.AppHost;
using System;
using System.IO;
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
{
public static class TestOnlyProductBehavior
{
private static readonly byte[] OriginalTestOnlyMarker = StringToByteArray("d38cc827-e34f-4453-9df4-1e796e9f1d07");
private static readonly byte[] EnabledTestOnlyMarker = StringToByteArray("e38cc827-e34f-4453-9df4-1e796e9f1d07");
private static byte[] StringToByteArray(string value)
{
byte[] result = new byte[value.Length];
for (int i = 0; i < value.Length; i++)
{
result[i] = (byte)value[i];
}
return result;
}
public static IDisposable Enable(string productBinaryPath)
{
if (!File.Exists(productBinaryPath))
{
throw new Exception($"Could not find product binary {productBinaryPath} to enable test only behavior on.");
}
if (BinaryUtils.SearchInFile(productBinaryPath, OriginalTestOnlyMarker) == -1)
{
// The marker is already enabled (probably by another call to TestOnlyProductBehavior)
// We allow this to be able to nest the enable calls seamlessly - so that tests don't have to track
// which helper does what.
return null;
}
TestFileBackup backup = new TestFileBackup(Path.GetDirectoryName(productBinaryPath), Path.GetFileNameWithoutExtension(productBinaryPath));
backup.Backup(productBinaryPath);
IDisposable returnDisposable = null;
try
{
BinaryUtils.SearchAndReplace(
productBinaryPath,
OriginalTestOnlyMarker,
EnabledTestOnlyMarker);
returnDisposable = backup;
backup = null;
}
finally
{
if (backup != null)
{
backup.Dispose();
}
}
return returnDisposable;
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.NET.HostModel.AppHost;
using System;
using System.IO;
namespace Microsoft.DotNet.CoreSetup.Test.HostActivation
{
public static class TestOnlyProductBehavior
{
private static readonly byte[] OriginalTestOnlyMarker = StringToByteArray("d38cc827-e34f-4453-9df4-1e796e9f1d07");
private static readonly byte[] EnabledTestOnlyMarker = StringToByteArray("e38cc827-e34f-4453-9df4-1e796e9f1d07");
private static byte[] StringToByteArray(string value)
{
byte[] result = new byte[value.Length];
for (int i = 0; i < value.Length; i++)
{
result[i] = (byte)value[i];
}
return result;
}
public static IDisposable Enable(string productBinaryPath)
{
if (!File.Exists(productBinaryPath))
{
throw new Exception($"Could not find product binary {productBinaryPath} to enable test only behavior on.");
}
if (BinaryUtils.SearchInFile(productBinaryPath, OriginalTestOnlyMarker) == -1)
{
// The marker is already enabled (probably by another call to TestOnlyProductBehavior)
// We allow this to be able to nest the enable calls seamlessly - so that tests don't have to track
// which helper does what.
return null;
}
TestFileBackup backup = new TestFileBackup(Path.GetDirectoryName(productBinaryPath), Path.GetFileNameWithoutExtension(productBinaryPath));
backup.Backup(productBinaryPath);
IDisposable returnDisposable = null;
try
{
BinaryUtils.SearchAndReplace(
productBinaryPath,
OriginalTestOnlyMarker,
EnabledTestOnlyMarker);
returnDisposable = backup;
backup = null;
}
finally
{
if (backup != null)
{
backup.Dispose();
}
}
return returnDisposable;
}
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/JIT/Regression/CLR-x86-JIT/V1-M10/b13466/b13466.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
namespace Default
{
//@BEGINRENAME; Verify this renames
//@ENDRENAME; Verify this renames
using System;
class q
{
static
int func(int i, int updateAddr, byte[] newBytes, int[] m_fixupPos)
{
while (i > 10)
{
if (i == 3)
{
if (updateAddr < 0)
newBytes[m_fixupPos[i]] = (byte)(256 + updateAddr);
else
newBytes[m_fixupPos[i]] = (byte)updateAddr;
}
else
i--;
}
return i;
}
public
static
int Main(String[] args)
{
func(0, 0, null, null);
return 100;
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
namespace Default
{
//@BEGINRENAME; Verify this renames
//@ENDRENAME; Verify this renames
using System;
class q
{
static
int func(int i, int updateAddr, byte[] newBytes, int[] m_fixupPos)
{
while (i > 10)
{
if (i == 3)
{
if (updateAddr < 0)
newBytes[m_fixupPos[i]] = (byte)(256 + updateAddr);
else
newBytes[m_fixupPos[i]] = (byte)updateAddr;
}
else
i--;
}
return i;
}
public
static
int Main(String[] args)
{
func(0, 0, null, null);
return 100;
}
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/libraries/System.Net.Quic/readme.md | # MsQuic
`System.Net.Quic` depends on [MsQuic](https://github.com/microsoft/msquic), Microsoft, cross-platform, native implementation of the [QUIC](https://datatracker.ietf.org/wg/quic/about/) protocol.
Currently, `System.Net.Quic` depends on [**msquic@3e40721bff04845208bc07eb4ee0c5e421e6388d**](https://github.com/microsoft/msquic/commit/3e40721bff04845208bc07eb4ee0c5e421e6388d) revision.
## Usage
MsQuic library in now being published so there's no need to compile it yourself.
For a reference, the packaging repository is in https://github.com/dotnet/msquic.
### Windows
Prerequisites:
- Latest [Windows Insider Builds](https://insider.windows.com/en-us/), Insiders Fast build. This is required for SChannel support for QUIC.
- To confirm you have a new enough build, run winver on command line and confirm you version is greater than Version 2004 (OS Build 20145.1000).
- Turned on TLS 1.3
- It is turned on by default, to confirm you can check the appropriate registry `Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols` (empty means default which means enabled).
During the build, the `msquic.dll` is automatically downloaded and placed in correct directories in order to be picked up by the runtime. It is also published as part of the runtime for Windows.
### Linux
On Linux, `libmsquic` is published via Microsoft official Linux package repository `packages.microsoft.com`. In order to consume it, you have to add it manually, see https://docs.microsoft.com/en-us/windows-server/administration/linux-package-repository-for-microsoft-software. After that, you should be able to install it via the package manager of your distro, e.g. for Ubuntu:
```
apt install libmsquic
```
### Build MsQuic
[MsQuic build docs](https://github.com/microsoft/msquic/blob/main/docs/BUILD.md)
You might want to test some `msquic` changes which hasn't propagated into the released package. For that, you need to build `msquic` yourself.
#### Linux
Prerequisites:
- build-essential
- cmake
- lttng-ust
- lttng-tools
`dotnet tool install --global`:
- microsoft.logging.clog
- microsoft.logging.clog2text.lttng
Run inside the msquic directory (for **Debug** build with logging on):
```bash
# build msquic in debug with logging
rm -rf build
mkdir build
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DQUIC_ENABLE_LOGGING=on
cd build
cmake --build . --config Debug
# copy msquic into runtime
yes | cp -rf bin/Debug/libmsquic.* <path-to-runtime>/src/libraries/System.Net.Quic/src/
```
#### Windows
Prerequisites:
- Latest [Windows Insider Builds](https://insider.windows.com/en-us/), Insiders Fast build. This is required for SChannel support for QUIC.
- To confirm you have a new enough build, run `winver` on command line and confirm you version is greater than Version 2004 (OS Build 20145.1000).
Follow the instructions from msquic build documentation.
| # MsQuic
`System.Net.Quic` depends on [MsQuic](https://github.com/microsoft/msquic), Microsoft, cross-platform, native implementation of the [QUIC](https://datatracker.ietf.org/wg/quic/about/) protocol.
Currently, `System.Net.Quic` depends on [**msquic@3e40721bff04845208bc07eb4ee0c5e421e6388d**](https://github.com/microsoft/msquic/commit/3e40721bff04845208bc07eb4ee0c5e421e6388d) revision.
## Usage
MsQuic library in now being published so there's no need to compile it yourself.
For a reference, the packaging repository is in https://github.com/dotnet/msquic.
### Windows
Prerequisites:
- Latest [Windows Insider Builds](https://insider.windows.com/en-us/), Insiders Fast build. This is required for SChannel support for QUIC.
- To confirm you have a new enough build, run winver on command line and confirm you version is greater than Version 2004 (OS Build 20145.1000).
- Turned on TLS 1.3
- It is turned on by default, to confirm you can check the appropriate registry `Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols` (empty means default which means enabled).
During the build, the `msquic.dll` is automatically downloaded and placed in correct directories in order to be picked up by the runtime. It is also published as part of the runtime for Windows.
### Linux
On Linux, `libmsquic` is published via Microsoft official Linux package repository `packages.microsoft.com`. In order to consume it, you have to add it manually, see https://docs.microsoft.com/en-us/windows-server/administration/linux-package-repository-for-microsoft-software. After that, you should be able to install it via the package manager of your distro, e.g. for Ubuntu:
```
apt install libmsquic
```
### Build MsQuic
[MsQuic build docs](https://github.com/microsoft/msquic/blob/main/docs/BUILD.md)
You might want to test some `msquic` changes which hasn't propagated into the released package. For that, you need to build `msquic` yourself.
#### Linux
Prerequisites:
- build-essential
- cmake
- lttng-ust
- lttng-tools
`dotnet tool install --global`:
- microsoft.logging.clog
- microsoft.logging.clog2text.lttng
Run inside the msquic directory (for **Debug** build with logging on):
```bash
# build msquic in debug with logging
rm -rf build
mkdir build
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DQUIC_ENABLE_LOGGING=on
cd build
cmake --build . --config Debug
# copy msquic into runtime
yes | cp -rf bin/Debug/libmsquic.* <path-to-runtime>/src/libraries/System.Net.Quic/src/
```
#### Windows
Prerequisites:
- Latest [Windows Insider Builds](https://insider.windows.com/en-us/), Insiders Fast build. This is required for SChannel support for QUIC.
- To confirm you have a new enough build, run `winver` on command line and confirm you version is greater than Version 2004 (OS Build 20145.1000).
Follow the instructions from msquic build documentation.
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/Loader/classloader/TypeInitialization/CctorsWithSideEffects/TypeLoadInitExcepBFI.il | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
.assembly extern System.Console { }
.assembly extern xunit.core {}
// Microsoft (R) .NET Framework IL Disassembler. Version 2.0.50103.00
// Copyright (C) Microsoft Corporation. All rights reserved.
// Metadata version: v2.0.50103
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 2:0:0:0
}
.assembly 'TypeLoadInitExcepBFI'
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.hash algorithm 0x00008004
.ver 0:0:0:0
}
// MVID: {A7BE6B3C-FF8D-43DB-B091-60CBA24AD082}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x03090000
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi beforefieldinit A
extends [mscorlib]System.Object
{
.field public static int32 i
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
// Code size 24 (0x18)
.maxstack 8
IL_0000: nop
IL_0001: ldstr "In A.cctor"
IL_0006: call void [System.Console]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: ldc.i4.5
IL_000d: stsfld int32 A::i
IL_0012: newobj instance void [mscorlib]System.Exception::.ctor()
IL_0017: throw
} // end of method A::.cctor
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method A::.ctor
} // end of class A
.class public sequential ansi sealed B
extends [mscorlib]System.ValueType
{
.pack 0
.size 1
.field public static int32 i
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
// Code size 24 (0x18)
.maxstack 8
IL_0000: nop
IL_0001: ldstr "In B.cctor"
IL_0006: call void [System.Console]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: ldc.i4.5
IL_000d: stsfld int32 B::i
IL_0012: newobj instance void [mscorlib]System.Exception::.ctor()
IL_0017: throw
} // end of method B::.cctor
} // end of class B
.class public auto ansi beforefieldinit Test_TypeLoadInitExcepBFI
extends [mscorlib]System.Object
{
.method public hidebysig static int32 Main() cil managed
{
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (
01 00 00 00
)
.entrypoint
// Code size 405 (0x195)
.maxstack 2
.locals init (bool V_0,
class [mscorlib]System.Exception V_1,
int32 V_2,
bool V_3)
IL_0000: nop
IL_0001: ldc.i4.1
IL_0002: stloc.0
.try
{
IL_0003: nop
IL_0004: ldstr "Accessing class's static field"
IL_0009: call void [System.Console]System.Console::WriteLine(string)
IL_000e: nop
IL_000f: ldstr "A.i: "
IL_0014: ldsfld int32 A::i
IL_0019: box [mscorlib]System.Int32
IL_001e: call string [mscorlib]System.String::Concat(object,
object)
IL_0023: call void [System.Console]System.Console::WriteLine(string)
IL_0028: nop
IL_0029: ldstr "Did not catch expected TypeInitializationException"
+ " exception"
IL_002e: call void [System.Console]System.Console::WriteLine(string)
IL_0033: nop
IL_0034: ldc.i4.0
IL_0035: stloc.0
IL_0036: nop
IL_0037: leave.s IL_0061
} // end .try
catch [mscorlib]System.TypeInitializationException
{
IL_0039: pop
IL_003a: nop
IL_003b: ldstr "Caught expected exception 1st time"
IL_0040: call void [System.Console]System.Console::WriteLine(string)
IL_0045: nop
IL_0046: nop
IL_0047: leave.s IL_0061
} // end handler
catch [mscorlib]System.Exception
{
IL_0049: stloc.1
IL_004a: nop
IL_004b: ldstr "Caught unexpected exception: "
IL_0050: ldloc.1
IL_0051: call string [mscorlib]System.String::Concat(object,
object)
IL_0056: call void [System.Console]System.Console::WriteLine(string)
IL_005b: nop
IL_005c: ldc.i4.0
IL_005d: stloc.0
IL_005e: nop
IL_005f: leave.s IL_0061
} // end handler
IL_0061: nop
.try
{
IL_0062: nop
IL_0063: ldstr "A.i: "
IL_0068: ldsfld int32 A::i
IL_006d: box [mscorlib]System.Int32
IL_0072: call string [mscorlib]System.String::Concat(object,
object)
IL_0077: call void [System.Console]System.Console::WriteLine(string)
IL_007c: nop
IL_007d: ldstr "Did not catch expected TypeInitializationException"
+ " exception"
IL_0082: call void [System.Console]System.Console::WriteLine(string)
IL_0087: nop
IL_0088: ldc.i4.0
IL_0089: stloc.0
IL_008a: nop
IL_008b: leave.s IL_00b5
} // end .try
catch [mscorlib]System.TypeInitializationException
{
IL_008d: pop
IL_008e: nop
IL_008f: ldstr "Caught expected exception 2nd time\n"
IL_0094: call void [System.Console]System.Console::WriteLine(string)
IL_0099: nop
IL_009a: nop
IL_009b: leave.s IL_00b5
} // end handler
catch [mscorlib]System.Exception
{
IL_009d: stloc.1
IL_009e: nop
IL_009f: ldstr "Caught unexpected exception: "
IL_00a4: ldloc.1
IL_00a5: call string [mscorlib]System.String::Concat(object,
object)
IL_00aa: call void [System.Console]System.Console::WriteLine(string)
IL_00af: nop
IL_00b0: ldc.i4.0
IL_00b1: stloc.0
IL_00b2: nop
IL_00b3: leave.s IL_00b5
} // end handler
IL_00b5: nop
IL_00b6: ldstr "Accessing struct's static field"
IL_00bb: call void [System.Console]System.Console::WriteLine(string)
IL_00c0: nop
.try
{
IL_00c1: nop
IL_00c2: ldstr "B.i: "
IL_00c7: ldsfld int32 B::i
IL_00cc: box [mscorlib]System.Int32
IL_00d1: call string [mscorlib]System.String::Concat(object,
object)
IL_00d6: call void [System.Console]System.Console::WriteLine(string)
IL_00db: nop
IL_00dc: ldstr "Did not catch expected TypeInitializationException"
+ " exception"
IL_00e1: call void [System.Console]System.Console::WriteLine(string)
IL_00e6: nop
IL_00e7: ldc.i4.0
IL_00e8: stloc.0
IL_00e9: nop
IL_00ea: leave.s IL_0114
} // end .try
catch [mscorlib]System.TypeInitializationException
{
IL_00ec: pop
IL_00ed: nop
IL_00ee: ldstr "Caught expected exception 1st time"
IL_00f3: call void [System.Console]System.Console::WriteLine(string)
IL_00f8: nop
IL_00f9: nop
IL_00fa: leave.s IL_0114
} // end handler
catch [mscorlib]System.Exception
{
IL_00fc: stloc.1
IL_00fd: nop
IL_00fe: ldstr "Caught unexpected exception: "
IL_0103: ldloc.1
IL_0104: call string [mscorlib]System.String::Concat(object,
object)
IL_0109: call void [System.Console]System.Console::WriteLine(string)
IL_010e: nop
IL_010f: ldc.i4.0
IL_0110: stloc.0
IL_0111: nop
IL_0112: leave.s IL_0114
} // end handler
IL_0114: nop
.try
{
IL_0115: nop
IL_0116: ldstr "B.i: "
IL_011b: ldsfld int32 B::i
IL_0120: box [mscorlib]System.Int32
IL_0125: call string [mscorlib]System.String::Concat(object,
object)
IL_012a: call void [System.Console]System.Console::WriteLine(string)
IL_012f: nop
IL_0130: ldstr "Did not catch expected TypeInitializationException"
+ " exception"
IL_0135: call void [System.Console]System.Console::WriteLine(string)
IL_013a: nop
IL_013b: ldc.i4.0
IL_013c: stloc.0
IL_013d: nop
IL_013e: leave.s IL_0168
} // end .try
catch [mscorlib]System.TypeInitializationException
{
IL_0140: pop
IL_0141: nop
IL_0142: ldstr "Caught expected exception 2nd time\n"
IL_0147: call void [System.Console]System.Console::WriteLine(string)
IL_014c: nop
IL_014d: nop
IL_014e: leave.s IL_0168
} // end handler
catch [mscorlib]System.Exception
{
IL_0150: stloc.1
IL_0151: nop
IL_0152: ldstr "Caught unexpected exception: "
IL_0157: ldloc.1
IL_0158: call string [mscorlib]System.String::Concat(object,
object)
IL_015d: call void [System.Console]System.Console::WriteLine(string)
IL_0162: nop
IL_0163: ldc.i4.0
IL_0164: stloc.0
IL_0165: nop
IL_0166: leave.s IL_0168
} // end handler
IL_0168: nop
IL_0169: ldloc.0
IL_016a: ldc.i4.0
IL_016b: ceq
IL_016d: stloc.3
IL_016e: ldloc.3
IL_016f: brtrue.s IL_0182
IL_0171: nop
IL_0172: ldstr "PASS"
IL_0177: call void [System.Console]System.Console::WriteLine(string)
IL_017c: nop
IL_017d: ldc.i4.s 100
IL_017f: stloc.2
IL_0180: br.s IL_0193
IL_0182: nop
IL_0183: ldstr "FAIL"
IL_0188: call void [System.Console]System.Console::WriteLine(string)
IL_018d: nop
IL_018e: ldc.i4.s 101
IL_0190: stloc.2
IL_0191: br.s IL_0193
IL_0193: ldloc.2
IL_0194: ret
} // end of method Test::Main
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method Test::.ctor
} // end of class Test
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************
// WARNING: Created Win32 resource file TypeLoadInitExcepBFI.res
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
.assembly extern System.Console { }
.assembly extern xunit.core {}
// Microsoft (R) .NET Framework IL Disassembler. Version 2.0.50103.00
// Copyright (C) Microsoft Corporation. All rights reserved.
// Metadata version: v2.0.50103
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 2:0:0:0
}
.assembly 'TypeLoadInitExcepBFI'
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.hash algorithm 0x00008004
.ver 0:0:0:0
}
// MVID: {A7BE6B3C-FF8D-43DB-B091-60CBA24AD082}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x03090000
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi beforefieldinit A
extends [mscorlib]System.Object
{
.field public static int32 i
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
// Code size 24 (0x18)
.maxstack 8
IL_0000: nop
IL_0001: ldstr "In A.cctor"
IL_0006: call void [System.Console]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: ldc.i4.5
IL_000d: stsfld int32 A::i
IL_0012: newobj instance void [mscorlib]System.Exception::.ctor()
IL_0017: throw
} // end of method A::.cctor
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method A::.ctor
} // end of class A
.class public sequential ansi sealed B
extends [mscorlib]System.ValueType
{
.pack 0
.size 1
.field public static int32 i
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
// Code size 24 (0x18)
.maxstack 8
IL_0000: nop
IL_0001: ldstr "In B.cctor"
IL_0006: call void [System.Console]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: ldc.i4.5
IL_000d: stsfld int32 B::i
IL_0012: newobj instance void [mscorlib]System.Exception::.ctor()
IL_0017: throw
} // end of method B::.cctor
} // end of class B
.class public auto ansi beforefieldinit Test_TypeLoadInitExcepBFI
extends [mscorlib]System.Object
{
.method public hidebysig static int32 Main() cil managed
{
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (
01 00 00 00
)
.entrypoint
// Code size 405 (0x195)
.maxstack 2
.locals init (bool V_0,
class [mscorlib]System.Exception V_1,
int32 V_2,
bool V_3)
IL_0000: nop
IL_0001: ldc.i4.1
IL_0002: stloc.0
.try
{
IL_0003: nop
IL_0004: ldstr "Accessing class's static field"
IL_0009: call void [System.Console]System.Console::WriteLine(string)
IL_000e: nop
IL_000f: ldstr "A.i: "
IL_0014: ldsfld int32 A::i
IL_0019: box [mscorlib]System.Int32
IL_001e: call string [mscorlib]System.String::Concat(object,
object)
IL_0023: call void [System.Console]System.Console::WriteLine(string)
IL_0028: nop
IL_0029: ldstr "Did not catch expected TypeInitializationException"
+ " exception"
IL_002e: call void [System.Console]System.Console::WriteLine(string)
IL_0033: nop
IL_0034: ldc.i4.0
IL_0035: stloc.0
IL_0036: nop
IL_0037: leave.s IL_0061
} // end .try
catch [mscorlib]System.TypeInitializationException
{
IL_0039: pop
IL_003a: nop
IL_003b: ldstr "Caught expected exception 1st time"
IL_0040: call void [System.Console]System.Console::WriteLine(string)
IL_0045: nop
IL_0046: nop
IL_0047: leave.s IL_0061
} // end handler
catch [mscorlib]System.Exception
{
IL_0049: stloc.1
IL_004a: nop
IL_004b: ldstr "Caught unexpected exception: "
IL_0050: ldloc.1
IL_0051: call string [mscorlib]System.String::Concat(object,
object)
IL_0056: call void [System.Console]System.Console::WriteLine(string)
IL_005b: nop
IL_005c: ldc.i4.0
IL_005d: stloc.0
IL_005e: nop
IL_005f: leave.s IL_0061
} // end handler
IL_0061: nop
.try
{
IL_0062: nop
IL_0063: ldstr "A.i: "
IL_0068: ldsfld int32 A::i
IL_006d: box [mscorlib]System.Int32
IL_0072: call string [mscorlib]System.String::Concat(object,
object)
IL_0077: call void [System.Console]System.Console::WriteLine(string)
IL_007c: nop
IL_007d: ldstr "Did not catch expected TypeInitializationException"
+ " exception"
IL_0082: call void [System.Console]System.Console::WriteLine(string)
IL_0087: nop
IL_0088: ldc.i4.0
IL_0089: stloc.0
IL_008a: nop
IL_008b: leave.s IL_00b5
} // end .try
catch [mscorlib]System.TypeInitializationException
{
IL_008d: pop
IL_008e: nop
IL_008f: ldstr "Caught expected exception 2nd time\n"
IL_0094: call void [System.Console]System.Console::WriteLine(string)
IL_0099: nop
IL_009a: nop
IL_009b: leave.s IL_00b5
} // end handler
catch [mscorlib]System.Exception
{
IL_009d: stloc.1
IL_009e: nop
IL_009f: ldstr "Caught unexpected exception: "
IL_00a4: ldloc.1
IL_00a5: call string [mscorlib]System.String::Concat(object,
object)
IL_00aa: call void [System.Console]System.Console::WriteLine(string)
IL_00af: nop
IL_00b0: ldc.i4.0
IL_00b1: stloc.0
IL_00b2: nop
IL_00b3: leave.s IL_00b5
} // end handler
IL_00b5: nop
IL_00b6: ldstr "Accessing struct's static field"
IL_00bb: call void [System.Console]System.Console::WriteLine(string)
IL_00c0: nop
.try
{
IL_00c1: nop
IL_00c2: ldstr "B.i: "
IL_00c7: ldsfld int32 B::i
IL_00cc: box [mscorlib]System.Int32
IL_00d1: call string [mscorlib]System.String::Concat(object,
object)
IL_00d6: call void [System.Console]System.Console::WriteLine(string)
IL_00db: nop
IL_00dc: ldstr "Did not catch expected TypeInitializationException"
+ " exception"
IL_00e1: call void [System.Console]System.Console::WriteLine(string)
IL_00e6: nop
IL_00e7: ldc.i4.0
IL_00e8: stloc.0
IL_00e9: nop
IL_00ea: leave.s IL_0114
} // end .try
catch [mscorlib]System.TypeInitializationException
{
IL_00ec: pop
IL_00ed: nop
IL_00ee: ldstr "Caught expected exception 1st time"
IL_00f3: call void [System.Console]System.Console::WriteLine(string)
IL_00f8: nop
IL_00f9: nop
IL_00fa: leave.s IL_0114
} // end handler
catch [mscorlib]System.Exception
{
IL_00fc: stloc.1
IL_00fd: nop
IL_00fe: ldstr "Caught unexpected exception: "
IL_0103: ldloc.1
IL_0104: call string [mscorlib]System.String::Concat(object,
object)
IL_0109: call void [System.Console]System.Console::WriteLine(string)
IL_010e: nop
IL_010f: ldc.i4.0
IL_0110: stloc.0
IL_0111: nop
IL_0112: leave.s IL_0114
} // end handler
IL_0114: nop
.try
{
IL_0115: nop
IL_0116: ldstr "B.i: "
IL_011b: ldsfld int32 B::i
IL_0120: box [mscorlib]System.Int32
IL_0125: call string [mscorlib]System.String::Concat(object,
object)
IL_012a: call void [System.Console]System.Console::WriteLine(string)
IL_012f: nop
IL_0130: ldstr "Did not catch expected TypeInitializationException"
+ " exception"
IL_0135: call void [System.Console]System.Console::WriteLine(string)
IL_013a: nop
IL_013b: ldc.i4.0
IL_013c: stloc.0
IL_013d: nop
IL_013e: leave.s IL_0168
} // end .try
catch [mscorlib]System.TypeInitializationException
{
IL_0140: pop
IL_0141: nop
IL_0142: ldstr "Caught expected exception 2nd time\n"
IL_0147: call void [System.Console]System.Console::WriteLine(string)
IL_014c: nop
IL_014d: nop
IL_014e: leave.s IL_0168
} // end handler
catch [mscorlib]System.Exception
{
IL_0150: stloc.1
IL_0151: nop
IL_0152: ldstr "Caught unexpected exception: "
IL_0157: ldloc.1
IL_0158: call string [mscorlib]System.String::Concat(object,
object)
IL_015d: call void [System.Console]System.Console::WriteLine(string)
IL_0162: nop
IL_0163: ldc.i4.0
IL_0164: stloc.0
IL_0165: nop
IL_0166: leave.s IL_0168
} // end handler
IL_0168: nop
IL_0169: ldloc.0
IL_016a: ldc.i4.0
IL_016b: ceq
IL_016d: stloc.3
IL_016e: ldloc.3
IL_016f: brtrue.s IL_0182
IL_0171: nop
IL_0172: ldstr "PASS"
IL_0177: call void [System.Console]System.Console::WriteLine(string)
IL_017c: nop
IL_017d: ldc.i4.s 100
IL_017f: stloc.2
IL_0180: br.s IL_0193
IL_0182: nop
IL_0183: ldstr "FAIL"
IL_0188: call void [System.Console]System.Console::WriteLine(string)
IL_018d: nop
IL_018e: ldc.i4.s 101
IL_0190: stloc.2
IL_0191: br.s IL_0193
IL_0193: ldloc.2
IL_0194: ret
} // end of method Test::Main
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method Test::.ctor
} // end of class Test
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************
// WARNING: Created Win32 resource file TypeLoadInitExcepBFI.res
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/Store.Vector128.Int32.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/******************************************************************************
* This file is auto-generated from a template file by the GenerateTests.csx *
* script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make *
* changes, please update the corresponding template and run according to the *
* directions listed in the file. *
******************************************************************************/
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
namespace JIT.HardwareIntrinsics.Arm
{
public static partial class Program
{
private static void Store_Vector128_Int32()
{
var test = new StoreUnaryOpTest__Store_Vector128_Int32();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates basic functionality works, using Load
test.RunBasicScenario_Load();
}
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates calling via reflection works, using Load
test.RunReflectionScenario_Load();
}
// Validates passing a static member works
test.RunClsVarScenario();
if (AdvSimd.IsSupported)
{
// Validates passing a static member works, using pinning and Load
test.RunClsVarScenario_Load();
}
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates passing a local works, using Load
test.RunLclVarScenario_Load();
}
// Validates passing the field of a local class works
test.RunClassLclFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing the field of a local class works, using pinning and Load
test.RunClassLclFldScenario_Load();
}
// Validates passing an instance member of a class works
test.RunClassFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing an instance member of a class works, using pinning and Load
test.RunClassFldScenario_Load();
}
// Validates passing the field of a local struct works
test.RunStructLclFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing the field of a local struct works, using pinning and Load
test.RunStructLclFldScenario_Load();
}
// Validates passing an instance member of a struct works
test.RunStructFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing an instance member of a struct works, using pinning and Load
test.RunStructFldScenario_Load();
}
}
else
{
// Validates we throw on unsupported hardware
test.RunUnsupportedScenario();
}
if (!test.Succeeded)
{
throw new Exception("One or more scenarios did not complete as expected.");
}
}
}
public sealed unsafe class StoreUnaryOpTest__Store_Vector128_Int32
{
private struct DataTable
{
private byte[] inArray1;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Int32[] inArray1, Int32[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int32>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int32, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector128<Int32> _fld1;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref testStruct._fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>());
return testStruct;
}
public void RunStructFldScenario(StoreUnaryOpTest__Store_Vector128_Int32 testClass)
{
AdvSimd.Store((Int32*)testClass._dataTable.outArrayPtr, _fld1);
testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(StoreUnaryOpTest__Store_Vector128_Int32 testClass)
{
fixed (Vector128<Int32>* pFld1 = &_fld1)
{
AdvSimd.Store((Int32*)testClass._dataTable.outArrayPtr, AdvSimd.LoadVector128((Int32*)(pFld1)));
testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32);
private static Int32[] _data1 = new Int32[Op1ElementCount];
private static Vector128<Int32> _clsVar1;
private Vector128<Int32> _fld1;
private DataTable _dataTable;
static StoreUnaryOpTest__Store_Vector128_Int32()
{
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>());
}
public StoreUnaryOpTest__Store_Vector128_Int32()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>());
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
_dataTable = new DataTable(_data1, new Int32[RetElementCount], LargestVectorSize);
}
public bool IsSupported => AdvSimd.IsSupported;
public bool Succeeded { get; set; }
public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr)));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
typeof(AdvSimd).GetMethod(nameof(AdvSimd.Store), new Type[] { typeof(Int32*), typeof(Vector128<Int32>) })
.Invoke(null, new object[] {
Pointer.Box(_dataTable.outArrayPtr, typeof(Int32*)),
Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr) });
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
typeof(AdvSimd).GetMethod(nameof(AdvSimd.Store), new Type[] { typeof(Int32*), typeof(Vector128<Int32>) })
.Invoke(null, new object[] {
Pointer.Box(_dataTable.outArrayPtr, typeof(Int32*)),
AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr))
});
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, _clsVar1);
ValidateResult(_clsVar1, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<Int32>* pClsVar1 = &_clsVar1)
{
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, AdvSimd.LoadVector128((Int32*)(pClsVar1)));
ValidateResult(_clsVar1, _dataTable.outArrayPtr);
}
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr);
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, op1);
ValidateResult(op1, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var op1 = AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr));
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, op1);
ValidateResult(op1, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new StoreUnaryOpTest__Store_Vector128_Int32();
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, test._fld1);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new StoreUnaryOpTest__Store_Vector128_Int32();
fixed (Vector128<Int32>* pFld1 = &test._fld1)
{
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, AdvSimd.LoadVector128((Int32*)(pFld1)));
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, _fld1);
ValidateResult(_fld1, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<Int32>* pFld1 = &_fld1)
{
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, AdvSimd.LoadVector128((Int32*)(pFld1)));
ValidateResult(_fld1, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, test._fld1);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, AdvSimd.LoadVector128((Int32*)(&test._fld1)));
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunStructFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
var test = TestStruct.Create();
test.RunStructFldScenario(this);
}
public void RunStructFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load));
var test = TestStruct.Create();
test.RunStructFldScenario_Load(this);
}
public void RunUnsupportedScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario));
bool succeeded = false;
try
{
RunBasicScenario_UnsafeRead();
}
catch (PlatformNotSupportedException)
{
succeeded = true;
}
if (!succeeded)
{
Succeeded = false;
}
}
private void ValidateResult(Vector128<Int32> op1, void* result, [CallerMemberName] string method = "")
{
Int32[] inArray1 = new Int32[Op1ElementCount];
Int32[] outArray = new Int32[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), op1);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>());
ValidateResult(inArray1, outArray, method);
}
private void ValidateResult(void* op1, void* result, [CallerMemberName] string method = "")
{
Int32[] inArray1 = new Int32[Op1ElementCount];
Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int32>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>());
ValidateResult(inArray1, outArray, method);
}
private void ValidateResult(Int32[] firstOp, Int32[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (int i = 0; i < RetElementCount; i++)
{
if (firstOp[i] != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.Store)}<Int32>(Vector128<Int32>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/******************************************************************************
* This file is auto-generated from a template file by the GenerateTests.csx *
* script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make *
* changes, please update the corresponding template and run according to the *
* directions listed in the file. *
******************************************************************************/
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
namespace JIT.HardwareIntrinsics.Arm
{
public static partial class Program
{
private static void Store_Vector128_Int32()
{
var test = new StoreUnaryOpTest__Store_Vector128_Int32();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates basic functionality works, using Load
test.RunBasicScenario_Load();
}
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates calling via reflection works, using Load
test.RunReflectionScenario_Load();
}
// Validates passing a static member works
test.RunClsVarScenario();
if (AdvSimd.IsSupported)
{
// Validates passing a static member works, using pinning and Load
test.RunClsVarScenario_Load();
}
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
if (AdvSimd.IsSupported)
{
// Validates passing a local works, using Load
test.RunLclVarScenario_Load();
}
// Validates passing the field of a local class works
test.RunClassLclFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing the field of a local class works, using pinning and Load
test.RunClassLclFldScenario_Load();
}
// Validates passing an instance member of a class works
test.RunClassFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing an instance member of a class works, using pinning and Load
test.RunClassFldScenario_Load();
}
// Validates passing the field of a local struct works
test.RunStructLclFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing the field of a local struct works, using pinning and Load
test.RunStructLclFldScenario_Load();
}
// Validates passing an instance member of a struct works
test.RunStructFldScenario();
if (AdvSimd.IsSupported)
{
// Validates passing an instance member of a struct works, using pinning and Load
test.RunStructFldScenario_Load();
}
}
else
{
// Validates we throw on unsupported hardware
test.RunUnsupportedScenario();
}
if (!test.Succeeded)
{
throw new Exception("One or more scenarios did not complete as expected.");
}
}
}
public sealed unsafe class StoreUnaryOpTest__Store_Vector128_Int32
{
private struct DataTable
{
private byte[] inArray1;
private byte[] outArray;
private GCHandle inHandle1;
private GCHandle outHandle;
private ulong alignment;
public DataTable(Int32[] inArray1, Int32[] outArray, int alignment)
{
int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int32>();
int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>();
if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray)
{
throw new ArgumentException("Invalid value of alignment");
}
this.inArray1 = new byte[alignment * 2];
this.outArray = new byte[alignment * 2];
this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned);
this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned);
this.alignment = (ulong)alignment;
Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int32, byte>(ref inArray1[0]), (uint)sizeOfinArray1);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment);
public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment);
public void Dispose()
{
inHandle1.Free();
outHandle.Free();
}
private static unsafe void* Align(byte* buffer, ulong expectedAlignment)
{
return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1));
}
}
private struct TestStruct
{
public Vector128<Int32> _fld1;
public static TestStruct Create()
{
var testStruct = new TestStruct();
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref testStruct._fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>());
return testStruct;
}
public void RunStructFldScenario(StoreUnaryOpTest__Store_Vector128_Int32 testClass)
{
AdvSimd.Store((Int32*)testClass._dataTable.outArrayPtr, _fld1);
testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
}
public void RunStructFldScenario_Load(StoreUnaryOpTest__Store_Vector128_Int32 testClass)
{
fixed (Vector128<Int32>* pFld1 = &_fld1)
{
AdvSimd.Store((Int32*)testClass._dataTable.outArrayPtr, AdvSimd.LoadVector128((Int32*)(pFld1)));
testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
}
}
}
private static readonly int LargestVectorSize = 16;
private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32);
private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32);
private static Int32[] _data1 = new Int32[Op1ElementCount];
private static Vector128<Int32> _clsVar1;
private Vector128<Int32> _fld1;
private DataTable _dataTable;
static StoreUnaryOpTest__Store_Vector128_Int32()
{
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>());
}
public StoreUnaryOpTest__Store_Vector128_Int32()
{
Succeeded = true;
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int32>>());
for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); }
_dataTable = new DataTable(_data1, new Int32[RetElementCount], LargestVectorSize);
}
public bool IsSupported => AdvSimd.IsSupported;
public bool Succeeded { get; set; }
public void RunBasicScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunBasicScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load));
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr)));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead));
typeof(AdvSimd).GetMethod(nameof(AdvSimd.Store), new Type[] { typeof(Int32*), typeof(Vector128<Int32>) })
.Invoke(null, new object[] {
Pointer.Box(_dataTable.outArrayPtr, typeof(Int32*)),
Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr) });
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunReflectionScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load));
typeof(AdvSimd).GetMethod(nameof(AdvSimd.Store), new Type[] { typeof(Int32*), typeof(Vector128<Int32>) })
.Invoke(null, new object[] {
Pointer.Box(_dataTable.outArrayPtr, typeof(Int32*)),
AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr))
});
ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
}
public void RunClsVarScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario));
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, _clsVar1);
ValidateResult(_clsVar1, _dataTable.outArrayPtr);
}
public void RunClsVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load));
fixed (Vector128<Int32>* pClsVar1 = &_clsVar1)
{
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, AdvSimd.LoadVector128((Int32*)(pClsVar1)));
ValidateResult(_clsVar1, _dataTable.outArrayPtr);
}
}
public void RunLclVarScenario_UnsafeRead()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead));
var op1 = Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr);
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, op1);
ValidateResult(op1, _dataTable.outArrayPtr);
}
public void RunLclVarScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));
var op1 = AdvSimd.LoadVector128((Int32*)(_dataTable.inArray1Ptr));
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, op1);
ValidateResult(op1, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));
var test = new StoreUnaryOpTest__Store_Vector128_Int32();
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, test._fld1);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunClassLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));
var test = new StoreUnaryOpTest__Store_Vector128_Int32();
fixed (Vector128<Int32>* pFld1 = &test._fld1)
{
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, AdvSimd.LoadVector128((Int32*)(pFld1)));
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
}
public void RunClassFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, _fld1);
ValidateResult(_fld1, _dataTable.outArrayPtr);
}
public void RunClassFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));
fixed (Vector128<Int32>* pFld1 = &_fld1)
{
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, AdvSimd.LoadVector128((Int32*)(pFld1)));
ValidateResult(_fld1, _dataTable.outArrayPtr);
}
}
public void RunStructLclFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));
var test = TestStruct.Create();
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, test._fld1);
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunStructLclFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));
var test = TestStruct.Create();
AdvSimd.Store((Int32*)_dataTable.outArrayPtr, AdvSimd.LoadVector128((Int32*)(&test._fld1)));
ValidateResult(test._fld1, _dataTable.outArrayPtr);
}
public void RunStructFldScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario));
var test = TestStruct.Create();
test.RunStructFldScenario(this);
}
public void RunStructFldScenario_Load()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load));
var test = TestStruct.Create();
test.RunStructFldScenario_Load(this);
}
public void RunUnsupportedScenario()
{
TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario));
bool succeeded = false;
try
{
RunBasicScenario_UnsafeRead();
}
catch (PlatformNotSupportedException)
{
succeeded = true;
}
if (!succeeded)
{
Succeeded = false;
}
}
private void ValidateResult(Vector128<Int32> op1, void* result, [CallerMemberName] string method = "")
{
Int32[] inArray1 = new Int32[Op1ElementCount];
Int32[] outArray = new Int32[RetElementCount];
Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), op1);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>());
ValidateResult(inArray1, outArray, method);
}
private void ValidateResult(void* op1, void* result, [CallerMemberName] string method = "")
{
Int32[] inArray1 = new Int32[Op1ElementCount];
Int32[] outArray = new Int32[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int32>>());
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>());
ValidateResult(inArray1, outArray, method);
}
private void ValidateResult(Int32[] firstOp, Int32[] result, [CallerMemberName] string method = "")
{
bool succeeded = true;
for (int i = 0; i < RetElementCount; i++)
{
if (firstOp[i] != result[i])
{
succeeded = false;
break;
}
}
if (!succeeded)
{
TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.Store)}<Int32>(Vector128<Int32>): {method} failed:");
TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})");
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})");
TestLibrary.TestFramework.LogInformation(string.Empty);
Succeeded = false;
}
}
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/JIT/Regression/JitBlue/GitHub_13561/GitHub_13561.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
internal static class Program
{
class MemberInfo { }
class PropertyInfo : MemberInfo { }
class CustomAttributeData
{
public Attribute Instantiate() => new CLSCompliantAttribute(false);
}
private static IEnumerable<CustomAttributeData> GetMatchingCustomAttributes(this MemberInfo element, Type optionalAttributeTypeFilter, bool inherit, bool skipTypeValidation = false)
{
{
PropertyInfo propertyInfo = element as PropertyInfo;
if (propertyInfo != null)
yield return new CustomAttributeData();
}
if (element == null)
throw new ArgumentNullException();
throw new NotSupportedException(); // Shouldn't get here.
}
private static IEnumerable<TOut> Select<TIn, TOut>(this IEnumerable<TIn> source, Func<TIn, TOut> transform)
{
foreach (var s in source)
yield return transform(s);
}
private static IEnumerable<T> GetCustomAttributes<T>(this MemberInfo element, bool inherit) where T : Attribute
{
IEnumerable<CustomAttributeData> matches = element.GetMatchingCustomAttributes(typeof(T), inherit, skipTypeValidation: true);
return matches.Select(m => (T)(m.Instantiate()));
}
private static AttributeType GetCustomAttribute<AttributeType>(PropertyInfo propInfo)
where AttributeType : Attribute
{
AttributeType result = null;
foreach (var attrib in propInfo.GetCustomAttributes<AttributeType>(false))
{
result = attrib;
break;
}
return result;
}
private static int Main(string[] args)
{
return GetCustomAttribute<Attribute>(new PropertyInfo()) != null ? 100 : -1;
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
internal static class Program
{
class MemberInfo { }
class PropertyInfo : MemberInfo { }
class CustomAttributeData
{
public Attribute Instantiate() => new CLSCompliantAttribute(false);
}
private static IEnumerable<CustomAttributeData> GetMatchingCustomAttributes(this MemberInfo element, Type optionalAttributeTypeFilter, bool inherit, bool skipTypeValidation = false)
{
{
PropertyInfo propertyInfo = element as PropertyInfo;
if (propertyInfo != null)
yield return new CustomAttributeData();
}
if (element == null)
throw new ArgumentNullException();
throw new NotSupportedException(); // Shouldn't get here.
}
private static IEnumerable<TOut> Select<TIn, TOut>(this IEnumerable<TIn> source, Func<TIn, TOut> transform)
{
foreach (var s in source)
yield return transform(s);
}
private static IEnumerable<T> GetCustomAttributes<T>(this MemberInfo element, bool inherit) where T : Attribute
{
IEnumerable<CustomAttributeData> matches = element.GetMatchingCustomAttributes(typeof(T), inherit, skipTypeValidation: true);
return matches.Select(m => (T)(m.Instantiate()));
}
private static AttributeType GetCustomAttribute<AttributeType>(PropertyInfo propInfo)
where AttributeType : Attribute
{
AttributeType result = null;
foreach (var attrib in propInfo.GetCustomAttributes<AttributeType>(false))
{
result = attrib;
break;
}
return result;
}
private static int Main(string[] args)
{
return GetCustomAttribute<Attribute>(new PropertyInfo()) != null ? 100 : -1;
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/JIT/IL_Conformance/Old/Conformance_Base/rem_i8.il | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
.assembly extern legacy library mscorlib {}
.class public _rem {
.method public static int64 _rem(int64,int64) {
.locals (class [mscorlib]System.Exception,int64)
.maxstack 3
try_start:
ldarg 0
ldarg 1
rem
stloc.1
leave.s try_end
try_end:
ldloc.1
br END
arithmetic:
isinst [mscorlib]System.ArithmeticException
stloc 0
leave AEEnd
AEEnd:
ldloc 0
brfalse FAIL
ldc.i8 0xAE
br END
divbyzero:
isinst [mscorlib]System.DivideByZeroException
stloc 0
leave DBZEnd
DBZEnd:
ldloc 0
brfalse FAIL
ldc.i8 0xDB0E
br END
FAIL:
ldc.i8 0xBAD
br END
END:
ret
.try try_start to try_end catch [mscorlib]System.DivideByZeroException handler divbyzero to DBZEnd
.try try_start to try_end catch [mscorlib]System.ArithmeticException handler arithmetic to AEEnd
}
.method public static int32 main(class [mscorlib]System.String[]) {
.entrypoint
.maxstack 20
ldc.i8 0x8000000000000000
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x8000000000000000
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0xAE
ceq
brfalse FAIL
ldc.i8 0x8000000000000000
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0x8000000000000000
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x8000000000000000
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0xFFFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0x8000000000000000
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0xD555555555555555
ceq
brfalse FAIL
ldc.i8 0x8000000000000000
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0xD555555555555556
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xFFFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0xFFFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0xFFFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0xFFFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0x0000000000000000
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000000
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000000
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0x0000000000000000
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000000
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000000
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x00000000
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000001
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000001
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000001
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000001
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0x7FFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0x2AAAAAAAAAAAAAAA
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0x2AAAAAAAAAAAAAA9
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0x5555555555555555
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x5555555555555555
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0x5555555555555555
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xAAAAAAAAAAAAAAAA
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0xAAAAAAAAAAAAAAAA
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0xFFFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i4 100
ret
FAIL:
ldc.i4 0x0
ret
}
}
.assembly rem_i8{}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
.assembly extern legacy library mscorlib {}
.class public _rem {
.method public static int64 _rem(int64,int64) {
.locals (class [mscorlib]System.Exception,int64)
.maxstack 3
try_start:
ldarg 0
ldarg 1
rem
stloc.1
leave.s try_end
try_end:
ldloc.1
br END
arithmetic:
isinst [mscorlib]System.ArithmeticException
stloc 0
leave AEEnd
AEEnd:
ldloc 0
brfalse FAIL
ldc.i8 0xAE
br END
divbyzero:
isinst [mscorlib]System.DivideByZeroException
stloc 0
leave DBZEnd
DBZEnd:
ldloc 0
brfalse FAIL
ldc.i8 0xDB0E
br END
FAIL:
ldc.i8 0xBAD
br END
END:
ret
.try try_start to try_end catch [mscorlib]System.DivideByZeroException handler divbyzero to DBZEnd
.try try_start to try_end catch [mscorlib]System.ArithmeticException handler arithmetic to AEEnd
}
.method public static int32 main(class [mscorlib]System.String[]) {
.entrypoint
.maxstack 20
ldc.i8 0x8000000000000000
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x8000000000000000
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0xAE
ceq
brfalse FAIL
ldc.i8 0x8000000000000000
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0x8000000000000000
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x8000000000000000
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0xFFFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0x8000000000000000
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0xD555555555555555
ceq
brfalse FAIL
ldc.i8 0x8000000000000000
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0xD555555555555556
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xFFFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0xFFFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0xFFFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0xFFFFFFFFFFFFFFFF
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0xFFFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0x0000000000000000
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000000
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000000
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0x0000000000000000
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000000
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000000
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x00000000
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000001
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000001
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000001
ceq
brfalse FAIL
ldc.i8 0x0000000000000001
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000001
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0x7FFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0x2AAAAAAAAAAAAAAA
ceq
brfalse FAIL
ldc.i8 0x7FFFFFFFFFFFFFFF
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0x2AAAAAAAAAAAAAA9
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0x5555555555555555
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x5555555555555555
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0x5555555555555555
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0x5555555555555555
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0x8000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xAAAAAAAAAAAAAAAA
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0xFFFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0x0000000000000000
call int64 _rem::_rem(int64,int64)
ldc.i8 0xDB0E
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0x0000000000000001
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0x7FFFFFFFFFFFFFFF
call int64 _rem::_rem(int64,int64)
ldc.i8 0xAAAAAAAAAAAAAAAA
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0x5555555555555555
call int64 _rem::_rem(int64,int64)
ldc.i8 0xFFFFFFFFFFFFFFFF
ceq
brfalse FAIL
ldc.i8 0xAAAAAAAAAAAAAAAA
ldc.i8 0xAAAAAAAAAAAAAAAA
call int64 _rem::_rem(int64,int64)
ldc.i8 0x0000000000000000
ceq
brfalse FAIL
ldc.i4 100
ret
FAIL:
ldc.i4 0x0
ret
}
}
.assembly rem_i8{}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Parameters/RoPropertyIndexParameter.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.Diagnostics;
namespace System.Reflection.TypeLoading
{
/// <summary>
/// Base class for all RoParameter's returned by PropertyInfo.GetParameters(). These are identical to the associated
/// getter's ParameterInfo's except for the Member property returning a property.
/// </summary>
internal sealed class RoPropertyIndexParameter : RoParameter
{
private readonly RoParameter _backingParameter;
internal RoPropertyIndexParameter(RoProperty member, RoParameter backingParameter)
: base(member, backingParameter.Position)
{
Debug.Assert(member != null);
Debug.Assert(backingParameter != null);
_backingParameter = backingParameter;
}
public sealed override int MetadataToken => _backingParameter.MetadataToken;
public sealed override string? Name => _backingParameter.Name;
public sealed override Type ParameterType => _backingParameter.ParameterType;
public sealed override ParameterAttributes Attributes => _backingParameter.Attributes;
public sealed override IEnumerable<CustomAttributeData> CustomAttributes => _backingParameter.CustomAttributes;
public sealed override bool HasDefaultValue => _backingParameter.HasDefaultValue;
public sealed override object? RawDefaultValue => _backingParameter.RawDefaultValue;
public sealed override Type[] GetOptionalCustomModifiers() => _backingParameter.GetOptionalCustomModifiers();
public sealed override Type[] GetRequiredCustomModifiers() => _backingParameter.GetRequiredCustomModifiers();
public sealed override string ToString() => _backingParameter.ToString();
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.Diagnostics;
namespace System.Reflection.TypeLoading
{
/// <summary>
/// Base class for all RoParameter's returned by PropertyInfo.GetParameters(). These are identical to the associated
/// getter's ParameterInfo's except for the Member property returning a property.
/// </summary>
internal sealed class RoPropertyIndexParameter : RoParameter
{
private readonly RoParameter _backingParameter;
internal RoPropertyIndexParameter(RoProperty member, RoParameter backingParameter)
: base(member, backingParameter.Position)
{
Debug.Assert(member != null);
Debug.Assert(backingParameter != null);
_backingParameter = backingParameter;
}
public sealed override int MetadataToken => _backingParameter.MetadataToken;
public sealed override string? Name => _backingParameter.Name;
public sealed override Type ParameterType => _backingParameter.ParameterType;
public sealed override ParameterAttributes Attributes => _backingParameter.Attributes;
public sealed override IEnumerable<CustomAttributeData> CustomAttributes => _backingParameter.CustomAttributes;
public sealed override bool HasDefaultValue => _backingParameter.HasDefaultValue;
public sealed override object? RawDefaultValue => _backingParameter.RawDefaultValue;
public sealed override Type[] GetOptionalCustomModifiers() => _backingParameter.GetOptionalCustomModifiers();
public sealed override Type[] GetRequiredCustomModifiers() => _backingParameter.GetRequiredCustomModifiers();
public sealed override string ToString() => _backingParameter.ToString();
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/UInt32Converter.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Text.Json.Serialization.Converters
{
internal sealed class UInt32Converter : JsonConverter<uint>
{
public UInt32Converter()
{
IsInternalConverterForNumberType = true;
}
public override uint Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.GetUInt32();
}
public override void Write(Utf8JsonWriter writer, uint value, JsonSerializerOptions options)
{
// For performance, lift up the writer implementation.
writer.WriteNumberValue((ulong)value);
}
internal override uint ReadAsPropertyNameCore(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.GetUInt32WithQuotes();
}
internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, uint value, JsonSerializerOptions options, bool isWritingExtensionDataProperty)
{
writer.WritePropertyName(value);
}
internal override uint ReadNumberWithCustomHandling(ref Utf8JsonReader reader, JsonNumberHandling handling, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.String &&
(JsonNumberHandling.AllowReadingFromString & handling) != 0)
{
return reader.GetUInt32WithQuotes();
}
return reader.GetUInt32();
}
internal override void WriteNumberWithCustomHandling(Utf8JsonWriter writer, uint value, JsonNumberHandling handling)
{
if ((JsonNumberHandling.WriteAsString & handling) != 0)
{
writer.WriteNumberValueAsString(value);
}
else
{
// For performance, lift up the writer implementation.
writer.WriteNumberValue((ulong)value);
}
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Text.Json.Serialization.Converters
{
internal sealed class UInt32Converter : JsonConverter<uint>
{
public UInt32Converter()
{
IsInternalConverterForNumberType = true;
}
public override uint Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.GetUInt32();
}
public override void Write(Utf8JsonWriter writer, uint value, JsonSerializerOptions options)
{
// For performance, lift up the writer implementation.
writer.WriteNumberValue((ulong)value);
}
internal override uint ReadAsPropertyNameCore(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.GetUInt32WithQuotes();
}
internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, uint value, JsonSerializerOptions options, bool isWritingExtensionDataProperty)
{
writer.WritePropertyName(value);
}
internal override uint ReadNumberWithCustomHandling(ref Utf8JsonReader reader, JsonNumberHandling handling, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.String &&
(JsonNumberHandling.AllowReadingFromString & handling) != 0)
{
return reader.GetUInt32WithQuotes();
}
return reader.GetUInt32();
}
internal override void WriteNumberWithCustomHandling(Utf8JsonWriter writer, uint value, JsonNumberHandling handling)
{
if ((JsonNumberHandling.WriteAsString & handling) != 0)
{
writer.WriteNumberValueAsString(value);
}
else
{
// For performance, lift up the writer implementation.
writer.WriteNumberValue((ulong)value);
}
}
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/RegexGeneratorAttributeTests.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Threading;
using Xunit;
namespace System.Text.RegularExpressions.Tests
{
public class RegexGeneratorAttributeTests
{
[Theory]
[InlineData(null, RegexOptions.None, Timeout.Infinite)]
[InlineData("", (RegexOptions)12345, -2)]
[InlineData("a.*b", RegexOptions.Compiled | RegexOptions.CultureInvariant, 1)]
public void Ctor_Roundtrips(string pattern, RegexOptions options, int matchTimeoutMilliseconds)
{
RegexGeneratorAttribute a;
if (matchTimeoutMilliseconds == -1)
{
if (options == RegexOptions.None)
{
a = new RegexGeneratorAttribute(pattern);
Assert.Equal(pattern, a.Pattern);
Assert.Equal(RegexOptions.None, a.Options);
Assert.Equal(Timeout.Infinite, a.MatchTimeoutMilliseconds);
}
a = new RegexGeneratorAttribute(pattern, options);
Assert.Equal(pattern, a.Pattern);
Assert.Equal(options, a.Options);
Assert.Equal(Timeout.Infinite, a.MatchTimeoutMilliseconds);
}
a = new RegexGeneratorAttribute(pattern, options, matchTimeoutMilliseconds);
Assert.Equal(pattern, a.Pattern);
Assert.Equal(options, a.Options);
Assert.Equal(matchTimeoutMilliseconds, a.MatchTimeoutMilliseconds);
}
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Threading;
using Xunit;
namespace System.Text.RegularExpressions.Tests
{
public class RegexGeneratorAttributeTests
{
[Theory]
[InlineData(null, RegexOptions.None, Timeout.Infinite)]
[InlineData("", (RegexOptions)12345, -2)]
[InlineData("a.*b", RegexOptions.Compiled | RegexOptions.CultureInvariant, 1)]
public void Ctor_Roundtrips(string pattern, RegexOptions options, int matchTimeoutMilliseconds)
{
RegexGeneratorAttribute a;
if (matchTimeoutMilliseconds == -1)
{
if (options == RegexOptions.None)
{
a = new RegexGeneratorAttribute(pattern);
Assert.Equal(pattern, a.Pattern);
Assert.Equal(RegexOptions.None, a.Options);
Assert.Equal(Timeout.Infinite, a.MatchTimeoutMilliseconds);
}
a = new RegexGeneratorAttribute(pattern, options);
Assert.Equal(pattern, a.Pattern);
Assert.Equal(options, a.Options);
Assert.Equal(Timeout.Infinite, a.MatchTimeoutMilliseconds);
}
a = new RegexGeneratorAttribute(pattern, options, matchTimeoutMilliseconds);
Assert.Equal(pattern, a.Pattern);
Assert.Equal(options, a.Options);
Assert.Equal(matchTimeoutMilliseconds, a.MatchTimeoutMilliseconds);
}
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/Loader/classloader/TypeGeneratorTests/TypeGeneratorTest968/Generated968.il | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
.assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) .ver 4:0:0:0 }
.assembly extern TestFramework { .publickeytoken = ( B0 3F 5F 7F 11 D5 0A 3A ) }
//TYPES IN FORWARDER ASSEMBLIES:
//TEST ASSEMBLY:
.assembly Generated968 { .hash algorithm 0x00008004 }
.assembly extern xunit.core {}
.class public BaseClass0
{
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed {
ldarg.0
call instance void [mscorlib]System.Object::.ctor()
ret
}
}
.class public BaseClass1
extends BaseClass0
{
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed {
ldarg.0
call instance void BaseClass0::.ctor()
ret
}
}
.class public G3_C1440`1<T0>
extends class G2_C471`2<!T0,class BaseClass0>
implements class IBase2`2<!T0,class BaseClass1>
{
.method public hidebysig newslot virtual instance string Method7<M0>() cil managed noinlining {
ldstr "G3_C1440::Method7.16190<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string ClassMethod4268() cil managed noinlining {
ldstr "G3_C1440::ClassMethod4268.16191()"
ret
}
.method public hidebysig newslot virtual instance string ClassMethod4269() cil managed noinlining {
ldstr "G3_C1440::ClassMethod4269.16192()"
ret
}
.method public hidebysig newslot virtual instance string ClassMethod4270<M0>() cil managed noinlining {
ldstr "G3_C1440::ClassMethod4270.16193<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string 'G2_C471<T0,class BaseClass0>.ClassMethod2300'() cil managed noinlining {
.override method instance string class G2_C471`2<!T0,class BaseClass0>::ClassMethod2300()
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ret
}
.method public hidebysig newslot virtual instance string 'G2_C471<T0,class BaseClass0>.ClassMethod2302'<M0>() cil managed noinlining {
.override method instance string class G2_C471`2<!T0,class BaseClass0>::ClassMethod2302<[1]>()
ldstr "G3_C1440::ClassMethod2302.MI.16195<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed {
ldarg.0
call instance void class G2_C471`2<!T0,class BaseClass0>::.ctor()
ret
}
}
.class public G2_C471`2<T0, T1>
extends class G1_C9`2<class BaseClass0,class BaseClass0>
implements class IBase2`2<class BaseClass1,!T1>, class IBase1`1<class BaseClass0>
{
.method public hidebysig virtual instance string Method7<M0>() cil managed noinlining {
ldstr "G2_C471::Method7.9269<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig virtual instance string Method4() cil managed noinlining {
ldstr "G2_C471::Method4.9270()"
ret
}
.method public hidebysig virtual instance string Method5() cil managed noinlining {
ldstr "G2_C471::Method5.9271()"
ret
}
.method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method5'() cil managed noinlining {
.override method instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ret
}
.method public hidebysig newslot virtual instance string Method6<M0>() cil managed noinlining {
ldstr "G2_C471::Method6.9273<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method6'<M0>() cil managed noinlining {
.override method instance string class IBase1`1<class BaseClass0>::Method6<[1]>()
ldstr "G2_C471::Method6.MI.9274<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string ClassMethod2300() cil managed noinlining {
ldstr "G2_C471::ClassMethod2300.9275()"
ret
}
.method public hidebysig newslot virtual instance string ClassMethod2301() cil managed noinlining {
ldstr "G2_C471::ClassMethod2301.9276()"
ret
}
.method public hidebysig newslot virtual instance string ClassMethod2302<M0>() cil managed noinlining {
ldstr "G2_C471::ClassMethod2302.9277<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string ClassMethod2303<M0>() cil managed noinlining {
ldstr "G2_C471::ClassMethod2303.9278<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string 'G1_C9<class BaseClass0,class BaseClass0>.ClassMethod1336'() cil managed noinlining {
.override method instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ret
}
.method public hidebysig newslot virtual instance string 'G1_C9<class BaseClass0,class BaseClass0>.ClassMethod1337'() cil managed noinlining {
.override method instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ret
}
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed {
ldarg.0
call instance void class G1_C9`2<class BaseClass0,class BaseClass0>::.ctor()
ret
}
}
.class interface public abstract IBase2`2<+T0, -T1>
{
.method public hidebysig newslot abstract virtual instance string Method7<M0>() cil managed { }
}
.class public abstract G1_C9`2<T0, T1>
implements class IBase2`2<class BaseClass0,!T0>, class IBase1`1<class BaseClass0>
{
.method public hidebysig virtual instance string Method7<M0>() cil managed noinlining {
ldstr "G1_C9::Method7.4833<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig virtual instance string Method4() cil managed noinlining {
ldstr "G1_C9::Method4.4834()"
ret
}
.method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method4'() cil managed noinlining {
.override method instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G1_C9::Method4.MI.4835()"
ret
}
.method public hidebysig newslot virtual instance string Method5() cil managed noinlining {
ldstr "G1_C9::Method5.4836()"
ret
}
.method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method5'() cil managed noinlining {
.override method instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G1_C9::Method5.MI.4837()"
ret
}
.method public hidebysig virtual instance string Method6<M0>() cil managed noinlining {
ldstr "G1_C9::Method6.4838<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method6'<M0>() cil managed noinlining {
.override method instance string class IBase1`1<class BaseClass0>::Method6<[1]>()
ldstr "G1_C9::Method6.MI.4839<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string ClassMethod1336() cil managed noinlining {
ldstr "G1_C9::ClassMethod1336.4840()"
ret
}
.method public hidebysig newslot virtual instance string ClassMethod1337() cil managed noinlining {
ldstr "G1_C9::ClassMethod1337.4841()"
ret
}
.method public hidebysig newslot virtual instance string ClassMethod1338<M0>() cil managed noinlining {
ldstr "G1_C9::ClassMethod1338.4842<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string ClassMethod1339<M0>() cil managed noinlining {
ldstr "G1_C9::ClassMethod1339.4843<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed {
ldarg.0
call instance void [mscorlib]System.Object::.ctor()
ret
}
}
.class interface public abstract IBase1`1<+T0>
{
.method public hidebysig newslot abstract virtual instance string Method4() cil managed { }
.method public hidebysig newslot abstract virtual instance string Method5() cil managed { }
.method public hidebysig newslot abstract virtual instance string Method6<M0>() cil managed { }
}
.class public auto ansi beforefieldinit Generated968 {
.method static void M.BaseClass0<(BaseClass0)W>(!!W inst, string exp) cil managed {
.maxstack 5
.locals init (string[] actualResults)
ldc.i4.s 0
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.BaseClass0<(BaseClass0)W>(!!W inst, string exp)"
ldc.i4.s 0
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.BaseClass1<(BaseClass1)W>(!!W inst, string exp) cil managed {
.maxstack 5
.locals init (string[] actualResults)
ldc.i4.s 0
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.BaseClass1<(BaseClass1)W>(!!W inst, string exp)"
ldc.i4.s 0
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G3_C1440.T<T0,(class G3_C1440`1<!!T0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 20
.locals init (string[] actualResults)
ldc.i4.s 15
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G3_C1440.T<T0,(class G3_C1440`1<!!T0>)W>(!!W 'inst', string exp)"
ldc.i4.s 15
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod4268()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod4269()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod4270<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 12
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 13
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 14
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G3_C1440.A<(class G3_C1440`1<class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 20
.locals init (string[] actualResults)
ldc.i4.s 15
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G3_C1440.A<(class G3_C1440`1<class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 15
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod4268()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod4269()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod4270<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 12
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 13
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 14
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G3_C1440.B<(class G3_C1440`1<class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 20
.locals init (string[] actualResults)
ldc.i4.s 15
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G3_C1440.B<(class G3_C1440`1<class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 15
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod4268()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod4269()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod4270<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 12
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 13
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 14
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.T.T<T0,T1,(class G2_C471`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.T.T<T0,T1,(class G2_C471`2<!!T0,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.A.T<T1,(class G2_C471`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.A.T<T1,(class G2_C471`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.A.A<(class G2_C471`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.A.A<(class G2_C471`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.A.B<(class G2_C471`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.A.B<(class G2_C471`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.B.T<T1,(class G2_C471`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.B.T<T1,(class G2_C471`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.B.A<(class G2_C471`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.B.A<(class G2_C471`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.B.B<(class G2_C471`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.B.B<(class G2_C471`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.T.T<T0,T1,(class IBase2`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.T.T<T0,T1,(class IBase2`2<!!T0,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<!!T0,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.A.T<T1,(class IBase2`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.A.T<T1,(class IBase2`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<class BaseClass0,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.A.A<(class IBase2`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.A.A<(class IBase2`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.A.B<(class IBase2`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.A.B<(class IBase2`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.B.T<T1,(class IBase2`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.B.T<T1,(class IBase2`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<class BaseClass1,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.B.A<(class IBase2`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.B.A<(class IBase2`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.B.B<(class IBase2`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.B.B<(class IBase2`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.T.T<T0,T1,(class G1_C9`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.T.T<T0,T1,(class G1_C9`2<!!T0,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.A.T<T1,(class G1_C9`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.A.T<T1,(class G1_C9`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.A.A<(class G1_C9`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.A.A<(class G1_C9`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.A.B<(class G1_C9`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.A.B<(class G1_C9`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.B.T<T1,(class G1_C9`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.B.T<T1,(class G1_C9`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.B.A<(class G1_C9`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.B.A<(class G1_C9`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.B.B<(class G1_C9`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.B.B<(class G1_C9`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase1.T<T0,(class IBase1`1<!!T0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 8
.locals init (string[] actualResults)
ldc.i4.s 3
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase1.T<T0,(class IBase1`1<!!T0>)W>(!!W 'inst', string exp)"
ldc.i4.s 3
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<!!T0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<!!T0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<!!T0>::Method6<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase1.A<(class IBase1`1<class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 8
.locals init (string[] actualResults)
ldc.i4.s 3
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase1.A<(class IBase1`1<class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 3
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase1.B<(class IBase1`1<class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 8
.locals init (string[] actualResults)
ldc.i4.s 3
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase1.B<(class IBase1`1<class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 3
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<class BaseClass1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<class BaseClass1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<class BaseClass1>::Method6<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method public hidebysig static void MethodCallingTest() cil managed
{
.maxstack 10
.locals init (object V_0)
ldstr "========================== Method Calling Test =========================="
call void [mscorlib]System.Console::WriteLine(string)
newobj instance void class G3_C1440`1<class BaseClass0>::.ctor()
stloc.0
ldloc.0
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2302<object>()
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2300()
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod4270<object>()
ldstr "G3_C1440::ClassMethod4270.16193<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod4269()
ldstr "G3_C1440::ClassMethod4269.16192()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod4268()
ldstr "G3_C1440::ClassMethod4268.16191()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::Method7<object>()
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2302<object>()
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2300()
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
newobj instance void class G3_C1440`1<class BaseClass1>::.ctor()
stloc.0
ldloc.0
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2302<object>()
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2300()
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod4270<object>()
ldstr "G3_C1440::ClassMethod4270.16193<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod4269()
ldstr "G3_C1440::ClassMethod4269.16192()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod4268()
ldstr "G3_C1440::ClassMethod4268.16191()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::Method7<object>()
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2302<object>()
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2300()
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
newobj instance void class G2_C471`2<class BaseClass0,class BaseClass0>::.ctor()
stloc.0
ldloc.0
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2302<object>()
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2300()
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
newobj instance void class G2_C471`2<class BaseClass0,class BaseClass1>::.ctor()
stloc.0
ldloc.0
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2302<object>()
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2300()
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
newobj instance void class G2_C471`2<class BaseClass1,class BaseClass0>::.ctor()
stloc.0
ldloc.0
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2302<object>()
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2300()
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
newobj instance void class G2_C471`2<class BaseClass1,class BaseClass1>::.ctor()
stloc.0
ldloc.0
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2302<object>()
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2300()
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldstr "========================================================================\n\n"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method public hidebysig static void ConstrainedCallsTest() cil managed
{
.maxstack 10
.locals init (object V_0)
ldstr "========================== Constrained Calls Test =========================="
call void [mscorlib]System.Console::WriteLine(string)
newobj instance void class G3_C1440`1<class BaseClass0>::.ctor()
stloc.0
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.T.T<class BaseClass0,class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.T<class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.A<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.A<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.T<class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.A<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G3_C1440`1<class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass1,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.A.B<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.T.T<class BaseClass0,class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.A.T<class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.A.A<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.A<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G3_C1440`1<class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass1,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.B<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G3_C1440::ClassMethod4268.16191()#G3_C1440::ClassMethod4269.16192()#G3_C1440::ClassMethod4270.16193<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.G3_C1440.T<class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G3_C1440::ClassMethod4268.16191()#G3_C1440::ClassMethod4269.16192()#G3_C1440::ClassMethod4270.16193<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.G3_C1440.A<class G3_C1440`1<class BaseClass0>>(!!0,string)
newobj instance void class G3_C1440`1<class BaseClass1>::.ctor()
stloc.0
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.T.T<class BaseClass0,class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.T<class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.A<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.A<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.T<class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.A<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G3_C1440`1<class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass1,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.A.B<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.T.T<class BaseClass1,class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.B.T<class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.B.A<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.A<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G3_C1440`1<class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass1,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.B.B<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G3_C1440::ClassMethod4268.16191()#G3_C1440::ClassMethod4269.16192()#G3_C1440::ClassMethod4270.16193<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.G3_C1440.T<class BaseClass1,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G3_C1440::ClassMethod4268.16191()#G3_C1440::ClassMethod4269.16192()#G3_C1440::ClassMethod4270.16193<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.G3_C1440.B<class G3_C1440`1<class BaseClass1>>(!!0,string)
newobj instance void class G2_C471`2<class BaseClass0,class BaseClass0>::.ctor()
stloc.0
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.A<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.A<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.A<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.B<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.A.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.A.A<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.A<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.B<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
newobj instance void class G2_C471`2<class BaseClass0,class BaseClass1>::.ctor()
stloc.0
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.A<class G2_C471`2<class BaseClass0,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.A<class G2_C471`2<class BaseClass0,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.A<class G2_C471`2<class BaseClass0,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.B<class G2_C471`2<class BaseClass0,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.T.T<class BaseClass0,class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.A.T<class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.A.B<class G2_C471`2<class BaseClass0,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.B<class G2_C471`2<class BaseClass0,class BaseClass1>>(!!0,string)
newobj instance void class G2_C471`2<class BaseClass1,class BaseClass0>::.ctor()
stloc.0
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.A<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.A<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.A<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.B<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.T.T<class BaseClass1,class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.B.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.B.A<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.A<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.B<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
newobj instance void class G2_C471`2<class BaseClass1,class BaseClass1>::.ctor()
stloc.0
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.A<class G2_C471`2<class BaseClass1,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.A<class G2_C471`2<class BaseClass1,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.A<class G2_C471`2<class BaseClass1,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.B<class G2_C471`2<class BaseClass1,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.T.T<class BaseClass1,class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.B.T<class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.B.B<class G2_C471`2<class BaseClass1,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.B<class G2_C471`2<class BaseClass1,class BaseClass1>>(!!0,string)
ldstr "========================================================================\n\n"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method public hidebysig static void StructConstrainedInterfaceCallsTest() cil managed
{
.maxstack 10
ldstr "===================== Struct Constrained Interface Calls Test ====================="
call void [mscorlib]System.Console::WriteLine(string)
ldstr "========================================================================\n\n"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method public hidebysig static void CalliTest() cil managed
{
.maxstack 10
.locals init (object V_0)
ldstr "========================== Method Calli Test =========================="
call void [mscorlib]System.Console::WriteLine(string)
newobj instance void class G3_C1440`1<class BaseClass0>::.ctor()
stloc.0
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2303<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2302<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2301()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2300()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod4270<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod4270.16193<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod4269()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod4269.16192()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod4268()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod4268.16191()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod2303<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod2302<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod2301()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod2300()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod1339<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod1338<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod1337()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod1336()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
newobj instance void class G3_C1440`1<class BaseClass1>::.ctor()
stloc.0
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2303<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2302<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2301()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2300()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1337()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1336()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod4270<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod4270.16193<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod4269()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod4269.16192()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod4268()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod4268.16191()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod2303<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod2302<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod2301()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod2300()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::Method5()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::Method4()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod1339<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod1338<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod1337()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod1336()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
newobj instance void class G2_C471`2<class BaseClass0,class BaseClass0>::.ctor()
stloc.0
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2303<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2302<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2301()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2300()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
newobj instance void class G2_C471`2<class BaseClass0,class BaseClass1>::.ctor()
stloc.0
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2303<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2302<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2301()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2300()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method5()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method4()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
newobj instance void class G2_C471`2<class BaseClass1,class BaseClass0>::.ctor()
stloc.0
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2303<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2302<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2301()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2300()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
newobj instance void class G2_C471`2<class BaseClass1,class BaseClass1>::.ctor()
stloc.0
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2303<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2302<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2301()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2300()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method5()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method4()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldstr "========================================================================\n\n"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method public hidebysig static int32 Main() cil managed
{
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (
01 00 00 00
)
.entrypoint
.maxstack 10
call void Generated968::MethodCallingTest()
call void Generated968::ConstrainedCallsTest()
call void Generated968::StructConstrainedInterfaceCallsTest()
call void Generated968::CalliTest()
ldc.i4 100
ret
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
.assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) .ver 4:0:0:0 }
.assembly extern TestFramework { .publickeytoken = ( B0 3F 5F 7F 11 D5 0A 3A ) }
//TYPES IN FORWARDER ASSEMBLIES:
//TEST ASSEMBLY:
.assembly Generated968 { .hash algorithm 0x00008004 }
.assembly extern xunit.core {}
.class public BaseClass0
{
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed {
ldarg.0
call instance void [mscorlib]System.Object::.ctor()
ret
}
}
.class public BaseClass1
extends BaseClass0
{
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed {
ldarg.0
call instance void BaseClass0::.ctor()
ret
}
}
.class public G3_C1440`1<T0>
extends class G2_C471`2<!T0,class BaseClass0>
implements class IBase2`2<!T0,class BaseClass1>
{
.method public hidebysig newslot virtual instance string Method7<M0>() cil managed noinlining {
ldstr "G3_C1440::Method7.16190<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string ClassMethod4268() cil managed noinlining {
ldstr "G3_C1440::ClassMethod4268.16191()"
ret
}
.method public hidebysig newslot virtual instance string ClassMethod4269() cil managed noinlining {
ldstr "G3_C1440::ClassMethod4269.16192()"
ret
}
.method public hidebysig newslot virtual instance string ClassMethod4270<M0>() cil managed noinlining {
ldstr "G3_C1440::ClassMethod4270.16193<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string 'G2_C471<T0,class BaseClass0>.ClassMethod2300'() cil managed noinlining {
.override method instance string class G2_C471`2<!T0,class BaseClass0>::ClassMethod2300()
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ret
}
.method public hidebysig newslot virtual instance string 'G2_C471<T0,class BaseClass0>.ClassMethod2302'<M0>() cil managed noinlining {
.override method instance string class G2_C471`2<!T0,class BaseClass0>::ClassMethod2302<[1]>()
ldstr "G3_C1440::ClassMethod2302.MI.16195<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed {
ldarg.0
call instance void class G2_C471`2<!T0,class BaseClass0>::.ctor()
ret
}
}
.class public G2_C471`2<T0, T1>
extends class G1_C9`2<class BaseClass0,class BaseClass0>
implements class IBase2`2<class BaseClass1,!T1>, class IBase1`1<class BaseClass0>
{
.method public hidebysig virtual instance string Method7<M0>() cil managed noinlining {
ldstr "G2_C471::Method7.9269<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig virtual instance string Method4() cil managed noinlining {
ldstr "G2_C471::Method4.9270()"
ret
}
.method public hidebysig virtual instance string Method5() cil managed noinlining {
ldstr "G2_C471::Method5.9271()"
ret
}
.method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method5'() cil managed noinlining {
.override method instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ret
}
.method public hidebysig newslot virtual instance string Method6<M0>() cil managed noinlining {
ldstr "G2_C471::Method6.9273<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method6'<M0>() cil managed noinlining {
.override method instance string class IBase1`1<class BaseClass0>::Method6<[1]>()
ldstr "G2_C471::Method6.MI.9274<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string ClassMethod2300() cil managed noinlining {
ldstr "G2_C471::ClassMethod2300.9275()"
ret
}
.method public hidebysig newslot virtual instance string ClassMethod2301() cil managed noinlining {
ldstr "G2_C471::ClassMethod2301.9276()"
ret
}
.method public hidebysig newslot virtual instance string ClassMethod2302<M0>() cil managed noinlining {
ldstr "G2_C471::ClassMethod2302.9277<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string ClassMethod2303<M0>() cil managed noinlining {
ldstr "G2_C471::ClassMethod2303.9278<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string 'G1_C9<class BaseClass0,class BaseClass0>.ClassMethod1336'() cil managed noinlining {
.override method instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ret
}
.method public hidebysig newslot virtual instance string 'G1_C9<class BaseClass0,class BaseClass0>.ClassMethod1337'() cil managed noinlining {
.override method instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ret
}
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed {
ldarg.0
call instance void class G1_C9`2<class BaseClass0,class BaseClass0>::.ctor()
ret
}
}
.class interface public abstract IBase2`2<+T0, -T1>
{
.method public hidebysig newslot abstract virtual instance string Method7<M0>() cil managed { }
}
.class public abstract G1_C9`2<T0, T1>
implements class IBase2`2<class BaseClass0,!T0>, class IBase1`1<class BaseClass0>
{
.method public hidebysig virtual instance string Method7<M0>() cil managed noinlining {
ldstr "G1_C9::Method7.4833<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig virtual instance string Method4() cil managed noinlining {
ldstr "G1_C9::Method4.4834()"
ret
}
.method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method4'() cil managed noinlining {
.override method instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G1_C9::Method4.MI.4835()"
ret
}
.method public hidebysig newslot virtual instance string Method5() cil managed noinlining {
ldstr "G1_C9::Method5.4836()"
ret
}
.method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method5'() cil managed noinlining {
.override method instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G1_C9::Method5.MI.4837()"
ret
}
.method public hidebysig virtual instance string Method6<M0>() cil managed noinlining {
ldstr "G1_C9::Method6.4838<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method6'<M0>() cil managed noinlining {
.override method instance string class IBase1`1<class BaseClass0>::Method6<[1]>()
ldstr "G1_C9::Method6.MI.4839<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string ClassMethod1336() cil managed noinlining {
ldstr "G1_C9::ClassMethod1336.4840()"
ret
}
.method public hidebysig newslot virtual instance string ClassMethod1337() cil managed noinlining {
ldstr "G1_C9::ClassMethod1337.4841()"
ret
}
.method public hidebysig newslot virtual instance string ClassMethod1338<M0>() cil managed noinlining {
ldstr "G1_C9::ClassMethod1338.4842<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig newslot virtual instance string ClassMethod1339<M0>() cil managed noinlining {
ldstr "G1_C9::ClassMethod1339.4843<"
ldtoken !!M0
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
call string [mscorlib]System.String::Concat(object,object)
ldstr ">()"
call string [mscorlib]System.String::Concat(object,object)
ret
}
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed {
ldarg.0
call instance void [mscorlib]System.Object::.ctor()
ret
}
}
.class interface public abstract IBase1`1<+T0>
{
.method public hidebysig newslot abstract virtual instance string Method4() cil managed { }
.method public hidebysig newslot abstract virtual instance string Method5() cil managed { }
.method public hidebysig newslot abstract virtual instance string Method6<M0>() cil managed { }
}
.class public auto ansi beforefieldinit Generated968 {
.method static void M.BaseClass0<(BaseClass0)W>(!!W inst, string exp) cil managed {
.maxstack 5
.locals init (string[] actualResults)
ldc.i4.s 0
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.BaseClass0<(BaseClass0)W>(!!W inst, string exp)"
ldc.i4.s 0
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.BaseClass1<(BaseClass1)W>(!!W inst, string exp) cil managed {
.maxstack 5
.locals init (string[] actualResults)
ldc.i4.s 0
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.BaseClass1<(BaseClass1)W>(!!W inst, string exp)"
ldc.i4.s 0
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G3_C1440.T<T0,(class G3_C1440`1<!!T0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 20
.locals init (string[] actualResults)
ldc.i4.s 15
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G3_C1440.T<T0,(class G3_C1440`1<!!T0>)W>(!!W 'inst', string exp)"
ldc.i4.s 15
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod4268()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod4269()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::ClassMethod4270<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 12
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 13
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 14
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<!!T0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G3_C1440.A<(class G3_C1440`1<class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 20
.locals init (string[] actualResults)
ldc.i4.s 15
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G3_C1440.A<(class G3_C1440`1<class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 15
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod4268()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod4269()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod4270<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 12
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 13
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 14
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G3_C1440.B<(class G3_C1440`1<class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 20
.locals init (string[] actualResults)
ldc.i4.s 15
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G3_C1440.B<(class G3_C1440`1<class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 15
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod4268()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod4269()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod4270<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 12
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 13
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 14
ldarga.s 0
constrained. !!W
callvirt instance string class G3_C1440`1<class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.T.T<T0,T1,(class G2_C471`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.T.T<T0,T1,(class G2_C471`2<!!T0,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<!!T0,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.A.T<T1,(class G2_C471`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.A.T<T1,(class G2_C471`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.A.A<(class G2_C471`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.A.A<(class G2_C471`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.A.B<(class G2_C471`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.A.B<(class G2_C471`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.B.T<T1,(class G2_C471`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.B.T<T1,(class G2_C471`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.B.A<(class G2_C471`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.B.A<(class G2_C471`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G2_C471.B.B<(class G2_C471`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 17
.locals init (string[] actualResults)
ldc.i4.s 12
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G2_C471.B.B<(class G2_C471`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 12
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2300()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2301()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2302<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2303<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 8
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 9
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 10
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 11
ldarga.s 0
constrained. !!W
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.T.T<T0,T1,(class IBase2`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.T.T<T0,T1,(class IBase2`2<!!T0,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<!!T0,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.A.T<T1,(class IBase2`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.A.T<T1,(class IBase2`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<class BaseClass0,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.A.A<(class IBase2`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.A.A<(class IBase2`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.A.B<(class IBase2`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.A.B<(class IBase2`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.B.T<T1,(class IBase2`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.B.T<T1,(class IBase2`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<class BaseClass1,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.B.A<(class IBase2`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.B.A<(class IBase2`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase2.B.B<(class IBase2`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 6
.locals init (string[] actualResults)
ldc.i4.s 1
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase2.B.B<(class IBase2`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 1
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.T.T<T0,T1,(class G1_C9`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.T.T<T0,T1,(class G1_C9`2<!!T0,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<!!T0,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.A.T<T1,(class G1_C9`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.A.T<T1,(class G1_C9`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.A.A<(class G1_C9`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.A.A<(class G1_C9`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.A.B<(class G1_C9`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.A.B<(class G1_C9`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.B.T<T1,(class G1_C9`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.B.T<T1,(class G1_C9`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.B.A<(class G1_C9`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.B.A<(class G1_C9`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.G1_C9.B.B<(class G1_C9`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 13
.locals init (string[] actualResults)
ldc.i4.s 8
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.G1_C9.B.B<(class G1_C9`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 8
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1336()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1337()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 3
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 4
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 5
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 6
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method6<object>()
stelem.ref
ldloc.s actualResults
ldc.i4.s 7
ldarga.s 0
constrained. !!W
callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method7<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase1.T<T0,(class IBase1`1<!!T0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 8
.locals init (string[] actualResults)
ldc.i4.s 3
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase1.T<T0,(class IBase1`1<!!T0>)W>(!!W 'inst', string exp)"
ldc.i4.s 3
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<!!T0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<!!T0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<!!T0>::Method6<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase1.A<(class IBase1`1<class BaseClass0>)W>(!!W 'inst', string exp) cil managed {
.maxstack 8
.locals init (string[] actualResults)
ldc.i4.s 3
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase1.A<(class IBase1`1<class BaseClass0>)W>(!!W 'inst', string exp)"
ldc.i4.s 3
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method static void M.IBase1.B<(class IBase1`1<class BaseClass1>)W>(!!W 'inst', string exp) cil managed {
.maxstack 8
.locals init (string[] actualResults)
ldc.i4.s 3
newarr string
stloc.s actualResults
ldarg.1
ldstr "M.IBase1.B<(class IBase1`1<class BaseClass1>)W>(!!W 'inst', string exp)"
ldc.i4.s 3
ldloc.s actualResults
ldc.i4.s 0
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<class BaseClass1>::Method4()
stelem.ref
ldloc.s actualResults
ldc.i4.s 1
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<class BaseClass1>::Method5()
stelem.ref
ldloc.s actualResults
ldc.i4.s 2
ldarga.s 0
constrained. !!W
callvirt instance string class IBase1`1<class BaseClass1>::Method6<object>()
stelem.ref
ldloc.s actualResults
call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[])
ret
}
.method public hidebysig static void MethodCallingTest() cil managed
{
.maxstack 10
.locals init (object V_0)
ldstr "========================== Method Calling Test =========================="
call void [mscorlib]System.Console::WriteLine(string)
newobj instance void class G3_C1440`1<class BaseClass0>::.ctor()
stloc.0
ldloc.0
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2302<object>()
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2300()
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod4270<object>()
ldstr "G3_C1440::ClassMethod4270.16193<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod4269()
ldstr "G3_C1440::ClassMethod4269.16192()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod4268()
ldstr "G3_C1440::ClassMethod4268.16191()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::Method7<object>()
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2302<object>()
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod2300()
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass0>
callvirt instance string class G3_C1440`1<class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
newobj instance void class G3_C1440`1<class BaseClass1>::.ctor()
stloc.0
ldloc.0
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2302<object>()
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2300()
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod4270<object>()
ldstr "G3_C1440::ClassMethod4270.16193<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod4269()
ldstr "G3_C1440::ClassMethod4269.16192()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod4268()
ldstr "G3_C1440::ClassMethod4268.16191()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::Method7<object>()
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2302<object>()
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod2300()
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G3_C1440`1<class BaseClass1>
callvirt instance string class G3_C1440`1<class BaseClass1>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
newobj instance void class G2_C471`2<class BaseClass0,class BaseClass0>::.ctor()
stloc.0
ldloc.0
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2302<object>()
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2300()
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
newobj instance void class G2_C471`2<class BaseClass0,class BaseClass1>::.ctor()
stloc.0
ldloc.0
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2302<object>()
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2300()
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
newobj instance void class G2_C471`2<class BaseClass1,class BaseClass0>::.ctor()
stloc.0
ldloc.0
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2302<object>()
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2300()
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
newobj instance void class G2_C471`2<class BaseClass1,class BaseClass1>::.ctor()
stloc.0
ldloc.0
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method5()
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>()
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2303<object>()
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2302<object>()
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2301()
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2300()
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method6<object>()
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method5()
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method4()
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>()
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>()
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1337()
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
dup
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
callvirt instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1336()
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldloc.0
dup
callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
pop
ldstr "========================================================================\n\n"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method public hidebysig static void ConstrainedCallsTest() cil managed
{
.maxstack 10
.locals init (object V_0)
ldstr "========================== Constrained Calls Test =========================="
call void [mscorlib]System.Console::WriteLine(string)
newobj instance void class G3_C1440`1<class BaseClass0>::.ctor()
stloc.0
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.T.T<class BaseClass0,class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.T<class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.A<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.A<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.T<class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.A<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G3_C1440`1<class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass1,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.A.B<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.T.T<class BaseClass0,class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.A.T<class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.A.A<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.A<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G3_C1440`1<class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass1,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.B<class G3_C1440`1<class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G3_C1440::ClassMethod4268.16191()#G3_C1440::ClassMethod4269.16192()#G3_C1440::ClassMethod4270.16193<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.G3_C1440.T<class BaseClass0,class G3_C1440`1<class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G3_C1440::ClassMethod4268.16191()#G3_C1440::ClassMethod4269.16192()#G3_C1440::ClassMethod4270.16193<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.G3_C1440.A<class G3_C1440`1<class BaseClass0>>(!!0,string)
newobj instance void class G3_C1440`1<class BaseClass1>::.ctor()
stloc.0
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.T.T<class BaseClass0,class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.T<class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.A<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.A<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.T<class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.A<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G3_C1440`1<class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass1,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.A.B<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.T.T<class BaseClass1,class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.B.T<class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.B.A<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass0,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.A<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G3_C1440`1<class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass1,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.IBase2.B.B<class G3_C1440`1<class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G3_C1440::ClassMethod4268.16191()#G3_C1440::ClassMethod4269.16192()#G3_C1440::ClassMethod4270.16193<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.G3_C1440.T<class BaseClass1,class G3_C1440`1<class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G3_C1440::ClassMethod2300.MI.16194()#G2_C471::ClassMethod2301.9276()#G3_C1440::ClassMethod2302.MI.16195<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G3_C1440::ClassMethod4268.16191()#G3_C1440::ClassMethod4269.16192()#G3_C1440::ClassMethod4270.16193<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G3_C1440::Method7.16190<System.Object>()#"
call void Generated968::M.G3_C1440.B<class G3_C1440`1<class BaseClass1>>(!!0,string)
newobj instance void class G2_C471`2<class BaseClass0,class BaseClass0>::.ctor()
stloc.0
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.A<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.A<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.A<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.B<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.A.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.A.A<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.A<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.B<class G2_C471`2<class BaseClass0,class BaseClass0>>(!!0,string)
newobj instance void class G2_C471`2<class BaseClass0,class BaseClass1>::.ctor()
stloc.0
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.A<class G2_C471`2<class BaseClass0,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.A<class G2_C471`2<class BaseClass0,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.T<class BaseClass0,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.A<class G2_C471`2<class BaseClass0,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.B<class G2_C471`2<class BaseClass0,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.T.T<class BaseClass0,class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.A.T<class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.A.B<class G2_C471`2<class BaseClass0,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass1,class G2_C471`2<class BaseClass0,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.B<class G2_C471`2<class BaseClass0,class BaseClass1>>(!!0,string)
newobj instance void class G2_C471`2<class BaseClass1,class BaseClass0>::.ctor()
stloc.0
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.A<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.A<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.A<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.B<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.T.T<class BaseClass1,class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.B.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.B.A<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.A<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass0>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.B<class G2_C471`2<class BaseClass1,class BaseClass0>>(!!0,string)
newobj instance void class G2_C471`2<class BaseClass1,class BaseClass1>::.ctor()
stloc.0
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G1_C9::Method6.4838<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G1_C9.A.A<class G2_C471`2<class BaseClass1,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.A<class G2_C471`2<class BaseClass1,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.T<class BaseClass0,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method4.9270()#G2_C471::Method5.MI.9272()#G2_C471::Method6.MI.9274<System.Object>()#"
call void Generated968::M.IBase1.A<class G2_C471`2<class BaseClass1,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.T<class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.A.B<class G2_C471`2<class BaseClass1,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.T.T<class BaseClass1,class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.B.T<class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::ClassMethod1336.MI.9279()#G2_C471::ClassMethod1337.MI.9280()#G1_C9::ClassMethod1338.4842<System.Object>()#G1_C9::ClassMethod1339.4843<System.Object>()#G2_C471::ClassMethod2300.9275()#G2_C471::ClassMethod2301.9276()#G2_C471::ClassMethod2302.9277<System.Object>()#G2_C471::ClassMethod2303.9278<System.Object>()#G2_C471::Method4.9270()#G2_C471::Method5.9271()#G2_C471::Method6.9273<System.Object>()#G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.G2_C471.B.B<class G2_C471`2<class BaseClass1,class BaseClass1>>(!!0,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.T.T<class BaseClass1,class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!2,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.T<class BaseClass1,class G2_C471`2<class BaseClass1,class BaseClass1>>(!!1,string)
ldloc.0
ldstr "G2_C471::Method7.9269<System.Object>()#"
call void Generated968::M.IBase2.B.B<class G2_C471`2<class BaseClass1,class BaseClass1>>(!!0,string)
ldstr "========================================================================\n\n"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method public hidebysig static void StructConstrainedInterfaceCallsTest() cil managed
{
.maxstack 10
ldstr "===================== Struct Constrained Interface Calls Test ====================="
call void [mscorlib]System.Console::WriteLine(string)
ldstr "========================================================================\n\n"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method public hidebysig static void CalliTest() cil managed
{
.maxstack 10
.locals init (object V_0)
ldstr "========================== Method Calli Test =========================="
call void [mscorlib]System.Console::WriteLine(string)
newobj instance void class G3_C1440`1<class BaseClass0>::.ctor()
stloc.0
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2303<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2302<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2301()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2300()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod4270<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod4270.16193<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod4269()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod4269.16192()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod4268()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod4268.16191()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod2303<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod2302<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod2301()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod2300()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod1339<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod1338<object>()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod1337()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass0>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass0>::ClassMethod1336()
calli default string(class G3_C1440`1<class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G3_C1440`1<class BaseClass0> on type class G3_C1440`1<class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
newobj instance void class G3_C1440`1<class BaseClass1>::.ctor()
stloc.0
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2303<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2302<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2301()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2300()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method5()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method4()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1337()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1336()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod4270<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod4270.16193<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod4269()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod4269.16192()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod4268()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod4268.16191()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::Method7<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::Method7.16190<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod2303<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod2302<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod2302.MI.16195<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod2301()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod2300()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G3_C1440::ClassMethod2300.MI.16194()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::Method6<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::Method5()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::Method4()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod1339<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod1338<object>()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod1337()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G3_C1440`1<class BaseClass1>
ldloc.0
ldvirtftn instance string class G3_C1440`1<class BaseClass1>::ClassMethod1336()
calli default string(class G3_C1440`1<class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G3_C1440`1<class BaseClass1> on type class G3_C1440`1<class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
newobj instance void class G2_C471`2<class BaseClass0,class BaseClass0>::.ctor()
stloc.0
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2303<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2302<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2301()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod2300()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
newobj instance void class G2_C471`2<class BaseClass0,class BaseClass1>::.ctor()
stloc.0
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2303<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2302<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2301()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod2300()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method5()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method4()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass0,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass0,class BaseClass1>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass0,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass0,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
newobj instance void class G2_C471`2<class BaseClass1,class BaseClass0>::.ctor()
stloc.0
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2303<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2302<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2301()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod2300()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass0>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass0>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass0>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass0>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
newobj instance void class G2_C471`2<class BaseClass1,class BaseClass1>::.ctor()
stloc.0
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G1_C9::Method6.4838<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G1_C9`2<class BaseClass0,class BaseClass0>
ldloc.0
ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G1_C9`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method5.MI.9272()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method6.MI.9274<System.Object>()"
ldstr "class IBase1`1<class BaseClass0> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2303<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod2303.9278<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2302<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod2302.9277<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2301()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod2301.9276()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod2300()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod2300.9275()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method6<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method6.9273<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method5()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method5.9271()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method4()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method4.9270()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G1_C9::ClassMethod1339.4843<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G1_C9::ClassMethod1338.4842<System.Object>()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1337()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod1337.MI.9280()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
castclass class G2_C471`2<class BaseClass1,class BaseClass1>
ldloc.0
ldvirtftn instance string class G2_C471`2<class BaseClass1,class BaseClass1>::ClassMethod1336()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::ClassMethod1336.MI.9279()"
ldstr "class G2_C471`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldloc.0
ldloc.0
ldvirtftn instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>()
calli default string(class G2_C471`2<class BaseClass1,class BaseClass1>)
ldstr "G2_C471::Method7.9269<System.Object>()"
ldstr "class IBase2`2<class BaseClass1,class BaseClass1> on type class G2_C471`2<class BaseClass1,class BaseClass1>"
call void [TestFramework]TestFramework::MethodCallTest(string,string,string)
ldstr "========================================================================\n\n"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method public hidebysig static int32 Main() cil managed
{
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (
01 00 00 00
)
.entrypoint
.maxstack 10
call void Generated968::MethodCallingTest()
call void Generated968::ConstrainedCallsTest()
call void Generated968::StructConstrainedInterfaceCallsTest()
call void Generated968::CalliTest()
ldc.i4 100
ret
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/JIT/Regression/JitBlue/GitHub_16472/Github_16472.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.CompilerServices;
class Program
{
static int Main()
{
int expected = BitConverter.IsLittleEndian ? 0x78563412 : 0x12345678;
int actual = Test();
return actual == expected ? 100 : 1;
}
struct Bytes
{
public byte b1, b2, b3, b4;
public Bytes(int dummy)
{
b1 = 0x12;
b2 = 0x34;
b3 = 0x56;
b4 = 0x78;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
static int Test()
{
Bytes s = new Bytes(42);
return Unsafe.As<byte, int>(ref s.b1);
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.CompilerServices;
class Program
{
static int Main()
{
int expected = BitConverter.IsLittleEndian ? 0x78563412 : 0x12345678;
int actual = Test();
return actual == expected ? 100 : 1;
}
struct Bytes
{
public byte b1, b2, b3, b4;
public Bytes(int dummy)
{
b1 = 0x12;
b2 = 0x34;
b3 = 0x56;
b4 = 0x78;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
static int Test()
{
Bytes s = new Bytes(42);
return Unsafe.As<byte, int>(ref s.b1);
}
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/inc/pedecoder.inl | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// --------------------------------------------------------------------------------
// PEDecoder.inl
//
// --------------------------------------------------------------------------------
#ifndef _PEDECODER_INL_
#define _PEDECODER_INL_
#include "pedecoder.h"
#include "ex.h"
#ifndef DACCESS_COMPILE
inline PEDecoder::PEDecoder()
: m_base(0),
m_size(0),
m_flags(0),
m_pNTHeaders(nullptr),
m_pCorHeader(nullptr),
m_pReadyToRunHeader(nullptr)
{
CONTRACTL
{
CONSTRUCTOR_CHECK;
NOTHROW;
CANNOT_TAKE_LOCK;
GC_NOTRIGGER;
}
CONTRACTL_END;
}
#else
inline PEDecoder::PEDecoder()
{
LIMITED_METHOD_CONTRACT;
}
#endif // #ifndef DACCESS_COMPILE
inline PTR_VOID PEDecoder::GetBase() const
{
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC;
return PTR_VOID(m_base);
}
inline BOOL PEDecoder::IsMapped() const
{
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC;
return (m_flags & FLAG_MAPPED) != 0;
}
inline BOOL PEDecoder::IsRelocated() const
{
LIMITED_METHOD_CONTRACT;
return (m_flags & FLAG_RELOCATED) != 0;
}
inline void PEDecoder::SetRelocated()
{
m_flags |= FLAG_RELOCATED;
}
inline BOOL PEDecoder::IsFlat() const
{
LIMITED_METHOD_CONTRACT;
return HasContents() && !IsMapped();
}
inline BOOL PEDecoder::HasContents() const
{
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC;
return (m_flags & FLAG_CONTENTS) != 0;
}
inline COUNT_T PEDecoder::GetSize() const
{
LIMITED_METHOD_DAC_CONTRACT;
return m_size;
}
inline PEDecoder::PEDecoder(PTR_VOID mappedBase, bool fixedUp /*= FALSE*/)
: m_base(dac_cast<TADDR>(mappedBase)),
m_size(0),
m_flags(FLAG_MAPPED | FLAG_CONTENTS | FLAG_NT_CHECKED | (fixedUp ? FLAG_RELOCATED : 0)),
m_pNTHeaders(nullptr),
m_pCorHeader(nullptr),
m_pReadyToRunHeader(nullptr)
{
CONTRACTL
{
CONSTRUCTOR_CHECK;
PRECONDITION(CheckPointer(mappedBase));
PRECONDITION(PEDecoder(mappedBase,fixedUp).CheckNTHeaders());
THROWS;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
// Temporarily set the size to 2 pages, so we can get the headers.
m_size = GetOsPageSize()*2;
m_pNTHeaders = PTR_IMAGE_NT_HEADERS(FindNTHeaders());
if (!m_pNTHeaders)
ThrowHR(COR_E_BADIMAGEFORMAT);
m_size = VAL32(m_pNTHeaders->OptionalHeader.SizeOfImage);
}
#ifndef DACCESS_COMPILE
//REM
//what's the right way to do this?
//we want to use some against TADDR, but also want to do
//some against what's just in the current process.
//m_base is a TADDR in DAC all the time, though.
//Have to implement separate fn to do the lookup??
inline PEDecoder::PEDecoder(void *flatBase, COUNT_T size)
: m_base((TADDR)flatBase),
m_size(size),
m_flags(FLAG_CONTENTS),
m_pNTHeaders(NULL),
m_pCorHeader(NULL),
m_pReadyToRunHeader(NULL)
{
CONTRACTL
{
CONSTRUCTOR_CHECK;
PRECONDITION(CheckPointer(flatBase));
NOTHROW;
GC_NOTRIGGER;
CANNOT_TAKE_LOCK;
}
CONTRACTL_END;
}
inline void PEDecoder::Init(void *flatBase, COUNT_T size)
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION((size == 0) || CheckPointer(flatBase));
PRECONDITION(!HasContents());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
m_base = (TADDR)flatBase;
m_size = size;
m_flags = FLAG_CONTENTS;
}
inline HRESULT PEDecoder::Init(void *mappedBase, bool fixedUp /*= FALSE*/)
{
CONTRACTL
{
INSTANCE_CHECK;
NOTHROW;
GC_NOTRIGGER;
PRECONDITION(CheckPointer(mappedBase));
PRECONDITION(!HasContents());
}
CONTRACTL_END;
m_base = (TADDR)mappedBase;
m_flags = FLAG_MAPPED | FLAG_CONTENTS;
if (fixedUp)
m_flags |= FLAG_RELOCATED;
// Temporarily set the size to 2 pages, so we can get the headers.
m_size = GetOsPageSize()*2;
m_pNTHeaders = FindNTHeaders();
if (!m_pNTHeaders)
return COR_E_BADIMAGEFORMAT;
m_size = VAL32(m_pNTHeaders->OptionalHeader.SizeOfImage);
return S_OK;
}
inline void PEDecoder::Reset()
{
CONTRACTL
{
INSTANCE_CHECK;
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
m_base=NULL;
m_flags=NULL;
m_size=NULL;
m_pNTHeaders=NULL;
m_pCorHeader=NULL;
m_pReadyToRunHeader=NULL;
}
#endif // #ifndef DACCESS_COMPILE
inline IMAGE_NT_HEADERS32 *PEDecoder::GetNTHeaders32() const
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
return dac_cast<PTR_IMAGE_NT_HEADERS32>(FindNTHeaders());
}
inline IMAGE_NT_HEADERS64 *PEDecoder::GetNTHeaders64() const
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
return dac_cast<PTR_IMAGE_NT_HEADERS64>(FindNTHeaders());
}
inline BOOL PEDecoder::Has32BitNTHeaders() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(HasNTHeaders());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACTL_END;
return (FindNTHeaders()->OptionalHeader.Magic == VAL16(IMAGE_NT_OPTIONAL_HDR32_MAGIC));
}
inline const void *PEDecoder::GetHeaders(COUNT_T *pSize) const
{
CONTRACT(const void *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
if (pSize != NULL)
*pSize = VAL32(FindNTHeaders()->OptionalHeader.SizeOfHeaders);
RETURN (const void *) m_base;
}
inline BOOL PEDecoder::IsDll() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
return ((FindNTHeaders()->FileHeader.Characteristics & VAL16(IMAGE_FILE_DLL)) != 0);
}
inline BOOL PEDecoder::HasBaseRelocations() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
return ((FindNTHeaders()->FileHeader.Characteristics & VAL16(IMAGE_FILE_RELOCS_STRIPPED)) == 0);
}
inline const void *PEDecoder::GetPreferredBase() const
{
CONTRACT(const void *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL, NULL_OK));
}
CONTRACT_END;
if (Has32BitNTHeaders())
RETURN (const void *) (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.ImageBase);
else
RETURN (const void *) (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.ImageBase);
}
inline COUNT_T PEDecoder::GetVirtualSize() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
return VAL32(FindNTHeaders()->OptionalHeader.SizeOfImage);
}
inline WORD PEDecoder::GetSubsystem() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
return VAL16(FindNTHeaders()->OptionalHeader.Subsystem);
}
inline WORD PEDecoder::GetDllCharacteristics() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
return VAL16(FindNTHeaders()->OptionalHeader.DllCharacteristics);
}
inline DWORD PEDecoder::GetTimeDateStamp() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
return VAL32(FindNTHeaders()->FileHeader.TimeDateStamp);
}
inline DWORD PEDecoder::GetCheckSum() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
return VAL32(FindNTHeaders()->OptionalHeader.CheckSum);
}
inline DWORD PEDecoder::GetFileAlignment() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
return VAL32(FindNTHeaders()->OptionalHeader.FileAlignment);
}
inline DWORD PEDecoder::GetSectionAlignment() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
return VAL32(FindNTHeaders()->OptionalHeader.SectionAlignment);
}
inline WORD PEDecoder::GetMachine() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
return VAL16(FindNTHeaders()->FileHeader.Machine);
}
inline WORD PEDecoder::GetCharacteristics() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
return VAL16(FindNTHeaders()->FileHeader.Characteristics);
}
inline SIZE_T PEDecoder::GetSizeOfStackReserve() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfStackReserve);
else
return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfStackReserve);
}
inline SIZE_T PEDecoder::GetSizeOfStackCommit() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfStackCommit);
else
return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfStackCommit);
}
inline SIZE_T PEDecoder::GetSizeOfHeapReserve() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfHeapReserve);
else
return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfHeapReserve);
}
inline SIZE_T PEDecoder::GetSizeOfHeapCommit() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfHeapCommit);
else
return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfHeapCommit);
}
inline UINT32 PEDecoder::GetLoaderFlags() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return VAL32(GetNTHeaders32()->OptionalHeader.LoaderFlags);
else
return VAL32(GetNTHeaders64()->OptionalHeader.LoaderFlags);
}
inline UINT32 PEDecoder::GetWin32VersionValue() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return VAL32(GetNTHeaders32()->OptionalHeader.Win32VersionValue);
else
return VAL32(GetNTHeaders64()->OptionalHeader.Win32VersionValue);
}
inline COUNT_T PEDecoder::GetNumberOfRvaAndSizes() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return VAL32(GetNTHeaders32()->OptionalHeader.NumberOfRvaAndSizes);
else
return VAL32(GetNTHeaders64()->OptionalHeader.NumberOfRvaAndSizes);
}
inline BOOL PEDecoder::HasDirectoryEntry(int entry) const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return (GetNTHeaders32()->OptionalHeader.DataDirectory[entry].VirtualAddress != 0);
else
return (GetNTHeaders64()->OptionalHeader.DataDirectory[entry].VirtualAddress != 0);
}
inline IMAGE_DATA_DIRECTORY *PEDecoder::GetDirectoryEntry(int entry) const
{
CONTRACT(IMAGE_DATA_DIRECTORY *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACT_END;
if (Has32BitNTHeaders())
RETURN dac_cast<PTR_IMAGE_DATA_DIRECTORY>(
dac_cast<TADDR>(GetNTHeaders32()) +
offsetof(IMAGE_NT_HEADERS32, OptionalHeader.DataDirectory) +
entry * sizeof(IMAGE_DATA_DIRECTORY));
else
RETURN dac_cast<PTR_IMAGE_DATA_DIRECTORY>(
dac_cast<TADDR>(GetNTHeaders64()) +
offsetof(IMAGE_NT_HEADERS64, OptionalHeader.DataDirectory) +
entry * sizeof(IMAGE_DATA_DIRECTORY));
}
inline TADDR PEDecoder::GetDirectoryEntryData(int entry, COUNT_T *pSize) const
{
CONTRACT(TADDR)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(CheckDirectoryEntry(entry, 0, NULL_OK));
PRECONDITION(CheckPointer(pSize, NULL_OK));
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer((void *)RETVAL, NULL_OK));
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACT_END;
IMAGE_DATA_DIRECTORY *pDir = GetDirectoryEntry(entry);
if (pSize != NULL)
*pSize = VAL32(pDir->Size);
RETURN GetDirectoryData(pDir);
}
inline TADDR PEDecoder::GetDirectoryData(IMAGE_DATA_DIRECTORY *pDir) const
{
CONTRACT(TADDR)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(CheckDirectory(pDir, 0, NULL_OK));
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
POSTCONDITION(CheckPointer((void *)RETVAL, NULL_OK));
CANNOT_TAKE_LOCK;
}
CONTRACT_END;
RETURN GetRvaData(VAL32(pDir->VirtualAddress));
}
inline TADDR PEDecoder::GetDirectoryData(IMAGE_DATA_DIRECTORY *pDir, COUNT_T *pSize) const
{
CONTRACT(TADDR)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(CheckDirectory(pDir, 0, NULL_OK));
PRECONDITION(CheckPointer(pSize));
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
POSTCONDITION(CheckPointer((void *)RETVAL, NULL_OK));
CANNOT_TAKE_LOCK;
}
CONTRACT_END;
*pSize = VAL32(pDir->Size);
RETURN GetRvaData(VAL32(pDir->VirtualAddress));
}
inline TADDR PEDecoder::GetInternalAddressData(SIZE_T address) const
{
CONTRACT(TADDR)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(CheckInternalAddress(address, NULL_OK));
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer((void *)RETVAL));
}
CONTRACT_END;
RETURN GetRvaData(InternalAddressToRva(address));
}
inline BOOL PEDecoder::HasCorHeader() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
SUPPORTS_DAC;
GC_NOTRIGGER;
}
CONTRACTL_END;
return HasDirectoryEntry(IMAGE_DIRECTORY_ENTRY_COMHEADER);
}
inline BOOL PEDecoder::IsILOnly() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(HasCorHeader());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
// Pretend that ready-to-run images are IL-only
return((GetCorHeader()->Flags & VAL32(COMIMAGE_FLAGS_ILONLY)) != 0) || HasReadyToRunHeader();
}
inline COUNT_T PEDecoder::RvaToOffset(RVA rva) const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(CheckRva(rva,NULL_OK));
NOTHROW;
CANNOT_TAKE_LOCK;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
if(rva > 0)
{
IMAGE_SECTION_HEADER *section = RvaToSection(rva);
if (section == NULL)
return rva;
return rva - VAL32(section->VirtualAddress) + VAL32(section->PointerToRawData);
}
else return 0;
}
inline RVA PEDecoder::OffsetToRva(COUNT_T fileOffset) const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(CheckOffset(fileOffset,NULL_OK));
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
if(fileOffset > 0)
{
IMAGE_SECTION_HEADER *section = OffsetToSection(fileOffset);
PREFIX_ASSUME (section!=NULL); //TODO: actually it is possible that it si null we need to rethink how we handle this cases and do better there
return fileOffset - VAL32(section->PointerToRawData) + VAL32(section->VirtualAddress);
}
else return 0;
}
inline BOOL PEDecoder::IsStrongNameSigned() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(HasCorHeader());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
return ((GetCorHeader()->Flags & VAL32(COMIMAGE_FLAGS_STRONGNAMESIGNED)) != 0);
}
inline BOOL PEDecoder::HasStrongNameSignature() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(HasCorHeader());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
return (GetCorHeader()->StrongNameSignature.VirtualAddress != 0);
}
inline CHECK PEDecoder::CheckStrongNameSignature() const
{
CONTRACT_CHECK
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(HasCorHeader());
PRECONDITION(HasStrongNameSignature());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACT_CHECK_END;
return CheckDirectory(&GetCorHeader()->StrongNameSignature, IMAGE_SCN_MEM_WRITE, NULL_OK);
}
inline PTR_CVOID PEDecoder::GetStrongNameSignature(COUNT_T *pSize) const
{
CONTRACT(PTR_CVOID)
{
INSTANCE_CHECK;
PRECONDITION(HasCorHeader());
PRECONDITION(HasStrongNameSignature());
PRECONDITION(CheckStrongNameSignature());
PRECONDITION(CheckPointer(pSize, NULL_OK));
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
IMAGE_DATA_DIRECTORY *pDir = &GetCorHeader()->StrongNameSignature;
if (pSize != NULL)
*pSize = VAL32(pDir->Size);
RETURN dac_cast<PTR_CVOID>(GetDirectoryData(pDir));
}
inline BOOL PEDecoder::HasTls() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
return HasDirectoryEntry(IMAGE_DIRECTORY_ENTRY_TLS);
}
inline CHECK PEDecoder::CheckTls() const
{
CONTRACT_CHECK
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACT_CHECK_END;
CHECK(CheckDirectoryEntry(IMAGE_DIRECTORY_ENTRY_TLS, 0, NULL_OK));
IMAGE_TLS_DIRECTORY *pTlsHeader = (IMAGE_TLS_DIRECTORY *) GetDirectoryEntryData(IMAGE_DIRECTORY_ENTRY_TLS);
CHECK(CheckUnderflow(VALPTR(pTlsHeader->EndAddressOfRawData), VALPTR(pTlsHeader->StartAddressOfRawData)));
CHECK(VALPTR(pTlsHeader->EndAddressOfRawData) - VALPTR(pTlsHeader->StartAddressOfRawData) <= COUNT_T_MAX);
CHECK(CheckInternalAddress(VALPTR(pTlsHeader->StartAddressOfRawData),
(COUNT_T) (VALPTR(pTlsHeader->EndAddressOfRawData) - VALPTR(pTlsHeader->StartAddressOfRawData))));
CHECK_OK;
}
inline PTR_VOID PEDecoder::GetTlsRange(COUNT_T * pSize) const
{
CONTRACT(void *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(HasTls());
PRECONDITION(CheckTls());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
IMAGE_TLS_DIRECTORY *pTlsHeader =
PTR_IMAGE_TLS_DIRECTORY(GetDirectoryEntryData(IMAGE_DIRECTORY_ENTRY_TLS));
if (pSize != 0)
*pSize = (COUNT_T) (VALPTR(pTlsHeader->EndAddressOfRawData) - VALPTR(pTlsHeader->StartAddressOfRawData));
PREFIX_ASSUME (pTlsHeader!=NULL);
RETURN PTR_VOID(GetInternalAddressData(pTlsHeader->StartAddressOfRawData));
}
inline UINT32 PEDecoder::GetTlsIndex() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(HasTls());
PRECONDITION(CheckTls());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
IMAGE_TLS_DIRECTORY *pTlsHeader = (IMAGE_TLS_DIRECTORY *) GetDirectoryEntryData(IMAGE_DIRECTORY_ENTRY_TLS);
return (UINT32)*PTR_UINT32(GetInternalAddressData((SIZE_T)VALPTR(pTlsHeader->AddressOfIndex)));
}
inline IMAGE_COR20_HEADER *PEDecoder::GetCorHeader() const
{
CONTRACT(IMAGE_COR20_HEADER *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(HasCorHeader());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACT_END;
if (m_pCorHeader == NULL)
const_cast<PEDecoder *>(this)->m_pCorHeader =
dac_cast<PTR_IMAGE_COR20_HEADER>(FindCorHeader());
RETURN m_pCorHeader;
}
inline BOOL PEDecoder::IsNativeMachineFormat() const
{
if (!HasContents() || !HasNTHeaders() )
return FALSE;
_ASSERTE(m_pNTHeaders);
WORD expectedFormat = HasCorHeader() && HasReadyToRunHeader() ?
IMAGE_FILE_MACHINE_NATIVE_NI :
IMAGE_FILE_MACHINE_NATIVE;
//do not call GetNTHeaders as we do not want to bother with PE32->PE32+ conversion
return m_pNTHeaders->FileHeader.Machine==expectedFormat;
}
inline BOOL PEDecoder::IsI386() const
{
if (!HasContents() || !HasNTHeaders() )
return FALSE;
_ASSERTE(m_pNTHeaders);
//do not call GetNTHeaders as we do not want to bother with PE32->PE32+ conversion
return m_pNTHeaders->FileHeader.Machine==IMAGE_FILE_MACHINE_I386;
}
// static
inline PTR_IMAGE_SECTION_HEADER PEDecoder::FindFirstSection(IMAGE_NT_HEADERS * pNTHeaders)
{
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC;
return dac_cast<PTR_IMAGE_SECTION_HEADER>(
dac_cast<TADDR>(pNTHeaders) +
FIELD_OFFSET(IMAGE_NT_HEADERS, OptionalHeader) +
VAL16(pNTHeaders->FileHeader.SizeOfOptionalHeader));
}
inline COUNT_T PEDecoder::GetNumberOfSections() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
return VAL16(FindNTHeaders()->FileHeader.NumberOfSections);
}
inline DWORD PEDecoder::GetImageIdentity() const
{
WRAPPER_NO_CONTRACT;
return GetTimeDateStamp() ^ GetCheckSum() ^ DWORD( GetVirtualSize() );
}
inline PTR_IMAGE_SECTION_HEADER PEDecoder::FindFirstSection() const
{
CONTRACT(IMAGE_SECTION_HEADER *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
SUPPORTS_DAC;
}
CONTRACT_END;
RETURN FindFirstSection(FindNTHeaders());
}
inline IMAGE_NT_HEADERS *PEDecoder::FindNTHeaders() const
{
CONTRACT(IMAGE_NT_HEADERS *)
{
INSTANCE_CHECK;
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACT_END;
RETURN PTR_IMAGE_NT_HEADERS(m_base + VAL32(PTR_IMAGE_DOS_HEADER(m_base)->e_lfanew));
}
inline IMAGE_COR20_HEADER *PEDecoder::FindCorHeader() const
{
CONTRACT(IMAGE_COR20_HEADER *)
{
INSTANCE_CHECK;
PRECONDITION(HasCorHeader());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACT_END;
const IMAGE_COR20_HEADER * pCor=PTR_IMAGE_COR20_HEADER(GetDirectoryEntryData(IMAGE_DIRECTORY_ENTRY_COMHEADER));
RETURN ((IMAGE_COR20_HEADER*)pCor);
}
inline CHECK PEDecoder::CheckBounds(RVA rangeBase, COUNT_T rangeSize, RVA rva)
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
CHECK(CheckOverflow(rangeBase, rangeSize));
CHECK(rva >= rangeBase);
CHECK(rva <= rangeBase + rangeSize);
CHECK_OK;
}
inline CHECK PEDecoder::CheckBounds(RVA rangeBase, COUNT_T rangeSize, RVA rva, COUNT_T size)
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
CHECK(CheckOverflow(rangeBase, rangeSize));
CHECK(CheckOverflow(rva, size));
CHECK(rva >= rangeBase);
CHECK(rva + size <= rangeBase + rangeSize);
CHECK_OK;
}
inline CHECK PEDecoder::CheckBounds(const void *rangeBase, COUNT_T rangeSize, const void *pointer)
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
CHECK(CheckOverflow(dac_cast<PTR_CVOID>(rangeBase), rangeSize));
CHECK(dac_cast<TADDR>(pointer) >= dac_cast<TADDR>(rangeBase));
CHECK(dac_cast<TADDR>(pointer) <= dac_cast<TADDR>(rangeBase) + rangeSize);
CHECK_OK;
}
inline CHECK PEDecoder::CheckBounds(PTR_CVOID rangeBase, COUNT_T rangeSize, PTR_CVOID pointer, COUNT_T size)
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
CHECK(CheckOverflow(rangeBase, rangeSize));
CHECK(CheckOverflow(pointer, size));
CHECK(dac_cast<TADDR>(pointer) >= dac_cast<TADDR>(rangeBase));
CHECK(dac_cast<TADDR>(pointer) + size <= dac_cast<TADDR>(rangeBase) + rangeSize);
CHECK_OK;
}
inline void PEDecoder::GetPEKindAndMachine(DWORD * pdwPEKind, DWORD *pdwMachine)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
DWORD dwKind=0,dwMachine=0;
if(HasContents() && HasNTHeaders())
{
dwMachine = GetMachine();
BOOL fIsPE32Plus = !Has32BitNTHeaders();
if (fIsPE32Plus)
dwKind |= (DWORD)pe32Plus;
if (HasCorHeader())
{
IMAGE_COR20_HEADER * pCorHdr = GetCorHeader();
if(pCorHdr != NULL)
{
DWORD dwCorFlags = pCorHdr->Flags;
if (dwCorFlags & VAL32(COMIMAGE_FLAGS_ILONLY))
{
dwKind |= (DWORD)peILonly;
#ifdef HOST_64BIT
// compensate for shim promotion of PE32/ILONLY headers to PE32+ on WIN64
if (fIsPE32Plus && (GetMachine() == IMAGE_FILE_MACHINE_I386))
dwKind &= ~((DWORD)pe32Plus);
#endif
}
if (COR_IS_32BIT_REQUIRED(dwCorFlags))
dwKind |= (DWORD)pe32BitRequired;
else if (COR_IS_32BIT_PREFERRED(dwCorFlags))
dwKind |= (DWORD)pe32BitPreferred;
// compensate for MC++ peculiarity
if(dwKind == 0)
dwKind = (DWORD)pe32BitRequired;
}
else
{
dwKind |= (DWORD)pe32Unmanaged;
}
if (HasReadyToRunHeader())
{
if (dwMachine == IMAGE_FILE_MACHINE_NATIVE_NI)
{
// Supply the original machine type to the assembly binder
dwMachine = IMAGE_FILE_MACHINE_NATIVE;
}
if ((GetReadyToRunHeader()->CoreHeader.Flags & READYTORUN_FLAG_PLATFORM_NEUTRAL_SOURCE) != 0)
{
// Supply the original PEKind/Machine to the assembly binder to make the full assembly name look like the original
dwKind = peILonly;
dwMachine = IMAGE_FILE_MACHINE_I386;
}
}
}
else
{
dwKind |= (DWORD)pe32Unmanaged;
}
}
*pdwPEKind = dwKind;
*pdwMachine = dwMachine;
}
inline BOOL PEDecoder::IsPlatformNeutral()
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
DWORD dwKind, dwMachine;
GetPEKindAndMachine(&dwKind, &dwMachine);
return ((dwKind & (peILonly | pe32Plus | pe32BitRequired)) == peILonly) && (dwMachine == IMAGE_FILE_MACHINE_I386);
}
inline BOOL PEDecoder::IsComponentAssembly() const
{
CONTRACTL
{
INSTANCE_CHECK;
NOTHROW;
GC_NOTRIGGER;
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACTL_END;
return HasReadyToRunHeader() && (m_pReadyToRunHeader->CoreHeader.Flags & READYTORUN_FLAG_COMPONENT) != 0;
}
inline BOOL PEDecoder::HasReadyToRunHeader() const
{
CONTRACTL
{
INSTANCE_CHECK;
NOTHROW;
GC_NOTRIGGER;
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACTL_END;
if (m_flags & FLAG_HAS_NO_READYTORUN_HEADER)
return FALSE;
if (m_pReadyToRunHeader != NULL)
return TRUE;
return FindReadyToRunHeader() != NULL;
}
inline READYTORUN_HEADER * PEDecoder::GetReadyToRunHeader() const
{
CONTRACT(READYTORUN_HEADER *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(HasCorHeader());
PRECONDITION(HasReadyToRunHeader());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
SUPPORTS_DAC;
CANNOT_TAKE_LOCK;
}
CONTRACT_END;
if (m_pReadyToRunHeader != NULL)
RETURN m_pReadyToRunHeader;
RETURN FindReadyToRunHeader();
}
#endif // _PEDECODER_INL_
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// --------------------------------------------------------------------------------
// PEDecoder.inl
//
// --------------------------------------------------------------------------------
#ifndef _PEDECODER_INL_
#define _PEDECODER_INL_
#include "pedecoder.h"
#include "ex.h"
#ifndef DACCESS_COMPILE
inline PEDecoder::PEDecoder()
: m_base(0),
m_size(0),
m_flags(0),
m_pNTHeaders(nullptr),
m_pCorHeader(nullptr),
m_pReadyToRunHeader(nullptr)
{
CONTRACTL
{
CONSTRUCTOR_CHECK;
NOTHROW;
CANNOT_TAKE_LOCK;
GC_NOTRIGGER;
}
CONTRACTL_END;
}
#else
inline PEDecoder::PEDecoder()
{
LIMITED_METHOD_CONTRACT;
}
#endif // #ifndef DACCESS_COMPILE
inline PTR_VOID PEDecoder::GetBase() const
{
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC;
return PTR_VOID(m_base);
}
inline BOOL PEDecoder::IsMapped() const
{
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC;
return (m_flags & FLAG_MAPPED) != 0;
}
inline BOOL PEDecoder::IsRelocated() const
{
LIMITED_METHOD_CONTRACT;
return (m_flags & FLAG_RELOCATED) != 0;
}
inline void PEDecoder::SetRelocated()
{
m_flags |= FLAG_RELOCATED;
}
inline BOOL PEDecoder::IsFlat() const
{
LIMITED_METHOD_CONTRACT;
return HasContents() && !IsMapped();
}
inline BOOL PEDecoder::HasContents() const
{
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC;
return (m_flags & FLAG_CONTENTS) != 0;
}
inline COUNT_T PEDecoder::GetSize() const
{
LIMITED_METHOD_DAC_CONTRACT;
return m_size;
}
inline PEDecoder::PEDecoder(PTR_VOID mappedBase, bool fixedUp /*= FALSE*/)
: m_base(dac_cast<TADDR>(mappedBase)),
m_size(0),
m_flags(FLAG_MAPPED | FLAG_CONTENTS | FLAG_NT_CHECKED | (fixedUp ? FLAG_RELOCATED : 0)),
m_pNTHeaders(nullptr),
m_pCorHeader(nullptr),
m_pReadyToRunHeader(nullptr)
{
CONTRACTL
{
CONSTRUCTOR_CHECK;
PRECONDITION(CheckPointer(mappedBase));
PRECONDITION(PEDecoder(mappedBase,fixedUp).CheckNTHeaders());
THROWS;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
// Temporarily set the size to 2 pages, so we can get the headers.
m_size = GetOsPageSize()*2;
m_pNTHeaders = PTR_IMAGE_NT_HEADERS(FindNTHeaders());
if (!m_pNTHeaders)
ThrowHR(COR_E_BADIMAGEFORMAT);
m_size = VAL32(m_pNTHeaders->OptionalHeader.SizeOfImage);
}
#ifndef DACCESS_COMPILE
//REM
//what's the right way to do this?
//we want to use some against TADDR, but also want to do
//some against what's just in the current process.
//m_base is a TADDR in DAC all the time, though.
//Have to implement separate fn to do the lookup??
inline PEDecoder::PEDecoder(void *flatBase, COUNT_T size)
: m_base((TADDR)flatBase),
m_size(size),
m_flags(FLAG_CONTENTS),
m_pNTHeaders(NULL),
m_pCorHeader(NULL),
m_pReadyToRunHeader(NULL)
{
CONTRACTL
{
CONSTRUCTOR_CHECK;
PRECONDITION(CheckPointer(flatBase));
NOTHROW;
GC_NOTRIGGER;
CANNOT_TAKE_LOCK;
}
CONTRACTL_END;
}
inline void PEDecoder::Init(void *flatBase, COUNT_T size)
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION((size == 0) || CheckPointer(flatBase));
PRECONDITION(!HasContents());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
m_base = (TADDR)flatBase;
m_size = size;
m_flags = FLAG_CONTENTS;
}
inline HRESULT PEDecoder::Init(void *mappedBase, bool fixedUp /*= FALSE*/)
{
CONTRACTL
{
INSTANCE_CHECK;
NOTHROW;
GC_NOTRIGGER;
PRECONDITION(CheckPointer(mappedBase));
PRECONDITION(!HasContents());
}
CONTRACTL_END;
m_base = (TADDR)mappedBase;
m_flags = FLAG_MAPPED | FLAG_CONTENTS;
if (fixedUp)
m_flags |= FLAG_RELOCATED;
// Temporarily set the size to 2 pages, so we can get the headers.
m_size = GetOsPageSize()*2;
m_pNTHeaders = FindNTHeaders();
if (!m_pNTHeaders)
return COR_E_BADIMAGEFORMAT;
m_size = VAL32(m_pNTHeaders->OptionalHeader.SizeOfImage);
return S_OK;
}
inline void PEDecoder::Reset()
{
CONTRACTL
{
INSTANCE_CHECK;
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
m_base=NULL;
m_flags=NULL;
m_size=NULL;
m_pNTHeaders=NULL;
m_pCorHeader=NULL;
m_pReadyToRunHeader=NULL;
}
#endif // #ifndef DACCESS_COMPILE
inline IMAGE_NT_HEADERS32 *PEDecoder::GetNTHeaders32() const
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
return dac_cast<PTR_IMAGE_NT_HEADERS32>(FindNTHeaders());
}
inline IMAGE_NT_HEADERS64 *PEDecoder::GetNTHeaders64() const
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
return dac_cast<PTR_IMAGE_NT_HEADERS64>(FindNTHeaders());
}
inline BOOL PEDecoder::Has32BitNTHeaders() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(HasNTHeaders());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACTL_END;
return (FindNTHeaders()->OptionalHeader.Magic == VAL16(IMAGE_NT_OPTIONAL_HDR32_MAGIC));
}
inline const void *PEDecoder::GetHeaders(COUNT_T *pSize) const
{
CONTRACT(const void *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
if (pSize != NULL)
*pSize = VAL32(FindNTHeaders()->OptionalHeader.SizeOfHeaders);
RETURN (const void *) m_base;
}
inline BOOL PEDecoder::IsDll() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
return ((FindNTHeaders()->FileHeader.Characteristics & VAL16(IMAGE_FILE_DLL)) != 0);
}
inline BOOL PEDecoder::HasBaseRelocations() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
return ((FindNTHeaders()->FileHeader.Characteristics & VAL16(IMAGE_FILE_RELOCS_STRIPPED)) == 0);
}
inline const void *PEDecoder::GetPreferredBase() const
{
CONTRACT(const void *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL, NULL_OK));
}
CONTRACT_END;
if (Has32BitNTHeaders())
RETURN (const void *) (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.ImageBase);
else
RETURN (const void *) (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.ImageBase);
}
inline COUNT_T PEDecoder::GetVirtualSize() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
return VAL32(FindNTHeaders()->OptionalHeader.SizeOfImage);
}
inline WORD PEDecoder::GetSubsystem() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
return VAL16(FindNTHeaders()->OptionalHeader.Subsystem);
}
inline WORD PEDecoder::GetDllCharacteristics() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
return VAL16(FindNTHeaders()->OptionalHeader.DllCharacteristics);
}
inline DWORD PEDecoder::GetTimeDateStamp() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
return VAL32(FindNTHeaders()->FileHeader.TimeDateStamp);
}
inline DWORD PEDecoder::GetCheckSum() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
return VAL32(FindNTHeaders()->OptionalHeader.CheckSum);
}
inline DWORD PEDecoder::GetFileAlignment() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
return VAL32(FindNTHeaders()->OptionalHeader.FileAlignment);
}
inline DWORD PEDecoder::GetSectionAlignment() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
//even though some data in OptionalHeader is different for 32 and 64, this field is the same
return VAL32(FindNTHeaders()->OptionalHeader.SectionAlignment);
}
inline WORD PEDecoder::GetMachine() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
return VAL16(FindNTHeaders()->FileHeader.Machine);
}
inline WORD PEDecoder::GetCharacteristics() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
return VAL16(FindNTHeaders()->FileHeader.Characteristics);
}
inline SIZE_T PEDecoder::GetSizeOfStackReserve() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfStackReserve);
else
return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfStackReserve);
}
inline SIZE_T PEDecoder::GetSizeOfStackCommit() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfStackCommit);
else
return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfStackCommit);
}
inline SIZE_T PEDecoder::GetSizeOfHeapReserve() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfHeapReserve);
else
return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfHeapReserve);
}
inline SIZE_T PEDecoder::GetSizeOfHeapCommit() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfHeapCommit);
else
return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfHeapCommit);
}
inline UINT32 PEDecoder::GetLoaderFlags() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return VAL32(GetNTHeaders32()->OptionalHeader.LoaderFlags);
else
return VAL32(GetNTHeaders64()->OptionalHeader.LoaderFlags);
}
inline UINT32 PEDecoder::GetWin32VersionValue() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return VAL32(GetNTHeaders32()->OptionalHeader.Win32VersionValue);
else
return VAL32(GetNTHeaders64()->OptionalHeader.Win32VersionValue);
}
inline COUNT_T PEDecoder::GetNumberOfRvaAndSizes() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return VAL32(GetNTHeaders32()->OptionalHeader.NumberOfRvaAndSizes);
else
return VAL32(GetNTHeaders64()->OptionalHeader.NumberOfRvaAndSizes);
}
inline BOOL PEDecoder::HasDirectoryEntry(int entry) const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
if (Has32BitNTHeaders())
return (GetNTHeaders32()->OptionalHeader.DataDirectory[entry].VirtualAddress != 0);
else
return (GetNTHeaders64()->OptionalHeader.DataDirectory[entry].VirtualAddress != 0);
}
inline IMAGE_DATA_DIRECTORY *PEDecoder::GetDirectoryEntry(int entry) const
{
CONTRACT(IMAGE_DATA_DIRECTORY *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACT_END;
if (Has32BitNTHeaders())
RETURN dac_cast<PTR_IMAGE_DATA_DIRECTORY>(
dac_cast<TADDR>(GetNTHeaders32()) +
offsetof(IMAGE_NT_HEADERS32, OptionalHeader.DataDirectory) +
entry * sizeof(IMAGE_DATA_DIRECTORY));
else
RETURN dac_cast<PTR_IMAGE_DATA_DIRECTORY>(
dac_cast<TADDR>(GetNTHeaders64()) +
offsetof(IMAGE_NT_HEADERS64, OptionalHeader.DataDirectory) +
entry * sizeof(IMAGE_DATA_DIRECTORY));
}
inline TADDR PEDecoder::GetDirectoryEntryData(int entry, COUNT_T *pSize) const
{
CONTRACT(TADDR)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(CheckDirectoryEntry(entry, 0, NULL_OK));
PRECONDITION(CheckPointer(pSize, NULL_OK));
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer((void *)RETVAL, NULL_OK));
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACT_END;
IMAGE_DATA_DIRECTORY *pDir = GetDirectoryEntry(entry);
if (pSize != NULL)
*pSize = VAL32(pDir->Size);
RETURN GetDirectoryData(pDir);
}
inline TADDR PEDecoder::GetDirectoryData(IMAGE_DATA_DIRECTORY *pDir) const
{
CONTRACT(TADDR)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(CheckDirectory(pDir, 0, NULL_OK));
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
POSTCONDITION(CheckPointer((void *)RETVAL, NULL_OK));
CANNOT_TAKE_LOCK;
}
CONTRACT_END;
RETURN GetRvaData(VAL32(pDir->VirtualAddress));
}
inline TADDR PEDecoder::GetDirectoryData(IMAGE_DATA_DIRECTORY *pDir, COUNT_T *pSize) const
{
CONTRACT(TADDR)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(CheckDirectory(pDir, 0, NULL_OK));
PRECONDITION(CheckPointer(pSize));
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
POSTCONDITION(CheckPointer((void *)RETVAL, NULL_OK));
CANNOT_TAKE_LOCK;
}
CONTRACT_END;
*pSize = VAL32(pDir->Size);
RETURN GetRvaData(VAL32(pDir->VirtualAddress));
}
inline TADDR PEDecoder::GetInternalAddressData(SIZE_T address) const
{
CONTRACT(TADDR)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(CheckInternalAddress(address, NULL_OK));
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer((void *)RETVAL));
}
CONTRACT_END;
RETURN GetRvaData(InternalAddressToRva(address));
}
inline BOOL PEDecoder::HasCorHeader() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
SUPPORTS_DAC;
GC_NOTRIGGER;
}
CONTRACTL_END;
return HasDirectoryEntry(IMAGE_DIRECTORY_ENTRY_COMHEADER);
}
inline BOOL PEDecoder::IsILOnly() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(HasCorHeader());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
// Pretend that ready-to-run images are IL-only
return((GetCorHeader()->Flags & VAL32(COMIMAGE_FLAGS_ILONLY)) != 0) || HasReadyToRunHeader();
}
inline COUNT_T PEDecoder::RvaToOffset(RVA rva) const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(CheckRva(rva,NULL_OK));
NOTHROW;
CANNOT_TAKE_LOCK;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
if(rva > 0)
{
IMAGE_SECTION_HEADER *section = RvaToSection(rva);
if (section == NULL)
return rva;
return rva - VAL32(section->VirtualAddress) + VAL32(section->PointerToRawData);
}
else return 0;
}
inline RVA PEDecoder::OffsetToRva(COUNT_T fileOffset) const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(CheckOffset(fileOffset,NULL_OK));
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
if(fileOffset > 0)
{
IMAGE_SECTION_HEADER *section = OffsetToSection(fileOffset);
PREFIX_ASSUME (section!=NULL); //TODO: actually it is possible that it si null we need to rethink how we handle this cases and do better there
return fileOffset - VAL32(section->PointerToRawData) + VAL32(section->VirtualAddress);
}
else return 0;
}
inline BOOL PEDecoder::IsStrongNameSigned() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(HasCorHeader());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
return ((GetCorHeader()->Flags & VAL32(COMIMAGE_FLAGS_STRONGNAMESIGNED)) != 0);
}
inline BOOL PEDecoder::HasStrongNameSignature() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(HasCorHeader());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
return (GetCorHeader()->StrongNameSignature.VirtualAddress != 0);
}
inline CHECK PEDecoder::CheckStrongNameSignature() const
{
CONTRACT_CHECK
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(HasCorHeader());
PRECONDITION(HasStrongNameSignature());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACT_CHECK_END;
return CheckDirectory(&GetCorHeader()->StrongNameSignature, IMAGE_SCN_MEM_WRITE, NULL_OK);
}
inline PTR_CVOID PEDecoder::GetStrongNameSignature(COUNT_T *pSize) const
{
CONTRACT(PTR_CVOID)
{
INSTANCE_CHECK;
PRECONDITION(HasCorHeader());
PRECONDITION(HasStrongNameSignature());
PRECONDITION(CheckStrongNameSignature());
PRECONDITION(CheckPointer(pSize, NULL_OK));
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
IMAGE_DATA_DIRECTORY *pDir = &GetCorHeader()->StrongNameSignature;
if (pSize != NULL)
*pSize = VAL32(pDir->Size);
RETURN dac_cast<PTR_CVOID>(GetDirectoryData(pDir));
}
inline BOOL PEDecoder::HasTls() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
return HasDirectoryEntry(IMAGE_DIRECTORY_ENTRY_TLS);
}
inline CHECK PEDecoder::CheckTls() const
{
CONTRACT_CHECK
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACT_CHECK_END;
CHECK(CheckDirectoryEntry(IMAGE_DIRECTORY_ENTRY_TLS, 0, NULL_OK));
IMAGE_TLS_DIRECTORY *pTlsHeader = (IMAGE_TLS_DIRECTORY *) GetDirectoryEntryData(IMAGE_DIRECTORY_ENTRY_TLS);
CHECK(CheckUnderflow(VALPTR(pTlsHeader->EndAddressOfRawData), VALPTR(pTlsHeader->StartAddressOfRawData)));
CHECK(VALPTR(pTlsHeader->EndAddressOfRawData) - VALPTR(pTlsHeader->StartAddressOfRawData) <= COUNT_T_MAX);
CHECK(CheckInternalAddress(VALPTR(pTlsHeader->StartAddressOfRawData),
(COUNT_T) (VALPTR(pTlsHeader->EndAddressOfRawData) - VALPTR(pTlsHeader->StartAddressOfRawData))));
CHECK_OK;
}
inline PTR_VOID PEDecoder::GetTlsRange(COUNT_T * pSize) const
{
CONTRACT(void *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(HasTls());
PRECONDITION(CheckTls());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
IMAGE_TLS_DIRECTORY *pTlsHeader =
PTR_IMAGE_TLS_DIRECTORY(GetDirectoryEntryData(IMAGE_DIRECTORY_ENTRY_TLS));
if (pSize != 0)
*pSize = (COUNT_T) (VALPTR(pTlsHeader->EndAddressOfRawData) - VALPTR(pTlsHeader->StartAddressOfRawData));
PREFIX_ASSUME (pTlsHeader!=NULL);
RETURN PTR_VOID(GetInternalAddressData(pTlsHeader->StartAddressOfRawData));
}
inline UINT32 PEDecoder::GetTlsIndex() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(HasTls());
PRECONDITION(CheckTls());
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
IMAGE_TLS_DIRECTORY *pTlsHeader = (IMAGE_TLS_DIRECTORY *) GetDirectoryEntryData(IMAGE_DIRECTORY_ENTRY_TLS);
return (UINT32)*PTR_UINT32(GetInternalAddressData((SIZE_T)VALPTR(pTlsHeader->AddressOfIndex)));
}
inline IMAGE_COR20_HEADER *PEDecoder::GetCorHeader() const
{
CONTRACT(IMAGE_COR20_HEADER *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(HasCorHeader());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACT_END;
if (m_pCorHeader == NULL)
const_cast<PEDecoder *>(this)->m_pCorHeader =
dac_cast<PTR_IMAGE_COR20_HEADER>(FindCorHeader());
RETURN m_pCorHeader;
}
inline BOOL PEDecoder::IsNativeMachineFormat() const
{
if (!HasContents() || !HasNTHeaders() )
return FALSE;
_ASSERTE(m_pNTHeaders);
WORD expectedFormat = HasCorHeader() && HasReadyToRunHeader() ?
IMAGE_FILE_MACHINE_NATIVE_NI :
IMAGE_FILE_MACHINE_NATIVE;
//do not call GetNTHeaders as we do not want to bother with PE32->PE32+ conversion
return m_pNTHeaders->FileHeader.Machine==expectedFormat;
}
inline BOOL PEDecoder::IsI386() const
{
if (!HasContents() || !HasNTHeaders() )
return FALSE;
_ASSERTE(m_pNTHeaders);
//do not call GetNTHeaders as we do not want to bother with PE32->PE32+ conversion
return m_pNTHeaders->FileHeader.Machine==IMAGE_FILE_MACHINE_I386;
}
// static
inline PTR_IMAGE_SECTION_HEADER PEDecoder::FindFirstSection(IMAGE_NT_HEADERS * pNTHeaders)
{
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC;
return dac_cast<PTR_IMAGE_SECTION_HEADER>(
dac_cast<TADDR>(pNTHeaders) +
FIELD_OFFSET(IMAGE_NT_HEADERS, OptionalHeader) +
VAL16(pNTHeaders->FileHeader.SizeOfOptionalHeader));
}
inline COUNT_T PEDecoder::GetNumberOfSections() const
{
CONTRACTL
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
SUPPORTS_DAC;
}
CONTRACTL_END;
return VAL16(FindNTHeaders()->FileHeader.NumberOfSections);
}
inline DWORD PEDecoder::GetImageIdentity() const
{
WRAPPER_NO_CONTRACT;
return GetTimeDateStamp() ^ GetCheckSum() ^ DWORD( GetVirtualSize() );
}
inline PTR_IMAGE_SECTION_HEADER PEDecoder::FindFirstSection() const
{
CONTRACT(IMAGE_SECTION_HEADER *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
SUPPORTS_DAC;
}
CONTRACT_END;
RETURN FindFirstSection(FindNTHeaders());
}
inline IMAGE_NT_HEADERS *PEDecoder::FindNTHeaders() const
{
CONTRACT(IMAGE_NT_HEADERS *)
{
INSTANCE_CHECK;
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACT_END;
RETURN PTR_IMAGE_NT_HEADERS(m_base + VAL32(PTR_IMAGE_DOS_HEADER(m_base)->e_lfanew));
}
inline IMAGE_COR20_HEADER *PEDecoder::FindCorHeader() const
{
CONTRACT(IMAGE_COR20_HEADER *)
{
INSTANCE_CHECK;
PRECONDITION(HasCorHeader());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACT_END;
const IMAGE_COR20_HEADER * pCor=PTR_IMAGE_COR20_HEADER(GetDirectoryEntryData(IMAGE_DIRECTORY_ENTRY_COMHEADER));
RETURN ((IMAGE_COR20_HEADER*)pCor);
}
inline CHECK PEDecoder::CheckBounds(RVA rangeBase, COUNT_T rangeSize, RVA rva)
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
CHECK(CheckOverflow(rangeBase, rangeSize));
CHECK(rva >= rangeBase);
CHECK(rva <= rangeBase + rangeSize);
CHECK_OK;
}
inline CHECK PEDecoder::CheckBounds(RVA rangeBase, COUNT_T rangeSize, RVA rva, COUNT_T size)
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
CHECK(CheckOverflow(rangeBase, rangeSize));
CHECK(CheckOverflow(rva, size));
CHECK(rva >= rangeBase);
CHECK(rva + size <= rangeBase + rangeSize);
CHECK_OK;
}
inline CHECK PEDecoder::CheckBounds(const void *rangeBase, COUNT_T rangeSize, const void *pointer)
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
CHECK(CheckOverflow(dac_cast<PTR_CVOID>(rangeBase), rangeSize));
CHECK(dac_cast<TADDR>(pointer) >= dac_cast<TADDR>(rangeBase));
CHECK(dac_cast<TADDR>(pointer) <= dac_cast<TADDR>(rangeBase) + rangeSize);
CHECK_OK;
}
inline CHECK PEDecoder::CheckBounds(PTR_CVOID rangeBase, COUNT_T rangeSize, PTR_CVOID pointer, COUNT_T size)
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
CHECK(CheckOverflow(rangeBase, rangeSize));
CHECK(CheckOverflow(pointer, size));
CHECK(dac_cast<TADDR>(pointer) >= dac_cast<TADDR>(rangeBase));
CHECK(dac_cast<TADDR>(pointer) + size <= dac_cast<TADDR>(rangeBase) + rangeSize);
CHECK_OK;
}
inline void PEDecoder::GetPEKindAndMachine(DWORD * pdwPEKind, DWORD *pdwMachine)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
DWORD dwKind=0,dwMachine=0;
if(HasContents() && HasNTHeaders())
{
dwMachine = GetMachine();
BOOL fIsPE32Plus = !Has32BitNTHeaders();
if (fIsPE32Plus)
dwKind |= (DWORD)pe32Plus;
if (HasCorHeader())
{
IMAGE_COR20_HEADER * pCorHdr = GetCorHeader();
if(pCorHdr != NULL)
{
DWORD dwCorFlags = pCorHdr->Flags;
if (dwCorFlags & VAL32(COMIMAGE_FLAGS_ILONLY))
{
dwKind |= (DWORD)peILonly;
#ifdef HOST_64BIT
// compensate for shim promotion of PE32/ILONLY headers to PE32+ on WIN64
if (fIsPE32Plus && (GetMachine() == IMAGE_FILE_MACHINE_I386))
dwKind &= ~((DWORD)pe32Plus);
#endif
}
if (COR_IS_32BIT_REQUIRED(dwCorFlags))
dwKind |= (DWORD)pe32BitRequired;
else if (COR_IS_32BIT_PREFERRED(dwCorFlags))
dwKind |= (DWORD)pe32BitPreferred;
// compensate for MC++ peculiarity
if(dwKind == 0)
dwKind = (DWORD)pe32BitRequired;
}
else
{
dwKind |= (DWORD)pe32Unmanaged;
}
if (HasReadyToRunHeader())
{
if (dwMachine == IMAGE_FILE_MACHINE_NATIVE_NI)
{
// Supply the original machine type to the assembly binder
dwMachine = IMAGE_FILE_MACHINE_NATIVE;
}
if ((GetReadyToRunHeader()->CoreHeader.Flags & READYTORUN_FLAG_PLATFORM_NEUTRAL_SOURCE) != 0)
{
// Supply the original PEKind/Machine to the assembly binder to make the full assembly name look like the original
dwKind = peILonly;
dwMachine = IMAGE_FILE_MACHINE_I386;
}
}
}
else
{
dwKind |= (DWORD)pe32Unmanaged;
}
}
*pdwPEKind = dwKind;
*pdwMachine = dwMachine;
}
inline BOOL PEDecoder::IsPlatformNeutral()
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
}
CONTRACTL_END;
DWORD dwKind, dwMachine;
GetPEKindAndMachine(&dwKind, &dwMachine);
return ((dwKind & (peILonly | pe32Plus | pe32BitRequired)) == peILonly) && (dwMachine == IMAGE_FILE_MACHINE_I386);
}
inline BOOL PEDecoder::IsComponentAssembly() const
{
CONTRACTL
{
INSTANCE_CHECK;
NOTHROW;
GC_NOTRIGGER;
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACTL_END;
return HasReadyToRunHeader() && (m_pReadyToRunHeader->CoreHeader.Flags & READYTORUN_FLAG_COMPONENT) != 0;
}
inline BOOL PEDecoder::HasReadyToRunHeader() const
{
CONTRACTL
{
INSTANCE_CHECK;
NOTHROW;
GC_NOTRIGGER;
CANNOT_TAKE_LOCK;
SUPPORTS_DAC;
}
CONTRACTL_END;
if (m_flags & FLAG_HAS_NO_READYTORUN_HEADER)
return FALSE;
if (m_pReadyToRunHeader != NULL)
return TRUE;
return FindReadyToRunHeader() != NULL;
}
inline READYTORUN_HEADER * PEDecoder::GetReadyToRunHeader() const
{
CONTRACT(READYTORUN_HEADER *)
{
INSTANCE_CHECK;
PRECONDITION(CheckNTHeaders());
PRECONDITION(HasCorHeader());
PRECONDITION(HasReadyToRunHeader());
NOTHROW;
GC_NOTRIGGER;
POSTCONDITION(CheckPointer(RETVAL));
SUPPORTS_DAC;
CANNOT_TAKE_LOCK;
}
CONTRACT_END;
if (m_pReadyToRunHeader != NULL)
RETURN m_pReadyToRunHeader;
RETURN FindReadyToRunHeader();
}
#endif // _PEDECODER_INL_
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/tests/JIT/Methodical/VT/etc/knight_do.csproj | <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
<DebugType>Full</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="knight.cs" />
</ItemGroup>
</Project>
| <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
<DebugType>Full</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="knight.cs" />
</ItemGroup>
</Project>
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/coreclr/jit/debuginfo.cpp | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include "jitpch.h"
#include "debuginfo.h"
#ifdef DEBUG
//------------------------------------------------------------------------
// Dump: Print a textual representation of this ILLocation.
//
// Notes:
// For invalid ILLocations, we print '???'.
// Otherwise the offset and flags are printed in the format 0xabc[EC].
//
void ILLocation::Dump() const
{
if (!IsValid())
{
printf("???");
}
else
{
printf("0x%03X[", GetOffset());
printf("%c", IsStackEmpty() ? 'E' : '-');
printf("%c", IsCall() ? 'C' : '-');
printf("]");
}
}
//------------------------------------------------------------------------
// Dump: Print a textual representation of this DebugInfo.
//
// Parameters:
// recurse - print the full path back to the root, separated by arrows.
//
// Notes:
// The DebugInfo is printed in the format
//
// INL02 @ 0xabc[EC]
//
// Before '@' is the ordinal of the inline context, then comes the IL
// offset, and then comes the IL location flags (stack Empty, isCall).
//
// If 'recurse' is specified then dump the full DebugInfo path to the
// root in the format
//
// INL02 @ 0xabc[EC] <- INL01 @ 0x123[EC] <- ... <- INLRT @ 0x456[EC]
//
// with the left most entry being the inner most inlined statement.
void DebugInfo::Dump(bool recurse) const
{
InlineContext* context = GetInlineContext();
if (context != nullptr)
{
if (context->IsRoot())
{
printf("INLRT @ ");
}
else if (context->GetOrdinal() != 0)
{
printf(FMT_INL_CTX " @ ", context->GetOrdinal());
}
}
GetLocation().Dump();
DebugInfo par;
if (recurse && GetParent(&par))
{
printf(" <- ");
par.Dump(recurse);
}
}
//------------------------------------------------------------------------
// Validate: Validate this DebugInfo instance.
//
// Notes:
// This validates that if there is DebugInfo, then it looks sane by checking
// that the IL location correctly points to the beginning of an IL instruction.
//
void DebugInfo::Validate() const
{
DebugInfo di = *this;
do
{
if (!di.IsValid())
continue;
bool isValidOffs = di.GetLocation().GetOffset() < di.GetInlineContext()->GetILSize();
if (isValidOffs)
{
bool isValidStart = di.GetInlineContext()->GetILInstsSet()->bitVectTest(di.GetLocation().GetOffset());
assert(isValidStart &&
"Detected invalid debug info: IL offset does not refer to the start of an IL instruction");
}
else
{
assert(!"Detected invalid debug info: IL offset is out of range");
}
} while (di.GetParent(&di));
}
#endif
//------------------------------------------------------------------------
// GetParent: Get debug info for the parent statement that inlined the
// statement for this debug info.
//
// Parameters:
// parent [out] - Debug info for the location that inlined this statement.
//
// Return Value:
// True if the current debug info is valid and has a parent; otherwise false.
// On false return, the 'parent' parameter is unaffected.
//
bool DebugInfo::GetParent(DebugInfo* parent) const
{
if ((m_inlineContext == nullptr) || m_inlineContext->IsRoot())
return false;
*parent = DebugInfo(m_inlineContext->GetParent(), m_inlineContext->GetLocation());
return true;
}
//------------------------------------------------------------------------
// GetRoot: Get debug info for the statement in the root function that
// eventually led to this debug info through inlines.
//
// Return Value:
// If this DebugInfo instance is valid, returns a DebugInfo instance
// representing the call in the root function that eventually inlined the
// statement this DebugInfo describes.
//
// If this DebugInfo instance is invalid, returns an invalid DebugInfo instance.
//
DebugInfo DebugInfo::GetRoot() const
{
DebugInfo result = *this;
while (result.GetParent(&result))
{
}
return result;
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include "jitpch.h"
#include "debuginfo.h"
#ifdef DEBUG
//------------------------------------------------------------------------
// Dump: Print a textual representation of this ILLocation.
//
// Notes:
// For invalid ILLocations, we print '???'.
// Otherwise the offset and flags are printed in the format 0xabc[EC].
//
void ILLocation::Dump() const
{
if (!IsValid())
{
printf("???");
}
else
{
printf("0x%03X[", GetOffset());
printf("%c", IsStackEmpty() ? 'E' : '-');
printf("%c", IsCall() ? 'C' : '-');
printf("]");
}
}
//------------------------------------------------------------------------
// Dump: Print a textual representation of this DebugInfo.
//
// Parameters:
// recurse - print the full path back to the root, separated by arrows.
//
// Notes:
// The DebugInfo is printed in the format
//
// INL02 @ 0xabc[EC]
//
// Before '@' is the ordinal of the inline context, then comes the IL
// offset, and then comes the IL location flags (stack Empty, isCall).
//
// If 'recurse' is specified then dump the full DebugInfo path to the
// root in the format
//
// INL02 @ 0xabc[EC] <- INL01 @ 0x123[EC] <- ... <- INLRT @ 0x456[EC]
//
// with the left most entry being the inner most inlined statement.
void DebugInfo::Dump(bool recurse) const
{
InlineContext* context = GetInlineContext();
if (context != nullptr)
{
if (context->IsRoot())
{
printf("INLRT @ ");
}
else if (context->GetOrdinal() != 0)
{
printf(FMT_INL_CTX " @ ", context->GetOrdinal());
}
}
GetLocation().Dump();
DebugInfo par;
if (recurse && GetParent(&par))
{
printf(" <- ");
par.Dump(recurse);
}
}
//------------------------------------------------------------------------
// Validate: Validate this DebugInfo instance.
//
// Notes:
// This validates that if there is DebugInfo, then it looks sane by checking
// that the IL location correctly points to the beginning of an IL instruction.
//
void DebugInfo::Validate() const
{
DebugInfo di = *this;
do
{
if (!di.IsValid())
continue;
bool isValidOffs = di.GetLocation().GetOffset() < di.GetInlineContext()->GetILSize();
if (isValidOffs)
{
bool isValidStart = di.GetInlineContext()->GetILInstsSet()->bitVectTest(di.GetLocation().GetOffset());
assert(isValidStart &&
"Detected invalid debug info: IL offset does not refer to the start of an IL instruction");
}
else
{
assert(!"Detected invalid debug info: IL offset is out of range");
}
} while (di.GetParent(&di));
}
#endif
//------------------------------------------------------------------------
// GetParent: Get debug info for the parent statement that inlined the
// statement for this debug info.
//
// Parameters:
// parent [out] - Debug info for the location that inlined this statement.
//
// Return Value:
// True if the current debug info is valid and has a parent; otherwise false.
// On false return, the 'parent' parameter is unaffected.
//
bool DebugInfo::GetParent(DebugInfo* parent) const
{
if ((m_inlineContext == nullptr) || m_inlineContext->IsRoot())
return false;
*parent = DebugInfo(m_inlineContext->GetParent(), m_inlineContext->GetLocation());
return true;
}
//------------------------------------------------------------------------
// GetRoot: Get debug info for the statement in the root function that
// eventually led to this debug info through inlines.
//
// Return Value:
// If this DebugInfo instance is valid, returns a DebugInfo instance
// representing the call in the root function that eventually inlined the
// statement this DebugInfo describes.
//
// If this DebugInfo instance is invalid, returns an invalid DebugInfo instance.
//
DebugInfo DebugInfo::GetRoot() const
{
DebugInfo result = *this;
while (result.GetParent(&result))
{
}
return result;
}
| -1 |
dotnet/runtime | 66,268 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co… | …nvert them to TO_I4/TO_I8 in the front end. | vargaz | 2022-03-06T20:28:39Z | 2022-03-08T15:18:15Z | f396c3496a905451bcb4649c44c6d2e627690d05 | 3959a4a9beeb292816008309e12b6d7150c05235 | [mono][jit] Remove OP_FCONV_TO_I/OP_RCONV_TO_I from the back ends, co…. …nvert them to TO_I4/TO_I8 in the front end. | ./src/libraries/System.Text.Encoding.CodePages/src/System/Text/CodePagesEncodingProvider.netcoreapp.cs | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
namespace System.Text
{
public sealed partial class CodePagesEncodingProvider : EncodingProvider
{
public override System.Collections.Generic.IEnumerable<System.Text.EncodingInfo> GetEncodings() => BaseCodePageEncoding.GetEncodings(this);
}
}
| // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
namespace System.Text
{
public sealed partial class CodePagesEncodingProvider : EncodingProvider
{
public override System.Collections.Generic.IEnumerable<System.Text.EncodingInfo> GetEncodings() => BaseCodePageEncoding.GetEncodings(this);
}
}
| -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.