Example #1
0
oop vframeMap::mirror_contents_at(oop obj, stringOop name) {
  TEST;
  slotDesc* sd = vfo->method()->find_nonVM_slot(name);
  if (sd == NULL) return ErrorCodes::vmString_prim_error(SLOTNAMEERROR);
  if (sd->is_obj_slot() && name->is_1arg_keyword())
    return Memory->assignmentMirrorObj;
  abstract_vframe* vf = vfo->as_vframe();
  oop contents = vf->get_slot(sd);
  return contents->as_mirror();
}
Example #2
0
oop slotsMap::copy_add_assignment_slot(slotsOop obj,
                                       stringOop name,
                                       slotType type,
                                       oop annoIgnored,
                                       bool mustAllocate) {
  Unused(annoIgnored);
  Unused(type);
                                         
  if (!name->is_1arg_keyword())
    return ErrorCodes::vmString_prim_error(ARGUMENTCOUNTERROR);

  assert(obj->is_slots() && this == obj->map(), "insecurity");

  // find the data slot

  slotDesc* ds= find_assignee_slot(name);

  if (ds == NULL)
    return ErrorCodes::vmString_prim_error(LONELYASSIGNMENTSLOTERROR);

  if (ds->is_obj_slot())
    // slot already exists -- nothing to do
    return obj->clone(mustAllocate);

  // must be a map slot
  if (!NakedMethods && ds->data->is_method_like())
    return ErrorCodes::vmString_prim_error(UNASSIGNABLESLOTERROR);

  // remove old map data slot
  slotsOop result= copy_remove_one_slot(obj, ds, mustAllocate);
  if (oop(result) == failedAllocationOop) return failedAllocationOop;
  slotsMap *new_map= (slotsMap*)result->map();

  // remove any existing method by same name
  slotDesc* old= new_map->find_slot(name);
  if (old) {
    result= new_map->copy_remove_one_slot(result, old, mustAllocate);
    if (oop(result) == failedAllocationOop) return result;
    new_map= (slotsMap*)result->map();
    assert(result->is_slots(), "just checking");
  } else {
    result= obj;
  }

  // Add in obj slot - enlarge object and put data into it from map
  result= new_map->copy_add_new_slot(result, ds->name, OBJ_SLOT(ds->type),
                                     ds->data, ds->annotation, mustAllocate);
  if (oop(result) == failedAllocationOop) return failedAllocationOop;
  assert(result->is_slots(), "should not fail");

  return result;
}