8149374: Replace C1-specific collection classes with universal collection classes
authorfzhinkin
Wed, 06 Apr 2016 18:51:03 +0300
changeset 38031 e0b822facc03
parent 38030 93f24e7b3c43
child 38032 bedc2fbb9454
8149374: Replace C1-specific collection classes with universal collection classes Reviewed-by: kvn, mgerdin, coleenp
hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp
hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp
hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp
hotspot/src/cpu/x86/vm/c1_FpuStackSim_x86.cpp
hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp
hotspot/src/share/vm/c1/c1_CodeStubs.hpp
hotspot/src/share/vm/c1/c1_Compilation.hpp
hotspot/src/share/vm/c1/c1_FrameMap.cpp
hotspot/src/share/vm/c1/c1_FrameMap.hpp
hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
hotspot/src/share/vm/c1/c1_IR.cpp
hotspot/src/share/vm/c1/c1_IR.hpp
hotspot/src/share/vm/c1/c1_Instruction.cpp
hotspot/src/share/vm/c1/c1_Instruction.hpp
hotspot/src/share/vm/c1/c1_LIR.hpp
hotspot/src/share/vm/c1/c1_LIRAssembler.cpp
hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
hotspot/src/share/vm/c1/c1_LIRGenerator.hpp
hotspot/src/share/vm/c1/c1_LinearScan.cpp
hotspot/src/share/vm/c1/c1_LinearScan.hpp
hotspot/src/share/vm/c1/c1_Optimizer.cpp
hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp
hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp
hotspot/src/share/vm/c1/c1_ValueMap.cpp
hotspot/src/share/vm/c1/c1_ValueMap.hpp
hotspot/src/share/vm/c1/c1_ValueStack.cpp
hotspot/src/share/vm/classfile/classFileParser.cpp
hotspot/src/share/vm/classfile/classFileParser.hpp
hotspot/src/share/vm/gc/cms/parNewGeneration.cpp
hotspot/src/share/vm/interpreter/rewriter.cpp
hotspot/src/share/vm/interpreter/rewriter.hpp
hotspot/src/share/vm/oops/cpCache.cpp
hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp
hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
hotspot/src/share/vm/utilities/array.cpp
hotspot/src/share/vm/utilities/array.hpp
hotspot/src/share/vm/utilities/growableArray.hpp
--- a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -1127,7 +1127,7 @@
 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
   Values* dims = x->dims();
   int i = dims->length();
-  LIRItemList* items = new LIRItemList(dims->length(), NULL);
+  LIRItemList* items = new LIRItemList(i, i, NULL);
   while (i-- > 0) {
     LIRItem* size = new LIRItem(dims->at(i), this);
     items->at_put(i, size);
--- a/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -1055,7 +1055,7 @@
 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
   Values* dims = x->dims();
   int i = dims->length();
-  LIRItemList* items = new LIRItemList(dims->length(), NULL);
+  LIRItemList* items = new LIRItemList(i, i, NULL);
   while (i-- > 0) {
     LIRItem* size = new LIRItem(dims->at(i), this);
     items->at_put(i, size);
--- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1033,7 +1033,7 @@
 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
   Values* dims = x->dims();
   int i = dims->length();
-  LIRItemList* items = new LIRItemList(dims->length(), NULL);
+  LIRItemList* items = new LIRItemList(i, i, NULL);
   while (i-- > 0) {
     LIRItem* size = new LIRItem(dims->at(i), this);
     items->at_put(i, size);
--- a/hotspot/src/cpu/x86/vm/c1_FpuStackSim_x86.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/c1_FpuStackSim_x86.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -169,18 +169,18 @@
 
 intArray* FpuStackSim::write_state() {
   intArray* res = new intArray(1 + FrameMap::nof_fpu_regs);
-  (*res)[0] = stack_size();
+  res->append(stack_size());
   for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
-    (*res)[1 + i] = regs_at(i);
+    res->append(regs_at(i));
   }
   return res;
 }
 
 
 void FpuStackSim::read_state(intArray* fpu_stack_state) {
-  _stack_size = (*fpu_stack_state)[0];
+  _stack_size = fpu_stack_state->at(0);
   for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
-    set_regs_at(i, (*fpu_stack_state)[1 + i]);
+    set_regs_at(i, fpu_stack_state->at(1 + i));
   }
 }
 
--- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1260,7 +1260,7 @@
 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
   Values* dims = x->dims();
   int i = dims->length();
-  LIRItemList* items = new LIRItemList(dims->length(), NULL);
+  LIRItemList* items = new LIRItemList(i, i, NULL);
   while (i-- > 0) {
     LIRItem* size = new LIRItem(dims->at(i), this);
     items->at_put(i, size);
--- a/hotspot/src/share/vm/c1/c1_CodeStubs.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_CodeStubs.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,17 +77,13 @@
   }
 };
 
-
-define_array(CodeStubArray, CodeStub*)
-define_stack(_CodeStubList, CodeStubArray)
-
-class CodeStubList: public _CodeStubList {
+class CodeStubList: public GrowableArray<CodeStub*> {
  public:
-  CodeStubList(): _CodeStubList() {}
+  CodeStubList(): GrowableArray<CodeStub*>() {}
 
   void append(CodeStub* stub) {
     if (!contains(stub)) {
-      _CodeStubList::append(stub);
+      GrowableArray<CodeStub*>::append(stub);
     }
   }
 };
--- a/hotspot/src/share/vm/c1/c1_Compilation.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_Compilation.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,12 +53,9 @@
 class CFGPrinter;
 typedef LIR_OprDesc* LIR_Opr;
 
-
-define_array(BasicTypeArray, BasicType)
-define_stack(BasicTypeList, BasicTypeArray)
-
-define_array(ExceptionInfoArray, ExceptionInfo*)
-define_stack(ExceptionInfoList,  ExceptionInfoArray)
+typedef GrowableArray<BasicType> BasicTypeArray;
+typedef GrowableArray<BasicType> BasicTypeList;
+typedef GrowableArray<ExceptionInfo*> ExceptionInfoList;
 
 class Compilation: public StackObj {
   friend class CompilationResourceObj;
--- a/hotspot/src/share/vm/c1/c1_FrameMap.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_FrameMap.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -164,7 +164,7 @@
   _reserved_argument_area_size = MAX2(4, reserved_argument_area_size) * BytesPerWord;
 
   _argcount = method->arg_size();
-  _argument_locations = new intArray(_argcount, -1);
+  _argument_locations = new intArray(_argcount, _argcount, -1);
   _incoming_arguments = java_calling_convention(signature_type_array_for(method), false);
   _oop_map_arg_count = _incoming_arguments->reserved_stack_slots();
 
--- a/hotspot/src/share/vm/c1/c1_FrameMap.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_FrameMap.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,8 +36,6 @@
 
 class ciMethod;
 class CallingConvention;
-class BasicTypeArray;
-class BasicTypeList;
 
 //--------------------------------------------------------
 //               FrameMap
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -356,7 +356,7 @@
 
   _active = BitMap(BlockBegin::number_of_blocks());         _active.clear();
   _visited = BitMap(BlockBegin::number_of_blocks());        _visited.clear();
-  _loop_map = intArray(BlockBegin::number_of_blocks(), 0);
+  _loop_map = intArray(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), 0);
   _next_loop_index = 0;
   _next_block_number = _blocks.length();
 
@@ -1353,7 +1353,7 @@
   } else {
     // collect successors & keys
     BlockList* sux = new BlockList(l + 1, NULL);
-    intArray* keys = new intArray(l, 0);
+    intArray* keys = new intArray(l, l, 0);
     int i;
     bool has_bb = false;
     for (i = 0; i < l; i++) {
@@ -1709,7 +1709,7 @@
   bool ignored_will_link;
   ciSignature* declared_signature = NULL;
   ciMethod* real_target = method()->get_method_at_bci(bci(), ignored_will_link, &declared_signature);
-  assert(expected == obj_args->length() || real_target->is_method_handle_intrinsic(), "missed on arg?");
+  assert(expected == obj_args->max_length() || real_target->is_method_handle_intrinsic(), "missed on arg?");
 #endif
 }
 
@@ -1720,7 +1720,7 @@
   if (obj_args == NULL) {
     return NULL;
   }
-  int s = obj_args->size();
+  int s = obj_args->max_length();
   // if called through method handle invoke, some arguments may have been popped
   for (int i = start, j = 0; j < s && i < args->length(); i++) {
     if (args->at(i)->type()->is_object_kind()) {
@@ -2157,7 +2157,7 @@
   ciKlass* klass = stream()->get_klass(will_link);
   ValueStack* state_before = !klass->is_loaded() || PatchALot ? copy_state_before() : copy_state_exhandling();
 
-  Values* dims = new Values(dimensions, NULL);
+  Values* dims = new Values(dimensions, dimensions, NULL);
   // fill in all dimensions
   int i = dimensions;
   while (i-- > 0) dims->at_put(i, ipop());
@@ -3760,9 +3760,9 @@
       int start = 0;
       Values* obj_args = args_list_for_profiling(callee, start, has_receiver);
       if (obj_args != NULL) {
-        int s = obj_args->size();
+        int s = obj_args->max_length();
         // if called through method handle invoke, some arguments may have been popped
-        for (int i = args_base+start, j = 0; j < obj_args->size() && i < state()->stack_size(); ) {
+        for (int i = args_base+start, j = 0; j < obj_args->max_length() && i < state()->stack_size(); ) {
           Value v = state()->stack_at_inc(i);
           if (v->type()->is_object_kind()) {
             obj_args->push(v);
@@ -4079,7 +4079,7 @@
   // properly clone all blocks in jsr region as well as exception
   // handlers containing rets
   BlockList* new_bci2block = new BlockList(bci2block()->length());
-  new_bci2block->push_all(bci2block());
+  new_bci2block->appendAll(bci2block());
   data->set_bci2block(new_bci2block);
   data->set_scope(scope());
   data->setup_jsr_xhandlers();
--- a/hotspot/src/share/vm/c1/c1_IR.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_IR.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -530,7 +530,7 @@
   _visited_blocks(_max_block_id),
   _active_blocks(_max_block_id),
   _dominator_blocks(_max_block_id),
-  _forward_branches(_max_block_id, 0),
+  _forward_branches(_max_block_id, _max_block_id, 0),
   _loop_end_blocks(8),
   _work_list(8),
   _linear_scan_order(NULL), // initialized later with correct size
@@ -848,13 +848,13 @@
     return false;
   }
 
-  assert(_linear_scan_order->index_of(cur) == -1, "block already processed (block can be ready only once)");
-  assert(_work_list.index_of(cur) == -1, "block already in work-list (block can be ready only once)");
+  assert(_linear_scan_order->find(cur) == -1, "block already processed (block can be ready only once)");
+  assert(_work_list.find(cur) == -1, "block already in work-list (block can be ready only once)");
   return true;
 }
 
 void ComputeLinearScanOrder::sort_into_work_list(BlockBegin* cur) {
-  assert(_work_list.index_of(cur) == -1, "block already in work list");
+  assert(_work_list.find(cur) == -1, "block already in work list");
 
   int cur_weight = compute_weight(cur);
 
@@ -890,7 +890,7 @@
 
 void ComputeLinearScanOrder::append_block(BlockBegin* cur) {
   TRACE_LINEAR_SCAN(3, tty->print_cr("appending block B%d (weight 0x%6x) to linear-scan order", cur->block_id(), cur->linear_scan_number()));
-  assert(_linear_scan_order->index_of(cur) == -1, "cannot add the same block twice");
+  assert(_linear_scan_order->find(cur) == -1, "cannot add the same block twice");
 
   // currently, the linear scan order and code emit order are equal.
   // therefore the linear_scan_number and the weight of a block must also
@@ -1115,13 +1115,13 @@
     BlockBegin* cur = _linear_scan_order->at(i);
 
     assert(cur->linear_scan_number() == i, "incorrect linear_scan_number");
-    assert(cur->linear_scan_number() >= 0 && cur->linear_scan_number() == _linear_scan_order->index_of(cur), "incorrect linear_scan_number");
+    assert(cur->linear_scan_number() >= 0 && cur->linear_scan_number() == _linear_scan_order->find(cur), "incorrect linear_scan_number");
 
     int j;
     for (j = cur->number_of_sux() - 1; j >= 0; j--) {
       BlockBegin* sux = cur->sux_at(j);
 
-      assert(sux->linear_scan_number() >= 0 && sux->linear_scan_number() == _linear_scan_order->index_of(sux), "incorrect linear_scan_number");
+      assert(sux->linear_scan_number() >= 0 && sux->linear_scan_number() == _linear_scan_order->find(sux), "incorrect linear_scan_number");
       if (!sux->is_set(BlockBegin::backward_branch_target_flag)) {
         assert(cur->linear_scan_number() < sux->linear_scan_number(), "invalid order");
       }
@@ -1133,7 +1133,7 @@
     for (j = cur->number_of_preds() - 1; j >= 0; j--) {
       BlockBegin* pred = cur->pred_at(j);
 
-      assert(pred->linear_scan_number() >= 0 && pred->linear_scan_number() == _linear_scan_order->index_of(pred), "incorrect linear_scan_number");
+      assert(pred->linear_scan_number() >= 0 && pred->linear_scan_number() == _linear_scan_order->find(pred), "incorrect linear_scan_number");
       if (!cur->is_set(BlockBegin::backward_branch_target_flag)) {
         assert(cur->linear_scan_number() > pred->linear_scan_number(), "invalid order");
       }
@@ -1255,8 +1255,7 @@
 }
 
 
-define_array(BlockListArray, BlockList*)
-define_stack(BlockListList, BlockListArray)
+typedef GrowableArray<BlockList*> BlockListList;
 
 class PredecessorValidator : public BlockClosure {
  private:
@@ -1270,7 +1269,7 @@
  public:
   PredecessorValidator(IR* hir) {
     ResourceMark rm;
-    _predecessors = new BlockListList(BlockBegin::number_of_blocks(), NULL);
+    _predecessors = new BlockListList(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), NULL);
     _blocks = new BlockList();
 
     int i;
--- a/hotspot/src/share/vm/c1/c1_IR.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_IR.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -104,9 +104,7 @@
   bool equals(XHandler* other) const;
 };
 
-define_array(_XHandlerArray, XHandler*)
-define_stack(_XHandlerList, _XHandlerArray)
-
+typedef GrowableArray<XHandler*> _XHandlerList;
 
 // XHandlers is the C1 internal list of exception handlers for a method
 class XHandlers: public CompilationResourceObj {
@@ -132,8 +130,7 @@
 
 
 class IRScope;
-define_array(IRScopeArray, IRScope*)
-define_stack(IRScopeList, IRScopeArray)
+typedef GrowableArray<IRScope*> IRScopeList;
 
 class Compilation;
 class IRScope: public CompilationResourceObj {
--- a/hotspot/src/share/vm/c1/c1_Instruction.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_Instruction.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -564,7 +564,7 @@
   for (int s = 0; s < from->number_of_sux();) {
     BlockBegin* sux = from->sux_at(s);
     if (sux == to) {
-      int index = sux->_predecessors.index_of(from);
+      int index = sux->_predecessors.find(from);
       if (index >= 0) {
         sux->_predecessors.remove_at(index);
       }
@@ -664,7 +664,7 @@
 
 void BlockBegin::remove_successor(BlockBegin* pred) {
   int idx;
-  while ((idx = _successors.index_of(pred)) >= 0) {
+  while ((idx = _successors.find(pred)) >= 0) {
     _successors.remove_at(idx);
   }
 }
@@ -677,7 +677,7 @@
 
 void BlockBegin::remove_predecessor(BlockBegin* pred) {
   int idx;
-  while ((idx = _predecessors.index_of(pred)) >= 0) {
+  while ((idx = _predecessors.find(pred)) >= 0) {
     _predecessors.remove_at(idx);
   }
 }
@@ -722,13 +722,15 @@
 
 
 void BlockBegin::iterate_preorder(BlockClosure* closure) {
-  boolArray mark(number_of_blocks(), false);
+  int mark_len = number_of_blocks();
+  boolArray mark(mark_len, mark_len, false);
   iterate_preorder(mark, closure);
 }
 
 
 void BlockBegin::iterate_postorder(BlockClosure* closure) {
-  boolArray mark(number_of_blocks(), false);
+  int mark_len = number_of_blocks();
+  boolArray mark(mark_len, mark_len, false);
   iterate_postorder(mark, closure);
 }
 
--- a/hotspot/src/share/vm/c1/c1_Instruction.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -115,11 +115,8 @@
 
 // A Value is a reference to the instruction creating the value
 typedef Instruction* Value;
-define_array(ValueArray, Value)
-define_stack(Values, ValueArray)
-
-define_array(ValueStackArray, ValueStack*)
-define_stack(ValueStackStack, ValueStackArray)
+typedef GrowableArray<Value> Values;
+typedef GrowableArray<ValueStack*> ValueStackStack;
 
 // BlockClosure is the base class for block traversal/iteration.
 
@@ -137,14 +134,13 @@
 
 
 // Some array and list classes
-define_array(BlockBeginArray, BlockBegin*)
-define_stack(_BlockList, BlockBeginArray)
-
-class BlockList: public _BlockList {
+typedef GrowableArray<BlockBegin*> BlockBeginArray;
+
+class BlockList: public GrowableArray<BlockBegin*> {
  public:
-  BlockList(): _BlockList() {}
-  BlockList(const int size): _BlockList(size) {}
-  BlockList(const int size, BlockBegin* init): _BlockList(size, init) {}
+  BlockList(): GrowableArray<BlockBegin*>() {}
+  BlockList(const int size): GrowableArray<BlockBegin*>(size) {}
+  BlockList(const int size, BlockBegin* init): GrowableArray<BlockBegin*>(size, size, init) {}
 
   void iterate_forward(BlockClosure* closure);
   void iterate_backward(BlockClosure* closure);
@@ -1744,7 +1740,7 @@
   void remove_predecessor(BlockBegin* pred);
   bool is_predecessor(BlockBegin* pred) const    { return _predecessors.contains(pred); }
   int number_of_preds() const                    { return _predecessors.length(); }
-  BlockBegin* pred_at(int i) const               { return _predecessors[i]; }
+  BlockBegin* pred_at(int i) const               { return _predecessors.at(i); }
 
   // exception handlers potentially invoked by this block
   void add_exception_handler(BlockBegin* b);
@@ -2609,10 +2605,7 @@
   void set_from(BlockBegin* b) { _from = b; }
 };
 
-
-define_array(BlockPairArray, BlockPair*)
-define_stack(BlockPairList, BlockPairArray)
-
+typedef GrowableArray<BlockPair*> BlockPairList;
 
 inline int         BlockBegin::number_of_sux() const            { assert(_end == NULL || _end->number_of_sux() == _successors.length(), "mismatch"); return _successors.length(); }
 inline BlockBegin* BlockBegin::sux_at(int i) const              { assert(_end == NULL || _end->sux_at(i) == _successors.at(i), "mismatch");          return _successors.at(i); }
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,17 +59,9 @@
 typedef LIR_OprDesc* LIR_Opr;
 typedef int          RegNr;
 
-define_array(LIR_OprArray, LIR_Opr)
-define_stack(LIR_OprList, LIR_OprArray)
-
-define_array(LIR_OprRefArray, LIR_Opr*)
-define_stack(LIR_OprRefList, LIR_OprRefArray)
-
-define_array(CodeEmitInfoArray, CodeEmitInfo*)
-define_stack(CodeEmitInfoList, CodeEmitInfoArray)
-
-define_array(LIR_OpArray, LIR_Op*)
-define_stack(LIR_OpList, LIR_OpArray)
+typedef GrowableArray<LIR_Opr> LIR_OprList;
+typedef GrowableArray<LIR_Op*> LIR_OpArray;
+typedef GrowableArray<LIR_Op*> LIR_OpList;
 
 // define LIR_OprPtr early so LIR_OprDesc can refer to it
 class LIR_OprPtr: public CompilationResourceObj {
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -127,7 +127,7 @@
 
 void LIR_Assembler::emit_stubs(CodeStubList* stub_list) {
   for (int m = 0; m < stub_list->length(); m++) {
-    CodeStub* s = (*stub_list)[m];
+    CodeStub* s = stub_list->at(m);
 
     check_codespace();
     CHECK_BAILOUT();
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -150,7 +150,7 @@
   int i;
   // resolve any cycles in moves from and to virtual registers
   for (i = virtual_operands().length() - 1; i >= 0; i --) {
-    ResolveNode* node = virtual_operands()[i];
+    ResolveNode* node = virtual_operands().at(i);
     if (!node->visited()) {
       _loop = NULL;
       move(NULL, node);
@@ -161,7 +161,7 @@
 
   // generate move for move from non virtual register to abitrary destination
   for (i = other_operands().length() - 1; i >= 0; i --) {
-    ResolveNode* node = other_operands()[i];
+    ResolveNode* node = other_operands().at(i);
     for (int j = node->no_of_destinations() - 1; j >= 0; j --) {
       emit_move(node->operand(), node->destination_at(j)->operand());
     }
@@ -177,7 +177,7 @@
     assert(node == NULL || node->operand() == opr, "");
     if (node == NULL) {
       node = new ResolveNode(opr);
-      vreg_table()[vreg_num] = node;
+      vreg_table().at_put(vreg_num, node);
     }
     // Make sure that all virtual operands show up in the list when
     // they are used as the source of a move.
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,8 +39,7 @@
 class SwitchRange;
 class LIRItem;
 
-define_array(LIRItemArray, LIRItem*)
-define_stack(LIRItemList, LIRItemArray)
+typedef GrowableArray<LIRItem*> LIRItemList;
 
 class SwitchRange: public CompilationResourceObj {
  private:
@@ -56,15 +55,12 @@
   BlockBegin* sux() const { return _sux; }
 };
 
-define_array(SwitchRangeArray, SwitchRange*)
-define_stack(SwitchRangeList, SwitchRangeArray)
-
+typedef GrowableArray<SwitchRange*> SwitchRangeArray;
+typedef GrowableArray<SwitchRange*> SwitchRangeList;
 
 class ResolveNode;
 
-define_array(NodeArray, ResolveNode*);
-define_stack(NodeList, NodeArray);
-
+typedef GrowableArray<ResolveNode*> NodeList;
 
 // Node objects form a directed graph of LIR_Opr
 // Edges between Nodes represent moves from one Node to its destinations
@@ -86,7 +82,7 @@
   // accessors
   LIR_Opr operand() const           { return _operand; }
   int no_of_destinations() const    { return _destinations.length(); }
-  ResolveNode* destination_at(int i)     { return _destinations[i]; }
+  ResolveNode* destination_at(int i)     { return _destinations.at(i); }
   bool assigned() const             { return _assigned; }
   bool visited() const              { return _visited; }
   bool start_node() const           { return _start_node; }
--- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -495,8 +495,8 @@
   }
 
   // initialize with correct length
-  _lir_ops = LIR_OpArray(num_instructions);
-  _block_of_op = BlockBeginArray(num_instructions);
+  _lir_ops = LIR_OpArray(num_instructions, num_instructions, NULL);
+  _block_of_op = BlockBeginArray(num_instructions, num_instructions, NULL);
 
   int op_id = 0;
   int idx = 0;
@@ -2506,7 +2506,8 @@
 void LinearScan::init_compute_debug_info() {
   // cache for frequently used scope values
   // (cpu registers and stack slots)
-  _scope_value_cache = ScopeValueArray((LinearScan::nof_cpu_regs + frame_map()->argcount() + max_spills()) * 2, NULL);
+  int cache_size = (LinearScan::nof_cpu_regs + frame_map()->argcount() + max_spills()) * 2;
+  _scope_value_cache = ScopeValueArray(cache_size, cache_size, NULL);
 }
 
 MonitorValue* LinearScan::location_for_monitor_index(int monitor_index) {
@@ -3041,7 +3042,7 @@
         insert_point++;
       }
     }
-    instructions->truncate(insert_point);
+    instructions->trunc_to(insert_point);
   }
 }
 
@@ -3445,7 +3446,7 @@
   RegisterVerifier(LinearScan* allocator)
     : _allocator(allocator)
     , _work_list(16)
-    , _saved_states(BlockBegin::number_of_blocks(), NULL)
+    , _saved_states(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), NULL)
   { }
 
   void verify(BlockBegin* start);
@@ -4451,7 +4452,7 @@
     new_use_pos_and_kinds.append(_use_pos_and_kinds.at(i));
   }
 
-  _use_pos_and_kinds.truncate(start_idx + 2);
+  _use_pos_and_kinds.trunc_to(start_idx + 2);
   result->_use_pos_and_kinds = _use_pos_and_kinds;
   _use_pos_and_kinds = new_use_pos_and_kinds;
 
@@ -5539,7 +5540,7 @@
     IntervalList* processed = _spill_intervals[reg];
     for (int i = 0; i < _spill_intervals[regHi]->length(); i++) {
       Interval* it = _spill_intervals[regHi]->at(i);
-      if (processed->find_from_end(it) == -1) {
+      if (processed->find(it) == -1) {
         remove_from_list(it);
         split_and_spill_interval(it);
       }
@@ -6210,7 +6211,7 @@
       _original_preds.clear();
       for (j = block->number_of_preds() - 1; j >= 0; j--) {
         BlockBegin* pred = block->pred_at(j);
-        if (_original_preds.index_of(pred) == -1) {
+        if (_original_preds.find(pred) == -1) {
           _original_preds.append(pred);
         }
       }
@@ -6230,7 +6231,7 @@
     }
     old_pos++;
   }
-  code->truncate(new_pos);
+  code->trunc_to(new_pos);
 
   DEBUG_ONLY(verify(code));
 }
@@ -6255,7 +6256,7 @@
           TRACE_LINEAR_SCAN(3, tty->print_cr("Deleting unconditional branch at end of block B%d", block->block_id()));
 
           // delete last branch instruction
-          instructions->truncate(instructions->length() - 1);
+          instructions->trunc_to(instructions->length() - 1);
 
         } else {
           LIR_Op* prev_op = instructions->at(instructions->length() - 2);
@@ -6294,7 +6295,7 @@
                 prev_branch->change_block(last_branch->block());
                 prev_branch->negate_cond();
                 prev_cmp->set_condition(prev_branch->cond());
-                instructions->truncate(instructions->length() - 1);
+                instructions->trunc_to(instructions->length() - 1);
                 // if we do change the condition, we have to change the cmove as well
                 if (prev_cmove != NULL) {
                   prev_cmove->set_condition(prev_branch->cond());
@@ -6377,19 +6378,19 @@
       LIR_OpBranch* op_branch = instructions->at(j)->as_OpBranch();
 
       if (op_branch != NULL) {
-        assert(op_branch->block() == NULL || code->index_of(op_branch->block()) != -1, "branch target not valid");
-        assert(op_branch->ublock() == NULL || code->index_of(op_branch->ublock()) != -1, "branch target not valid");
+        assert(op_branch->block() == NULL || code->find(op_branch->block()) != -1, "branch target not valid");
+        assert(op_branch->ublock() == NULL || code->find(op_branch->ublock()) != -1, "branch target not valid");
       }
     }
 
     for (j = 0; j < block->number_of_sux() - 1; j++) {
       BlockBegin* sux = block->sux_at(j);
-      assert(code->index_of(sux) != -1, "successor not valid");
+      assert(code->find(sux) != -1, "successor not valid");
     }
 
     for (j = 0; j < block->number_of_preds() - 1; j++) {
       BlockBegin* pred = block->pred_at(j);
-      assert(code->index_of(pred) != -1, "successor not valid");
+      assert(code->find(pred) != -1, "successor not valid");
     }
   }
 }
--- a/hotspot/src/share/vm/c1/c1_LinearScan.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -44,18 +44,9 @@
 
 typedef GrowableArray<Interval*> IntervalArray;
 typedef GrowableArray<Interval*> IntervalList;
-
-define_array(IntervalsArray, IntervalList*)
-define_stack(IntervalsList, IntervalsArray)
-
-define_array(OopMapArray, OopMap*)
-define_stack(OopMapList, OopMapArray)
-
-define_array(ScopeValueArray, ScopeValue*)
-
-define_array(LIR_OpListArray, LIR_OpList*);
-define_stack(LIR_OpListStack, LIR_OpListArray);
-
+typedef GrowableArray<IntervalList*> IntervalsList;
+typedef GrowableArray<ScopeValue*> ScopeValueArray;
+typedef GrowableArray<LIR_OpList*> LIR_OpListStack;
 
 enum IntervalUseKind {
   // priority of use kinds must be ascending
@@ -67,9 +58,6 @@
   firstValidKind = 1,
   lastValidKind = 3
 };
-define_array(UseKindArray, IntervalUseKind)
-define_stack(UseKindStack, UseKindArray)
-
 
 enum IntervalKind {
   fixedKind = 0,  // interval pre-colored by LIR_Generator
@@ -619,7 +607,7 @@
   void   add_range(int from, int to);
   Interval* split(int split_pos);
   Interval* split_from_start(int split_pos);
-  void remove_first_use_pos()                    { _use_pos_and_kinds.truncate(_use_pos_and_kinds.length() - 2); }
+  void remove_first_use_pos()                    { _use_pos_and_kinds.trunc_to(_use_pos_and_kinds.length() - 2); }
 
   // test intersection
   bool   covers(int op_id, LIR_OpVisitState::OprMode mode) const;
--- a/hotspot/src/share/vm/c1/c1_Optimizer.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_Optimizer.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,9 +31,7 @@
 #include "utilities/bitMap.inline.hpp"
 #include "compiler/compileLog.hpp"
 
-define_array(ValueSetArray, ValueSet*);
-define_stack(ValueSetList, ValueSetArray);
-
+typedef GrowableArray<ValueSet*> ValueSetList;
 
 Optimizer::Optimizer(IR* ir) {
   assert(ir->is_valid(), "IR must be valid");
@@ -583,8 +581,8 @@
 
   ValueSet* state()                               { return _set; }
   void      set_state_from (ValueSet* state)      { _set->set_from(state); }
-  ValueSet* state_for      (BlockBegin* block)    { return _block_states[block->block_id()]; }
-  void      set_state_for  (BlockBegin* block, ValueSet* stack) { _block_states[block->block_id()] = stack; }
+  ValueSet* state_for      (BlockBegin* block)    { return _block_states.at(block->block_id()); }
+  void      set_state_for  (BlockBegin* block, ValueSet* stack) { _block_states.at_put(block->block_id(), stack); }
   // Returns true if caused a change in the block's state.
   bool      merge_state_for(BlockBegin* block,
                             ValueSet*   incoming_state);
@@ -595,7 +593,7 @@
     : _opt(opt)
     , _set(new ValueSet())
     , _last_explicit_null_check(NULL)
-    , _block_states(BlockBegin::number_of_blocks(), NULL)
+    , _block_states(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), NULL)
     , _work_list(new BlockList()) {
     _visitable_instructions = new ValueSet();
     _visitor.set_eliminator(this);
@@ -1164,19 +1162,19 @@
   // handlers and iterate over them as well
   int nblocks = BlockBegin::number_of_blocks();
   BlockList blocks(nblocks);
-  boolArray visited_block(nblocks, false);
+  boolArray visited_block(nblocks, nblocks, false);
 
   blocks.push(ir()->start());
-  visited_block[ir()->start()->block_id()] = true;
+  visited_block.at_put(ir()->start()->block_id(), true);
   for (int i = 0; i < blocks.length(); i++) {
-    BlockBegin* b = blocks[i];
+    BlockBegin* b = blocks.at(i);
     // exception handlers need to be treated as additional roots
     for (int e = b->number_of_exception_handlers(); e-- > 0; ) {
       BlockBegin* excp = b->exception_handler_at(e);
       int id = excp->block_id();
-      if (!visited_block[id]) {
+      if (!visited_block.at(id)) {
         blocks.push(excp);
-        visited_block[id] = true;
+        visited_block.at_put(id, true);
         nce.iterate(excp);
       }
     }
@@ -1185,9 +1183,9 @@
     for (int s = end->number_of_sux(); s-- > 0; ) {
       BlockBegin* next = end->sux_at(s);
       int id = next->block_id();
-      if (!visited_block[id]) {
+      if (!visited_block.at(id)) {
         blocks.push(next);
-        visited_block[id] = true;
+        visited_block.at_put(id, true);
       }
     }
   }
--- a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,8 +53,8 @@
 
 // Constructor
 RangeCheckEliminator::RangeCheckEliminator(IR *ir) :
-  _bounds(Instruction::number_of_instructions(), NULL),
-  _access_indexed_info(Instruction::number_of_instructions(), NULL)
+  _bounds(Instruction::number_of_instructions(), Instruction::number_of_instructions(), NULL),
+  _access_indexed_info(Instruction::number_of_instructions(), Instruction::number_of_instructions(), NULL)
 {
   _visitor.set_range_check_eliminator(this);
   _ir = ir;
@@ -303,28 +303,28 @@
   // Wrong type or NULL -> No bound
   if (!v || (!v->type()->as_IntType() && !v->type()->as_ObjectType())) return NULL;
 
-  if (!_bounds[v->id()]) {
+  if (!_bounds.at(v->id())) {
     // First (default) bound is calculated
     // Create BoundStack
-    _bounds[v->id()] = new BoundStack();
+    _bounds.at_put(v->id(), new BoundStack());
     _visitor.clear_bound();
     Value visit_value = v;
     visit_value->visit(&_visitor);
     Bound *bound = _visitor.bound();
     if (bound) {
-      _bounds[v->id()]->push(bound);
+      _bounds.at(v->id())->push(bound);
     }
-    if (_bounds[v->id()]->length() == 0) {
+    if (_bounds.at(v->id())->length() == 0) {
       assert(!(v->as_Constant() && v->type()->as_IntConstant()), "constants not handled here");
-      _bounds[v->id()]->push(new Bound());
+      _bounds.at(v->id())->push(new Bound());
     }
-  } else if (_bounds[v->id()]->length() == 0) {
+  } else if (_bounds.at(v->id())->length() == 0) {
     // To avoid endless loops, bound is currently in calculation -> nothing known about it
     return new Bound();
   }
 
   // Return bound
-  return _bounds[v->id()]->top();
+  return _bounds.at(v->id())->top();
 }
 
 // Update bound
@@ -353,28 +353,28 @@
     // No bound update for constants
     return;
   }
-  if (!_bounds[v->id()]) {
+  if (!_bounds.at(v->id())) {
     get_bound(v);
-    assert(_bounds[v->id()], "Now Stack must exist");
+    assert(_bounds.at(v->id()), "Now Stack must exist");
   }
   Bound *top = NULL;
-  if (_bounds[v->id()]->length() > 0) {
-    top = _bounds[v->id()]->top();
+  if (_bounds.at(v->id())->length() > 0) {
+    top = _bounds.at(v->id())->top();
   }
   if (top) {
     bound->and_op(top);
   }
-  _bounds[v->id()]->push(bound);
+  _bounds.at(v->id())->push(bound);
   pushed.append(v->id());
 }
 
 // Add instruction + idx for in block motion
 void RangeCheckEliminator::add_access_indexed_info(InstructionList &indices, int idx, Value instruction, AccessIndexed *ai) {
   int id = instruction->id();
-  AccessIndexedInfo *aii = _access_indexed_info[id];
+  AccessIndexedInfo *aii = _access_indexed_info.at(id);
   if (aii == NULL) {
     aii = new AccessIndexedInfo();
-    _access_indexed_info[id] = aii;
+    _access_indexed_info.at_put(id, aii);
     indices.append(instruction);
     aii->_min = idx;
     aii->_max = idx;
@@ -461,7 +461,7 @@
     if (_optimistic) {
       for (int i = 0; i < indices.length(); i++) {
         Instruction *index_instruction = indices.at(i);
-        AccessIndexedInfo *info = _access_indexed_info[index_instruction->id()];
+        AccessIndexedInfo *info = _access_indexed_info.at(index_instruction->id());
         assert(info != NULL, "Info must not be null");
 
         // if idx < 0, max > 0, max + idx may fall between 0 and
@@ -562,7 +562,7 @@
     // Clear data structures for next array
     for (int i = 0; i < indices.length(); i++) {
       Instruction *index_instruction = indices.at(i);
-      _access_indexed_info[index_instruction->id()] = NULL;
+      _access_indexed_info.at_put(index_instruction->id(), NULL);
     }
     indices.clear();
   }
@@ -1005,7 +1005,7 @@
 
   // Reset stack
   for (int i=0; i<pushed.length(); i++) {
-    _bounds[pushed[i]]->pop();
+    _bounds.at(pushed.at(i))->pop();
   }
 }
 
@@ -1051,7 +1051,7 @@
 #endif
 
 // Verification or the IR
-RangeCheckEliminator::Verification::Verification(IR *ir) : _used(BlockBegin::number_of_blocks(), false) {
+RangeCheckEliminator::Verification::Verification(IR *ir) : _used(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), false) {
   this->_ir = ir;
   ir->iterate_linear_scan_order(this);
 }
@@ -1146,14 +1146,14 @@
   if (start == end) return start != dont_use;
   // Simple BSF from start to end
   //  BlockBeginList _current;
-  for (int i=0; i<_used.length(); i++) {
-    _used[i] = false;
+  for (int i=0; i < _used.length(); i++) {
+    _used.at_put(i, false);
   }
-  _current.truncate(0);
-  _successors.truncate(0);
+  _current.trunc_to(0);
+  _successors.trunc_to(0);
   if (start != dont_use) {
     _current.push(start);
-    _used[start->block_id()] = true;
+    _used.at_put(start->block_id(), true);
   }
 
   //  BlockBeginList _successors;
@@ -1180,17 +1180,17 @@
       }
     }
     for (int i=0; i<_successors.length(); i++) {
-      BlockBegin *sux = _successors[i];
+      BlockBegin *sux = _successors.at(i);
       assert(sux != NULL, "Successor must not be NULL!");
       if (sux == end) {
         return true;
       }
-      if (sux != dont_use && !_used[sux->block_id()]) {
-        _used[sux->block_id()] = true;
+      if (sux != dont_use && !_used.at(sux->block_id())) {
+        _used.at_put(sux->block_id(), true);
         _current.push(sux);
       }
     }
-    _successors.truncate(0);
+    _successors.trunc_to(0);
   }
 
   return false;
--- a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,10 +40,8 @@
   bool _optimistic; // Insert predicates and deoptimize when they fail
   IR *_ir;
 
-  define_array(BlockBeginArray, BlockBegin*)
-  define_stack(BlockBeginList, BlockBeginArray)
-  define_stack(IntegerStack, intArray)
-  define_array(IntegerMap, IntegerStack*)
+  typedef GrowableArray<BlockBegin*> BlockBeginList;
+  typedef GrowableArray<int> IntegerStack;
 
   class Verification : public BlockClosure {
   // RangeCheckEliminator::Verification should never get instatiated on the heap.
@@ -180,13 +178,10 @@
   void add_assertions(Bound *bound, Instruction *instruction, Instruction *position);
 #endif
 
-  define_array(BoundArray, Bound *)
-  define_stack(BoundStack, BoundArray)
-  define_array(BoundMap, BoundStack *)
-  define_array(AccessIndexedArray, AccessIndexed *)
-  define_stack(AccessIndexedList, AccessIndexedArray)
-  define_array(InstructionArray, Instruction *)
-  define_stack(InstructionList, InstructionArray)
+  typedef GrowableArray<Bound*> BoundStack;
+  typedef GrowableArray<BoundStack*> BoundMap;
+  typedef GrowableArray<AccessIndexed*> AccessIndexedList;
+  typedef GrowableArray<Instruction*> InstructionList;
 
   class AccessIndexedInfo : public CompilationResourceObj  {
   public:
@@ -195,7 +190,7 @@
     int _max;
   };
 
-  define_array(AccessIndexedInfoArray, AccessIndexedInfo *)
+  typedef GrowableArray<AccessIndexedInfo*> AccessIndexedInfoArray;
   BoundMap _bounds; // Mapping from Instruction's id to current bound
   AccessIndexedInfoArray _access_indexed_info; // Mapping from Instruction's id to AccessIndexedInfo for in block motion
   Visitor _visitor;
--- a/hotspot/src/share/vm/c1/c1_ValueMap.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_ValueMap.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
 
 ValueMap::ValueMap()
   : _nesting(0)
-  , _entries(ValueMapInitialSize, NULL)
+  , _entries(ValueMapInitialSize, ValueMapInitialSize, NULL)
   , _killed_values()
   , _entry_count(0)
 {
@@ -56,7 +56,7 @@
 
 ValueMap::ValueMap(ValueMap* old)
   : _nesting(old->_nesting + 1)
-  , _entries(old->_entries.length())
+  , _entries(old->_entries.length(), old->_entries.length(), NULL)
   , _killed_values()
   , _entry_count(old->_entry_count)
 {
@@ -72,7 +72,7 @@
   int new_size = old_size * 2 + 1;
 
   ValueMapEntryList worklist(8);
-  ValueMapEntryArray new_entries(new_size, NULL);
+  ValueMapEntryArray new_entries(new_size, new_size, NULL);
   int new_entry_count = 0;
 
   TRACE_VALUE_NUMBERING(tty->print_cr("increasing table size from %d to %d", old_size, new_size));
@@ -486,7 +486,7 @@
 
 GlobalValueNumbering::GlobalValueNumbering(IR* ir)
   : _current_map(NULL)
-  , _value_maps(ir->linear_scan_order()->length(), NULL)
+  , _value_maps(ir->linear_scan_order()->length(), ir->linear_scan_order()->length(), NULL)
   , _compilation(ir->compilation())
 {
   TRACE_VALUE_NUMBERING(tty->print_cr("****** start of global value numbering"));
--- a/hotspot/src/share/vm/c1/c1_ValueMap.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_ValueMap.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,8 +53,8 @@
   void set_next(ValueMapEntry* next) { _next = next; }
 };
 
-define_array(ValueMapEntryArray, ValueMapEntry*)
-define_stack(ValueMapEntryList, ValueMapEntryArray)
+typedef GrowableArray<ValueMapEntry*> ValueMapEntryArray;
+typedef GrowableArray<ValueMapEntry*> ValueMapEntryList;
 
 // ValueMap implements nested hash tables for value numbering.  It
 // maintains a set _killed_values which represents the instructions
@@ -129,8 +129,7 @@
 #endif
 };
 
-define_array(ValueMapArray, ValueMap*)
-
+typedef GrowableArray<ValueMap*> ValueMapArray;
 
 class ValueNumberingVisitor: public InstructionVisitor {
  protected:
--- a/hotspot/src/share/vm/c1/c1_ValueStack.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/c1/c1_ValueStack.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
 , _caller_state(caller_state)
 , _bci(-99)
 , _kind(Parsing)
-, _locals(scope->method()->max_locals(), NULL)
+, _locals(scope->method()->max_locals(), scope->method()->max_locals(), NULL)
 , _stack(scope->method()->max_stack())
 , _locks()
 {
@@ -178,7 +178,7 @@
 
   ValueType* t = stack_at(index)->type();
   Value phi = new Phi(t, b, -index - 1);
-  _stack[index] = phi;
+  _stack.at_put(index, phi);
 
   assert(!t->is_double_word() || _stack.at(index + 1) == NULL, "hi-word of doubleword value must be NULL");
 }
@@ -225,7 +225,7 @@
   if (locals_size() > 0) {
     InstructionPrinter ip;
     for (int i = 0; i < locals_size();) {
-      Value l = _locals[i];
+      Value l = _locals.at(i);
       tty->print("local %d ", i);
       if (l == NULL) {
         tty->print("null");
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -2927,7 +2927,7 @@
   // If JVMTI original method ordering or sharing is enabled construct int
   // array remembering the original ordering
   if (JvmtiExport::can_maintain_original_method_order() || DumpSharedSpaces) {
-    method_ordering = new intArray(length);
+    method_ordering = new intArray(length, length, -1);
     for (int index = 0; index < length; index++) {
       Method* const m = methods->at(index);
       const int old_index = m->vtable_index();
--- a/hotspot/src/share/vm/classfile/classFileParser.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/classfile/classFileParser.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,6 @@
 template <typename T>
 class GrowableArray;
 class InstanceKlass;
-class intArray;
 class Symbol;
 class TempNewSymbol;
 
--- a/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -280,7 +280,7 @@
   }
 }
 
-class ParScanThreadStateSet: private ResourceArray {
+class ParScanThreadStateSet: StackObj {
 public:
   // Initializes states for the specified number of threads;
   ParScanThreadStateSet(int                     num_threads,
@@ -315,8 +315,10 @@
   ParallelTaskTerminator& _term;
   ParNewGeneration&       _young_gen;
   Generation&             _old_gen;
+  ParScanThreadState*     _per_thread_states;
+  const int               _num_threads;
  public:
-  bool is_valid(int id) const { return id < length(); }
+  bool is_valid(int id) const { return id < _num_threads; }
   ParallelTaskTerminator* terminator() { return &_term; }
 };
 
@@ -329,30 +331,31 @@
                                              PreservedMarksSet& preserved_marks_set,
                                              size_t desired_plab_sz,
                                              ParallelTaskTerminator& term)
-  : ResourceArray(sizeof(ParScanThreadState), num_threads),
-    _young_gen(young_gen),
+  : _young_gen(young_gen),
     _old_gen(old_gen),
-    _term(term)
+    _term(term),
+    _per_thread_states(NEW_RESOURCE_ARRAY(ParScanThreadState, num_threads)),
+    _num_threads(num_threads)
 {
   assert(num_threads > 0, "sanity check!");
   assert(ParGCUseLocalOverflow == (overflow_stacks != NULL),
          "overflow_stack allocation mismatch");
   // Initialize states.
   for (int i = 0; i < num_threads; ++i) {
-    new ((ParScanThreadState*)_data + i)
-        ParScanThreadState(&to_space, &young_gen, &old_gen, i, &queue_set,
-                           overflow_stacks, preserved_marks_set.get(i),
-                           desired_plab_sz, term);
+    new(_per_thread_states + i)
+      ParScanThreadState(&to_space, &young_gen, &old_gen, i, &queue_set,
+                         overflow_stacks, preserved_marks_set.get(i),
+                         desired_plab_sz, term);
   }
 }
 
 inline ParScanThreadState& ParScanThreadStateSet::thread_state(int i) {
-  assert(i >= 0 && i < length(), "sanity check!");
-  return ((ParScanThreadState*)_data)[i];
+  assert(i >= 0 && i < _num_threads, "sanity check!");
+  return _per_thread_states[i];
 }
 
 void ParScanThreadStateSet::trace_promotion_failed(const YoungGCTracer* gc_tracer) {
-  for (int i = 0; i < length(); ++i) {
+  for (int i = 0; i < _num_threads; ++i) {
     if (thread_state(i).promotion_failed()) {
       gc_tracer->report_promotion_failed(thread_state(i).promotion_failed_info());
       thread_state(i).promotion_failed_info().reset();
@@ -363,7 +366,7 @@
 void ParScanThreadStateSet::reset(uint active_threads, bool promotion_failed) {
   _term.reset_for_reuse(active_threads);
   if (promotion_failed) {
-    for (int i = 0; i < length(); ++i) {
+    for (int i = 0; i < _num_threads; ++i) {
       thread_state(i).print_promotion_failure_size();
     }
   }
@@ -378,7 +381,7 @@
 }
 
 void ParScanThreadStateSet::reset_stats() {
-  for (int i = 0; i < length(); ++i) {
+  for (int i = 0; i < _num_threads; ++i) {
     thread_state(i).reset_stats();
   }
 }
@@ -401,7 +404,7 @@
 
   print_termination_stats_hdr(st);
 
-  for (int i = 0; i < length(); ++i) {
+  for (int i = 0; i < _num_threads; ++i) {
     const ParScanThreadState & pss = thread_state(i);
     const double elapsed_ms = pss.elapsed_time() * 1000.0;
     const double s_roots_ms = pss.strong_roots_time() * 1000.0;
@@ -429,7 +432,7 @@
   print_taskqueue_stats_hdr(st);
 
   TaskQueueStats totals;
-  for (int i = 0; i < length(); ++i) {
+  for (int i = 0; i < _num_threads; ++i) {
     const ParScanThreadState & pss = thread_state(i);
     const TaskQueueStats & stats = pss.taskqueue_stats();
     st->print("%3d ", i); stats.print(st); st->cr();
@@ -452,7 +455,7 @@
   // possible since this might otherwise become a bottleneck
   // to scaling. Should we add heavy-weight work into this
   // loop, consider parallelizing the loop into the worker threads.
-  for (int i = 0; i < length(); ++i) {
+  for (int i = 0; i < _num_threads; ++i) {
     ParScanThreadState& par_scan_state = thread_state(i);
 
     // Flush stats related to To-space PLAB activity and
--- a/hotspot/src/share/vm/interpreter/rewriter.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/interpreter/rewriter.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,11 +65,12 @@
   // Record limits of resolved reference map for constant pool cache indices
   record_map_limits();
 
-  guarantee((int)_cp_cache_map.length()-1 <= (int)((u2)-1),
+  guarantee((int) _cp_cache_map.length() - 1 <= (int) ((u2)-1),
             "all cp cache indexes fit in a u2");
 
-  if (saw_mh_symbol)
-    _method_handle_invokers.initialize(length, (int)0);
+  if (saw_mh_symbol) {
+    _method_handle_invokers.at_grow(length, 0);
+  }
 }
 
 // Unrewrite the bytecodes if an error occurs.
@@ -193,7 +194,7 @@
       assert(_pool->tag_at(cp_index).is_method(), "wrong index");
       // Determine whether this is a signature-polymorphic method.
       if (cp_index >= _method_handle_invokers.length())  return;
-      int status = _method_handle_invokers[cp_index];
+      int status = _method_handle_invokers.at(cp_index);
       assert(status >= -1 && status <= 1, "oob tri-state");
       if (status == 0) {
         if (_pool->klass_ref_at_noresolve(cp_index) == vmSymbols::java_lang_invoke_MethodHandle() &&
@@ -211,7 +212,7 @@
         } else {
           status = -1;
         }
-        _method_handle_invokers[cp_index] = status;
+        _method_handle_invokers.at(cp_index) = status;
       }
       // We use a special internal bytecode for such methods (if non-static).
       // The basic reason for this is that such methods need an extra "appendix" argument
@@ -287,7 +288,7 @@
       // add delta to each.
       int resolved_index = _patch_invokedynamic_refs->at(i);
       for (int entry = 0; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) {
-        assert(_invokedynamic_references_map[resolved_index+entry] == cache_index,
+        assert(_invokedynamic_references_map.at(resolved_index + entry) == cache_index,
              "should be the same index");
         _invokedynamic_references_map.at_put(resolved_index+entry,
                                              cache_index + delta);
@@ -520,7 +521,14 @@
 Rewriter::Rewriter(instanceKlassHandle klass, const constantPoolHandle& cpool, Array<Method*>* methods, TRAPS)
   : _klass(klass),
     _pool(cpool),
-    _methods(methods)
+    _methods(methods),
+    _cp_map(cpool->length()),
+    _cp_cache_map(cpool->length() / 2),
+    _reference_map(cpool->length()),
+    _resolved_references_map(cpool->length() / 2),
+    _invokedynamic_references_map(cpool->length() / 2),
+    _method_handle_invokers(cpool->length()),
+    _invokedynamic_cp_cache_map(cpool->length() / 4)
 {
 
   // Rewrite bytecodes - exception here exits.
--- a/hotspot/src/share/vm/interpreter/rewriter.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/interpreter/rewriter.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -37,13 +37,13 @@
   instanceKlassHandle _klass;
   constantPoolHandle  _pool;
   Array<Method*>*     _methods;
-  intArray            _cp_map;
-  intStack            _cp_cache_map;        // for Methodref, Fieldref,
-                                            // InterfaceMethodref and InvokeDynamic
-  intArray            _reference_map;       // maps from cp index to resolved_refs index (or -1)
-  intStack            _resolved_references_map;    // for strings, methodHandle, methodType
-  intStack            _invokedynamic_references_map; // for invokedynamic resolved refs
-  intArray            _method_handle_invokers;
+  GrowableArray<int>  _cp_map;
+  GrowableArray<int>  _cp_cache_map;  // for Methodref, Fieldref,
+                                      // InterfaceMethodref and InvokeDynamic
+  GrowableArray<int>  _reference_map; // maps from cp index to resolved_refs index (or -1)
+  GrowableArray<int>  _resolved_references_map; // for strings, methodHandle, methodType
+  GrowableArray<int>  _invokedynamic_references_map; // for invokedynamic resolved refs
+  GrowableArray<int>  _method_handle_invokers;
   int                 _resolved_reference_limit;
 
   // For mapping invokedynamic bytecodes, which are discovered during method
@@ -51,28 +51,31 @@
   // If there are any invokespecial/InterfaceMethodref special case bytecodes,
   // these entries are added before invokedynamic entries so that the
   // invokespecial bytecode 16 bit index doesn't overflow.
-  intStack            _invokedynamic_cp_cache_map;
+  GrowableArray<int>      _invokedynamic_cp_cache_map;
 
   // For patching.
   GrowableArray<address>* _patch_invokedynamic_bcps;
   GrowableArray<int>*     _patch_invokedynamic_refs;
 
   void init_maps(int length) {
-    _cp_map.initialize(length, -1);
-    // Choose an initial value large enough that we don't get frequent
-    // calls to grow().
-    _cp_cache_map.initialize(length/2);
+    _cp_map.trunc_to(0);
+    _cp_map.at_grow(length, -1);
+
+    _cp_cache_map.trunc_to(0);
     // Also cache resolved objects, in another different cache.
-    _reference_map.initialize(length, -1);
-    _resolved_references_map.initialize(length/2);
-    _invokedynamic_references_map.initialize(length/2);
+    _reference_map.trunc_to(0);
+    _reference_map.at_grow(length, -1);
+
+    _method_handle_invokers.trunc_to(0);
+    _resolved_references_map.trunc_to(0);
+    _invokedynamic_references_map.trunc_to(0);
     _resolved_reference_limit = -1;
     _first_iteration_cp_cache_limit = -1;
 
     // invokedynamic specific fields
-    _invokedynamic_cp_cache_map.initialize(length/4);
-    _patch_invokedynamic_bcps = new GrowableArray<address>(length/4);
-    _patch_invokedynamic_refs = new GrowableArray<int>(length/4);
+    _invokedynamic_cp_cache_map.trunc_to(0);
+    _patch_invokedynamic_bcps = new GrowableArray<address>(length / 4);
+    _patch_invokedynamic_refs = new GrowableArray<int>(length / 4);
   }
 
   int _first_iteration_cp_cache_limit;
@@ -90,10 +93,10 @@
     return _cp_cache_map.length() - _first_iteration_cp_cache_limit;
   }
 
-  int  cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map[i]; }
-  bool has_cp_cache(int i) { return (uint)i < (uint)_cp_map.length() && _cp_map[i] >= 0; }
+  int  cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map.at(i); }
+  bool has_cp_cache(int i) { return (uint) i < (uint) _cp_map.length() && _cp_map.at(i) >= 0; }
 
-  int add_map_entry(int cp_index, intArray* cp_map, intStack* cp_cache_map) {
+  int add_map_entry(int cp_index, GrowableArray<int>* cp_map, GrowableArray<int>* cp_cache_map) {
     assert(cp_map->at(cp_index) == -1, "not twice on same cp_index");
     int cache_index = cp_cache_map->append(cp_index);
     cp_map->at_put(cp_index, cache_index);
@@ -121,7 +124,7 @@
   }
 
   int invokedynamic_cp_cache_entry_pool_index(int cache_index) {
-    int cp_index = _invokedynamic_cp_cache_map[cache_index];
+    int cp_index = _invokedynamic_cp_cache_map.at(cache_index);
     return cp_index;
   }
 
@@ -131,9 +134,9 @@
     assert(_first_iteration_cp_cache_limit >= 0, "add these special cache entries after first iteration");
     // Don't add InterfaceMethodref if it already exists at the end.
     for (int i = _first_iteration_cp_cache_limit; i < _cp_cache_map.length(); i++) {
-     if (cp_cache_entry_pool_index(i) == cp_index) {
-       return i;
-     }
+      if (cp_cache_entry_pool_index(i) == cp_index) {
+        return i;
+      }
     }
     int cache_index = _cp_cache_map.append(cp_index);
     assert(cache_index >= _first_iteration_cp_cache_limit, "");
@@ -144,10 +147,10 @@
 
   int  cp_entry_to_resolved_references(int cp_index) const {
     assert(has_entry_in_resolved_references(cp_index), "oob");
-    return _reference_map[cp_index];
+    return _reference_map.at(cp_index);
   }
   bool has_entry_in_resolved_references(int cp_index) const {
-    return (uint)cp_index < (uint)_reference_map.length() && _reference_map[cp_index] >= 0;
+    return (uint) cp_index < (uint) _reference_map.length() && _reference_map.at(cp_index) >= 0;
   }
 
   // add a new entry to the resolved_references map
@@ -174,13 +177,13 @@
   }
 
   int resolved_references_entry_to_pool_index(int ref_index) {
-    int cp_index = _resolved_references_map[ref_index];
+    int cp_index = _resolved_references_map.at(ref_index);
     return cp_index;
   }
 
   // Access the contents of _cp_cache_map to determine CP cache layout.
   int cp_cache_entry_pool_index(int cache_index) {
-    int cp_index = _cp_cache_map[cache_index];
+    int cp_index = _cp_cache_map.at(cache_index);
     return cp_index;
   }
 
--- a/hotspot/src/share/vm/oops/cpCache.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/oops/cpCache.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -568,7 +568,7 @@
                                    const intArray& invokedynamic_references_map) {
   for (int i = 0; i < inverse_index_map.length(); i++) {
     ConstantPoolCacheEntry* e = entry_at(i);
-    int original_index = inverse_index_map[i];
+    int original_index = inverse_index_map.at(i);
     e->initialize_entry(original_index);
     assert(entry_at(i) == e, "sanity");
   }
@@ -578,19 +578,19 @@
   for (int i = 0; i < invokedynamic_inverse_index_map.length(); i++) {
     int offset = i + invokedynamic_offset;
     ConstantPoolCacheEntry* e = entry_at(offset);
-    int original_index = invokedynamic_inverse_index_map[i];
+    int original_index = invokedynamic_inverse_index_map.at(i);
     e->initialize_entry(original_index);
     assert(entry_at(offset) == e, "sanity");
   }
 
   for (int ref = 0; ref < invokedynamic_references_map.length(); ref++) {
-    const int cpci = invokedynamic_references_map[ref];
+    const int cpci = invokedynamic_references_map.at(ref);
     if (cpci >= 0) {
 #ifdef ASSERT
       // invokedynamic and invokehandle have more entries; check if they
       // all point to the same constant pool cache entry.
       for (int entry = 1; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) {
-        const int cpci_next = invokedynamic_references_map[ref + entry];
+        const int cpci_next = invokedynamic_references_map.at(ref + entry);
         assert(cpci == cpci_next, "%d == %d", cpci, cpci_next);
       }
 #endif
--- a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -693,7 +693,7 @@
   if (JvmtiExport::can_maintain_original_method_order()) {
     int index;
     int original_index;
-    intArray method_order(num_methods, 0);
+    intArray method_order(num_methods, num_methods, 0);
 
     // invert the method order mapping
     for (index = 0; index < num_methods; index++) {
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1447,12 +1447,12 @@
 
   ResourceMark rm(THREAD);
   _index_map_count = 0;
-  _index_map_p = new intArray(scratch_cp->length(), -1);
+  _index_map_p = new intArray(scratch_cp->length(), scratch_cp->length(), -1);
 
   _operands_cur_length = ConstantPool::operand_array_length(old_cp->operands());
   _operands_index_map_count = 0;
-  _operands_index_map_p = new intArray(
-    ConstantPool::operand_array_length(scratch_cp->operands()), -1);
+  int operands_index_map_len = ConstantPool::operand_array_length(scratch_cp->operands());
+  _operands_index_map_p = new intArray(operands_index_map_len, operands_index_map_len, -1);
 
   // reference to the cp holder is needed for copy_operands()
   merge_cp->set_pool_holder(scratch_class());
--- a/hotspot/src/share/vm/utilities/array.cpp	Mon Apr 11 21:42:55 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "memory/resourceArea.hpp"
-#include "runtime/thread.inline.hpp"
-#include "utilities/array.hpp"
-
-
-#ifdef ASSERT
-void ResourceArray::init_nesting() {
-  _nesting = Thread::current()->resource_area()->nesting();
-}
-#endif
-
-
-void ResourceArray::sort(size_t esize, ftype f) {
-  if (!is_empty()) qsort(_data, length(), esize, f);
-}
-template <MEMFLAGS F> void CHeapArray<F>::sort(size_t esize, ftype f) {
-  if (!is_empty()) qsort(_data, length(), esize, f);
-}
-
-
-void ResourceArray::expand(size_t esize, int i, int& size) {
-  // make sure we are expanding within the original resource mark
-  assert(
-    _nesting == Thread::current()->resource_area()->nesting(),
-    "allocating outside original resource mark"
-  );
-  // determine new size
-  if (size == 0) size = 4; // prevent endless loop
-  while (i >= size) size *= 2;
-  // allocate and initialize new data section
-  void* data = resource_allocate_bytes(esize * size);
-  memcpy(data, _data, esize * length());
-  _data = data;
-}
-
-
-template <MEMFLAGS F> void CHeapArray<F>::expand(size_t esize, int i, int& size) {
-  // determine new size
-  if (size == 0) size = 4; // prevent endless loop
-  while (i >= size) size *= 2;
-  // allocate and initialize new data section
-  void* data = NEW_C_HEAP_ARRAY(char*, esize * size, F);
-  memcpy(data, _data, esize * length());
-  FREE_C_HEAP_ARRAY(char*, _data);
-  _data = data;
-}
-
-
-void ResourceArray::remove_at(size_t esize, int i) {
-  assert(0 <= i && i < length(), "index out of bounds");
-  _length--;
-  void* dst = (char*)_data + i*esize;
-  void* src = (char*)dst + esize;
-  size_t cnt = (length() - i)*esize;
-  memmove(dst, src, cnt);
-}
-
-template <MEMFLAGS F> void CHeapArray<F>::remove_at(size_t esize, int i) {
-  assert(0 <= i && i < length(), "index out of bounds");
-  _length--;
-  void* dst = (char*)_data + i*esize;
-  void* src = (char*)dst + esize;
-  size_t cnt = (length() - i)*esize;
-  memmove(dst, src, cnt);
-}
--- a/hotspot/src/share/vm/utilities/array.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/utilities/array.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,273 +30,11 @@
 #include "memory/metaspace.hpp"
 #include "runtime/orderAccess.hpp"
 
-// correct linkage required to compile w/o warnings
-// (must be on file level - cannot be local)
-extern "C" { typedef int (*ftype)(const void*, const void*); }
-
-
-class ResourceArray: public ResourceObj {
- protected:
-  int   _length;                                 // the number of array elements
-  void* _data;                                   // the array memory
-#ifdef ASSERT
-  int   _nesting;                                // the resource area nesting level
-#endif
-
-  // creation
-  ResourceArray() {
-    _length  = 0;
-    _data    = NULL;
-    DEBUG_ONLY(init_nesting();)
-    // client may call initialize, at most once
-  }
-
-
-  ResourceArray(size_t esize, int length) {
-    DEBUG_ONLY(_data = NULL);
-    initialize(esize, length);
-  }
-
-  void initialize(size_t esize, int length) {
-    assert(length >= 0, "illegal length");
-    assert(StressRewriter || _data == NULL, "must be new object");
-    _length  = length;
-    _data    = resource_allocate_bytes(esize * length);
-    DEBUG_ONLY(init_nesting();)
-  }
-
-#ifdef ASSERT
-  void init_nesting();
-#endif
-
-  // helper functions
-  void sort     (size_t esize, ftype f);         // sort the array
-  void expand   (size_t esize, int i, int& size);// expand the array to include slot i
-  void remove_at(size_t esize, int i);           // remove the element in slot i
-
- public:
-  // standard operations
-  int  length() const                            { return _length; }
-  bool is_empty() const                          { return length() == 0; }
-};
-
-
-template <MEMFLAGS F>class CHeapArray: public CHeapObj<F> {
- protected:
-  int   _length;                                 // the number of array elements
-  void* _data;                                   // the array memory
-
-  // creation
-  CHeapArray() {
-    _length  = 0;
-    _data    = NULL;
-  }
-
-
-  CHeapArray(size_t esize, int length) {
-    assert(length >= 0, "illegal length");
-    _length  = length;
-    _data    = (void*) NEW_C_HEAP_ARRAY(char *, esize * length, F);
-  }
-
-  void initialize(size_t esize, int length) {
-    // In debug set array to 0?
-  }
-
-#ifdef ASSERT
-  void init_nesting();
-#endif
-
-  // helper functions
-  void sort     (size_t esize, ftype f);         // sort the array
-  void expand   (size_t esize, int i, int& size);// expand the array to include slot i
-  void remove_at(size_t esize, int i);           // remove the element in slot i
-
- public:
-  // standard operations
-  int  length() const                            { return _length; }
-  bool is_empty() const                          { return length() == 0; }
-};
-
-#define define_generic_array(array_name,element_type, base_class)                        \
-  class array_name: public base_class {                                                  \
-   protected:                                                                            \
-    typedef element_type etype;                                                          \
-    enum { esize = sizeof(etype) };                                                      \
-                                                                                         \
-    void base_remove_at(size_t size, int i) { base_class::remove_at(size, i); }          \
-                                                                                         \
-   public:                                                                               \
-    /* creation */                                                                       \
-    array_name() : base_class()                       {}                                 \
-    explicit array_name(const int length) : base_class(esize, length) {}                          \
-    array_name(const int length, const etype fx)      { initialize(length, fx); }        \
-    void initialize(const int length)     { base_class::initialize(esize, length); }     \
-    void initialize(const int length, const etype fx) {                                  \
-      initialize(length);                                                                \
-      for (int i = 0; i < length; i++) ((etype*)_data)[i] = fx;                          \
-    }                                                                                    \
-                                                                                         \
-    /* standard operations */                                                            \
-    etype& operator [] (const int i) const {                                             \
-      assert(0 <= i && i < length(), "index out of bounds");                             \
-      return ((etype*)_data)[i];                                                         \
-    }                                                                                    \
-                                                                                         \
-    int index_of(const etype x) const {                                                  \
-      int i = length();                                                                  \
-      while (i-- > 0 && ((etype*)_data)[i] != x) ;                                       \
-      /* i < 0 || ((etype*)_data)_data[i] == x */                                        \
-      return i;                                                                          \
-    }                                                                                    \
-                                                                                         \
-    void sort(int f(etype*, etype*))             { base_class::sort(esize, (ftype)f); }  \
-    bool contains(const etype x) const           { return index_of(x) >= 0; }            \
-                                                                                         \
-    /* deprecated operations - for compatibility with GrowableArray only */              \
-    etype  at(const int i) const                 { return (*this)[i]; }                  \
-    void   at_put(const int i, const etype x)    { (*this)[i] = x; }                     \
-    etype* adr_at(const int i)                   { return &(*this)[i]; }                 \
-    int    find(const etype x)                   { return index_of(x); }                 \
-  };                                                                                     \
-
-
-#define define_array(array_name,element_type)                                            \
-  define_generic_array(array_name, element_type, ResourceArray)
-
-
-#define define_stack(stack_name,array_name)                                              \
-  class stack_name: public array_name {                                                  \
-   protected:                                                                            \
-    int _size;                                                                           \
-                                                                                         \
-    void grow(const int i, const etype fx) {                                             \
-      assert(i >= length(), "index too small");                                          \
-      if (i >= size()) expand(esize, i, _size);                                          \
-      for (int j = length(); j <= i; j++) ((etype*)_data)[j] = fx;                       \
-      _length = i+1;                                                                     \
-    }                                                                                    \
-                                                                                         \
-   public:                                                                               \
-    /* creation */                                                                       \
-    stack_name() : array_name()                     { _size = 0; }                       \
-    stack_name(const int size)                      { initialize(size); }                \
-    stack_name(const int size, const etype fx)      { initialize(size, fx); }            \
-    void initialize(const int size, const etype fx) {                                    \
-      _size = size;                                                                      \
-      array_name::initialize(size, fx);                                                  \
-      /* _length == size, allocation and size are the same */                            \
-    }                                                                                    \
-    void initialize(const int size) {                                                    \
-      _size = size;                                                                      \
-      array_name::initialize(size);                                                      \
-      _length = 0;          /* reset length to zero; _size records the allocation */     \
-    }                                                                                    \
-                                                                                         \
-    /* standard operations */                                                            \
-    int size() const                             { return _size; }                       \
-                                                                                         \
-    int push(const etype x) {                                                            \
-      int len = length();                                                                \
-      if (len >= size()) expand(esize, len, _size);                                      \
-      ((etype*)_data)[len] = x;                                                          \
-      _length = len+1;                                                                   \
-      return len;                                                                        \
-    }                                                                                    \
-                                                                                         \
-    etype pop() {                                                                        \
-      assert(!is_empty(), "stack is empty");                                             \
-      return ((etype*)_data)[--_length];                                                 \
-    }                                                                                    \
-                                                                                         \
-    etype top() const {                                                                  \
-      assert(!is_empty(), "stack is empty");                                             \
-      return ((etype*)_data)[length() - 1];                                              \
-    }                                                                                    \
-                                                                                         \
-    void push_all(const stack_name* stack) {                                             \
-      const int l = stack->length();                                                     \
-      for (int i = 0; i < l; i++) push(((etype*)(stack->_data))[i]);                     \
-    }                                                                                    \
-                                                                                         \
-    etype at_grow(const int i, const etype fx) {                                         \
-      if (i >= length()) grow(i, fx);                                                    \
-      return ((etype*)_data)[i];                                                         \
-    }                                                                                    \
-                                                                                         \
-    void at_put_grow(const int i, const etype x, const etype fx) {                       \
-      if (i >= length()) grow(i, fx);                                                    \
-      ((etype*)_data)[i] = x;                                                            \
-    }                                                                                    \
-                                                                                         \
-    void truncate(const int length) {                                                    \
-      assert(0 <= length && length <= this->length(), "illegal length");                 \
-      _length = length;                                                                  \
-    }                                                                                    \
-                                                                                         \
-    void remove_at(int i)                        { base_remove_at(esize, i); }           \
-    void remove(etype x)                         { remove_at(index_of(x)); }             \
-                                                                                         \
-    /* inserts the given element before the element at index i */                        \
-    void insert_before(const int i, const etype el)  {                                   \
-      int len = length();                                                                \
-      int new_length = len + 1;                                                          \
-      if (new_length >= size()) expand(esize, new_length, _size);                        \
-      for (int j = len - 1; j >= i; j--) {                                               \
-        ((etype*)_data)[j + 1] = ((etype*)_data)[j];                                     \
-      }                                                                                  \
-      _length = new_length;                                                              \
-      at_put(i, el);                                                                     \
-    }                                                                                    \
-                                                                                         \
-    /* inserts contents of the given stack before the element at index i */              \
-    void insert_before(const int i, const stack_name *st) {                              \
-      if (st->length() == 0) return;                                                     \
-      int len = length();                                                                \
-      int st_len = st->length();                                                         \
-      int new_length = len + st_len;                                                     \
-      if (new_length >= size()) expand(esize, new_length, _size);                        \
-      int j;                                                                             \
-      for (j = len - 1; j >= i; j--) {                                                   \
-        ((etype*)_data)[j + st_len] = ((etype*)_data)[j];                                \
-      }                                                                                  \
-      for (j = 0; j < st_len; j++) {                                                     \
-        ((etype*)_data)[i + j] = ((etype*)st->_data)[j];                                 \
-      }                                                                                  \
-      _length = new_length;                                                              \
-    }                                                                                    \
-                                                                                         \
-    /* deprecated operations - for compatibility with GrowableArray only */              \
-    int  capacity() const                        { return size(); }                      \
-    void clear()                                 { truncate(0); }                        \
-    void trunc_to(const int length)              { truncate(length); }                   \
-    int  append(const etype x)                   { return push(x); }                     \
-    void appendAll(const stack_name* stack)      { push_all(stack); }                    \
-    etype last() const                           { return top(); }                       \
-  };                                                                                     \
-
-
-#define define_resource_list(element_type)                                               \
-  define_generic_array(element_type##Array, element_type, ResourceArray)                 \
-  define_stack(element_type##List, element_type##Array)
-
-#define define_resource_pointer_list(element_type)                                       \
-  define_generic_array(element_type##Array, element_type *, ResourceArray)               \
-  define_stack(element_type##List, element_type##Array)
-
-#define define_c_heap_list(element_type)                                                 \
-  define_generic_array(element_type##Array, element_type, CHeapArray)                    \
-  define_stack(element_type##List, element_type##Array)
-
-#define define_c_heap_pointer_list(element_type)                                         \
-  define_generic_array(element_type##Array, element_type *, CHeapArray)                  \
-  define_stack(element_type##List, element_type##Array)
-
-
 // Arrays for basic types
-
-define_array(boolArray, bool)          define_stack(boolStack, boolArray)
-define_array(intArray , int )          define_stack(intStack , intArray )
+typedef GrowableArray<int> intArray;
+typedef GrowableArray<int> intStack;
+typedef GrowableArray<bool> boolArray;
+typedef GrowableArray<bool> boolStack;
 
 // Array for metadata allocation
 
--- a/hotspot/src/share/vm/utilities/growableArray.hpp	Mon Apr 11 21:42:55 2016 +0300
+++ b/hotspot/src/share/vm/utilities/growableArray.hpp	Wed Apr 06 18:51:03 2016 +0300
@@ -250,6 +250,10 @@
     return _data[_len-1];
   }
 
+  E last() const {
+    return top();
+  }
+
   GrowableArrayIterator<E> begin() const {
     return GrowableArrayIterator<E>(this, 0);
   }
@@ -363,6 +367,24 @@
     _data[idx] = elem;
   }
 
+  void insert_before(const int idx, const GrowableArray<E>* array) {
+    assert(0 <= idx && idx <= _len, "illegal index");
+    check_nesting();
+    int array_len = array->length();
+    int new_len = _len + array_len;
+    if (new_len >= _max) grow(new_len);
+
+    for (int j = _len - 1; j >= idx; j--) {
+      _data[j + array_len] = _data[j];
+    }
+
+    for (int j = 0; j < array_len; j++) {
+      _data[idx + j] = array->_data[j];
+    }
+
+    _len += array_len;
+  }
+
   void appendAll(const GrowableArray<E>* l) {
     for (int i = 0; i < l->_len; i++) {
       raw_at_put_grow(_len, l->_data[i], E());