00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 class MethodInterval: public ResourceObj {
00030 protected:
00031 MethodInterval* _parent;
00032 methodOop _method;
00033 int _begin_bci;
00034 int _end_bci;
00035 bool _in_prim_failure;
00036 #ifdef DELTA_COMPILER
00037 IntervalInfo* _info;
00038 #endif
00039
00040 void initialize(methodOop method, MethodInterval* parent, int begin_bci, int end_bci, bool failBlock);
00041 void set_end_bci(int bci) { _end_bci = bci; }
00042
00043
00044 MethodInterval(methodOop method, MethodInterval* parent);
00045 MethodInterval(methodOop method, MethodInterval* parent,
00046 int begin_bci, int end_bci = -1, bool failureBlock = false);
00047 friend class MethodIntervalFactory;
00048
00049 public:
00050
00051 bool includes(int bci) const { return begin_bci() <= bci && bci < end_bci(); }
00052
00053
00054 methodOop method() const { return _method; }
00055 int begin_bci() const { return _begin_bci; }
00056 int end_bci() const { return _end_bci; }
00057 MethodInterval* parent() const { return _parent; }
00058
00059
00060 bool in_prim_failure_block() const { return _in_prim_failure; }
00061 void set_prim_failure(bool f) { _in_prim_failure = f; }
00062
00063
00064 #ifdef DELTA_COMPILER
00065 IntervalInfo* info() const { return _info; }
00066 void set_info(IntervalInfo* i) { _info = i; }
00067 #endif
00068 };
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 class InlineSendNode: public MethodInterval {
00085 protected:
00086
00087 InlineSendNode(methodOop method, MethodInterval* parent, int begin_bci, int end_bci = -1);
00088
00089 public:
00090
00091 virtual symbolOop selector() const = 0;
00092 };
00093
00094
00095 class CondNode: public InlineSendNode {
00096 protected:
00097 MethodInterval* _expr_code;
00098
00099
00100 CondNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, int dest_offset);
00101
00102 public:
00103
00104 MethodInterval* expr_code() const { return _expr_code; }
00105
00106
00107 virtual bool is_and() const = 0;
00108 virtual bool is_or() const = 0;
00109 };
00110
00111
00112 class AndNode: public CondNode {
00113
00114 AndNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, int dest_offset);
00115 friend class MethodIntervalFactory;
00116
00117 public:
00118
00119 symbolOop selector() const;
00120 bool is_and() const { return true; }
00121 bool is_or() const { return false; }
00122 };
00123
00124
00125 class OrNode: public CondNode {
00126 protected:
00127
00128 OrNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, int dest_offset);
00129 friend class MethodIntervalFactory;
00130
00131 public:
00132
00133 symbolOop selector() const;
00134 bool is_and() const { return false; }
00135 bool is_or() const { return true; }
00136 };
00137
00138
00139 class WhileNode: public InlineSendNode {
00140 protected:
00141 bool _cond;
00142 MethodInterval* _expr_code;
00143 MethodInterval* _body_code;
00144
00145
00146 WhileNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, int cond_offset, int end_offset);
00147 friend class MethodIntervalFactory;
00148
00149 public:
00150
00151 MethodInterval* expr_code() const { return _expr_code; }
00152
00153 MethodInterval* body_code() const { return _body_code; }
00154
00155
00156 symbolOop selector() const;
00157 bool is_whileTrue() const { return _cond; }
00158 bool is_whileFalse() const { return !_cond; }
00159 };
00160
00161
00162 class IfNode: public InlineSendNode {
00163 protected:
00164 bool _cond;
00165 bool _ignore_else_while_printing;
00166 bool _produces_result;
00167 MethodInterval* _then_code;
00168 MethodInterval* _else_code;
00169
00170
00171 IfNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, bool cond, int else_offset, u_char structure);
00172 friend class MethodIntervalFactory;
00173
00174 public:
00175
00176 MethodInterval* then_code() const { return _then_code; }
00177
00178 MethodInterval* else_code() const { return _else_code; }
00179
00180
00181 symbolOop selector() const;
00182 bool is_ifTrue() const { return _cond; }
00183 bool is_ifFalse() const { return !_cond; }
00184 bool ignore_else_while_printing() const { return _ignore_else_while_printing; }
00185 bool produces_result() const { return _produces_result; }
00186 };
00187
00188
00189 class ExternalCallNode: public MethodInterval {
00190 protected:
00191 MethodInterval* _failure_code;
00192
00193
00194 ExternalCallNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci);
00195 ExternalCallNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, int end_offset);
00196
00197 public:
00198
00199 MethodInterval* failure_code() const { return _failure_code; }
00200 };
00201
00202
00203 class PrimitiveCallNode: public ExternalCallNode {
00204 protected:
00205 primitive_desc* _pdesc;
00206 bool _has_receiver;
00207 symbolOop _name;
00208
00209
00210 PrimitiveCallNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, bool has_receiver, symbolOop name, primitive_desc* pdesc);
00211 PrimitiveCallNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, bool has_receiver, symbolOop name, primitive_desc* pdesc, int end_offset);
00212 friend class MethodIntervalFactory;
00213
00214 public:
00215
00216 primitive_desc* pdesc() const { return _pdesc; }
00217 bool has_receiver() const { return _has_receiver; }
00218 symbolOop name() const { return _name; }
00219 int number_of_parameters() const;
00220 };
00221
00222
00223 class DLLCallNode: public ExternalCallNode {
00224 protected:
00225 symbolOop _dll_name;
00226 symbolOop _function_name;
00227 int _nofArgs;
00228 dll_func _function;
00229 bool _async;
00230
00231 void initialize(InterpretedDLL_Cache* cache);
00232
00233
00234 DLLCallNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, InterpretedDLL_Cache* cache);
00235 friend class MethodIntervalFactory;
00236
00237 public:
00238
00239 symbolOop dll_name() const { return _dll_name; }
00240 symbolOop function_name() const { return _function_name; }
00241 int nofArgs() const { return _nofArgs; }
00242 dll_func function() const { return _function; }
00243 bool async() const { return _async; }
00244 };
00245
00246
00247
00248
00249
00250
00251 enum AllocationType {
00252 tos_as_scope,
00253 context_as_scope
00254
00255 };
00256
00257 class MethodIterator;
00258
00259
00260
00261 class MethodClosure: ValueObj {
00262 private:
00263 methodOop _method;
00264 int _bci;
00265 int _next_bci;
00266 bool _aborting;
00267 bool _in_prim_failure;
00268 int _float0_index;
00269
00270 void set_method(methodOop method);
00271 void set_bci(int bci) { _bci = bci; }
00272 void set_next_bci(int next_bci) { _next_bci = next_bci; }
00273 int float_at(int index);
00274
00275 protected:
00276 MethodClosure();
00277
00278 virtual void abort() { _aborting = true; }
00279 virtual void un_abort() { _aborting = false; }
00280
00281 friend class MethodIterator;
00282
00283 public:
00284 int bci() const { return _bci; }
00285 int next_bci() const { return _next_bci; }
00286 methodOop method() const { return _method; }
00287 bool aborting() const { return _aborting; }
00288
00289
00290
00291
00292 virtual void if_node(IfNode* node) = 0;
00293 virtual void cond_node(CondNode* node) = 0;
00294 virtual void while_node(WhileNode* node) = 0;
00295 virtual void primitive_call_node(PrimitiveCallNode* node) = 0;
00296 virtual void dll_call_node(DLLCallNode* node) = 0;
00297
00298
00299 virtual bool in_prim_failure_block() const { return _in_prim_failure; }
00300 virtual void set_prim_failure(bool f) { _in_prim_failure = f; }
00301
00302 public:
00303
00304
00305 virtual void allocate_temporaries(int nofTemps) = 0;
00306
00307
00308 virtual void push_self() = 0;
00309 virtual void push_tos() = 0;
00310 virtual void push_literal(oop obj) = 0;
00311
00312
00313
00314
00315
00316
00317
00318 virtual void push_argument(int no) = 0;
00319 virtual void push_temporary(int no) = 0;
00320 virtual void push_temporary(int no, int context) = 0;
00321
00322 virtual void push_instVar(int offset) = 0;
00323 virtual void push_instVar_name(symbolOop name) = 0;
00324
00325 virtual void push_classVar(associationOop assoc) = 0;
00326 virtual void push_classVar_name(symbolOop name) = 0;
00327
00328 virtual void push_global(associationOop obj) = 0;
00329
00330 virtual void store_temporary(int no) = 0;
00331 virtual void store_temporary(int no, int context) = 0;
00332
00333 virtual void store_instVar(int offset) = 0;
00334 virtual void store_instVar_name(symbolOop name) = 0;
00335
00336 virtual void store_classVar(associationOop assoc) = 0;
00337 virtual void store_classVar_name(symbolOop name) = 0;
00338
00339 virtual void store_global(associationOop obj) = 0;
00340
00341 virtual void pop() = 0;
00342
00343
00344
00345 virtual void normal_send(InterpretedIC* ic) = 0;
00346 virtual void self_send (InterpretedIC* ic) = 0;
00347 virtual void super_send (InterpretedIC* ic) = 0;
00348
00349
00350 virtual void double_equal() = 0;
00351 virtual void double_not_equal() = 0;
00352
00353
00354 virtual void method_return(int nofArgs) = 0;
00355 virtual void nonlocal_return(int nofArgs) = 0;
00356
00357 virtual void allocate_closure(AllocationType type, int nofArgs, methodOop meth) = 0;
00358 virtual void allocate_context(int nofTemps, bool forMethod) = 0;
00359
00360
00361 virtual void set_self_via_context() = 0;
00362 virtual void copy_self_into_context() = 0;
00363 virtual void copy_argument_into_context(int argNo, int no) = 0;
00364
00365
00366 virtual void zap_scope() = 0;
00367
00368
00369 virtual void predict_prim_call(primitive_desc* pdesc, int failure_start) = 0;
00370
00371
00372 virtual void float_allocate(int nofFloatTemps, int nofFloatExprs) = 0;
00373 virtual void float_floatify(Floats::Function f, int fno) = 0;
00374 virtual void float_move(int fno, int from) = 0;
00375 virtual void float_set(int fno, doubleOop value) = 0;
00376 virtual void float_nullary(Floats::Function f, int fno) = 0;
00377 virtual void float_unary(Floats::Function f, int fno) = 0;
00378 virtual void float_binary(Floats::Function f, int fno) = 0;
00379 virtual void float_unaryToOop(Floats::Function f, int fno) = 0;
00380 virtual void float_binaryToOop(Floats::Function f, int fno) = 0;
00381 };
00382
00383 class CustomizedMethodClosure : public MethodClosure {
00384 public:
00385
00386 void push_instVar_name(symbolOop name);
00387 void store_instVar_name(symbolOop name);
00388
00389 void push_classVar_name(symbolOop name);
00390 void push_classVar(associationOop assoc);
00391
00392 void store_classVar_name(symbolOop name);
00393 void store_classVar(associationOop assoc);
00394 };
00395
00396
00397
00398
00399
00400 class SpecializedMethodClosure: public CustomizedMethodClosure {
00401 public:
00402 virtual void if_node(IfNode* node);
00403 virtual void cond_node(CondNode* node);
00404 virtual void while_node(WhileNode* node);
00405 virtual void primitive_call_node(PrimitiveCallNode* node);
00406 virtual void dll_call_node(DLLCallNode* node);
00407
00408 public:
00409
00410 virtual void instruction() {}
00411
00412 public:
00413 virtual void allocate_temporaries(int nofTemps) { instruction(); }
00414 virtual void push_self() { instruction(); }
00415 virtual void push_tos() { instruction(); }
00416 virtual void push_literal(oop obj) { instruction(); }
00417 virtual void push_argument(int no) { instruction(); }
00418 virtual void push_temporary(int no) { instruction(); }
00419 virtual void push_temporary(int no, int context) { instruction(); }
00420 virtual void push_instVar(int offset) { instruction(); }
00421 virtual void push_global(associationOop obj) { instruction(); }
00422 virtual void store_temporary(int no) { instruction(); }
00423 virtual void store_temporary(int no, int context) { instruction(); }
00424 virtual void store_instVar(int offset) { instruction(); }
00425 virtual void store_global(associationOop obj) { instruction(); }
00426 virtual void pop() { instruction(); }
00427 virtual void normal_send(InterpretedIC* ic) { instruction(); }
00428 virtual void self_send (InterpretedIC* ic) { instruction(); }
00429 virtual void super_send (InterpretedIC* ic) { instruction(); }
00430 virtual void double_equal() { instruction(); }
00431 virtual void double_not_equal() { instruction(); }
00432 virtual void method_return(int nofArgs) { instruction(); }
00433 virtual void nonlocal_return(int nofArgs) { instruction(); }
00434 virtual void allocate_closure(AllocationType type, int nofArgs, methodOop meth) { instruction(); }
00435 virtual void allocate_context(int nofTemps, bool forMethod) { instruction(); }
00436 virtual void set_self_via_context() { instruction(); }
00437 virtual void copy_self_into_context() { instruction(); }
00438 virtual void copy_argument_into_context(int argNo, int no) { instruction(); }
00439 virtual void zap_scope() { instruction(); }
00440 virtual void predict_prim_call(primitive_desc* pdesc, int failure_start) { instruction(); }
00441 virtual void float_allocate(int nofFloatTemps, int nofFloatExprs) { instruction(); }
00442 virtual void float_floatify(Floats::Function f, int fno) { instruction(); }
00443 virtual void float_move(int fno, int from) { instruction(); }
00444 virtual void float_set(int fno, doubleOop value) { instruction(); }
00445 virtual void float_nullary(Floats::Function f, int fno) { instruction(); }
00446 virtual void float_unary(Floats::Function f, int fno) { instruction(); }
00447 virtual void float_binary(Floats::Function f, int fno) { instruction(); }
00448 virtual void float_unaryToOop(Floats::Function f, int fno) { instruction(); }
00449 virtual void float_binaryToOop(Floats::Function f, int fno) { instruction(); }
00450 };
00451
00452
00453
00454 class AbstractMethodIntervalFactory : StackObj {
00455 public:
00456 virtual MethodInterval* new_MethodInterval(methodOop method, MethodInterval* parent) = 0;
00457 virtual MethodInterval* new_MethodInterval(methodOop method, MethodInterval* parent,
00458 int begin_bci, int end_bci = -1, bool failureBlock = false) = 0;
00459 virtual AndNode* new_AndNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, int dest_offset) = 0;
00460 virtual OrNode* new_OrNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, int dest_offset) = 0;
00461 virtual WhileNode* new_WhileNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, int cond_offset, int end_offset) = 0;
00462 virtual IfNode* new_IfNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, bool cond, int else_offset, u_char structure) = 0;
00463 virtual PrimitiveCallNode* new_PrimitiveCallNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, bool has_receiver, symbolOop name, primitive_desc* pdesc) = 0;
00464 virtual PrimitiveCallNode* new_PrimitiveCallNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, bool has_receiver, symbolOop name, primitive_desc* pdesc, int end_offset) = 0;
00465 virtual DLLCallNode* new_DLLCallNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, InterpretedDLL_Cache* cache) = 0;
00466 };
00467
00468
00469 class MethodIntervalFactory : public AbstractMethodIntervalFactory {
00470 public:
00471 MethodInterval* new_MethodInterval(methodOop method, MethodInterval* parent);
00472 MethodInterval* new_MethodInterval(methodOop method, MethodInterval* parent,
00473 int begin_bci, int end_bci = -1, bool failureBlock = false);
00474 AndNode* new_AndNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, int dest_offset);
00475 OrNode* new_OrNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, int dest_offset);
00476 WhileNode* new_WhileNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, int cond_offset, int end_offset);
00477 IfNode* new_IfNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, bool cond, int else_offset, u_char structure);
00478 PrimitiveCallNode* new_PrimitiveCallNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, bool has_receiver, symbolOop name, primitive_desc* pdesc);
00479 PrimitiveCallNode* new_PrimitiveCallNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, bool has_receiver, symbolOop name, primitive_desc* pdesc, int end_offset);
00480 DLLCallNode* new_DLLCallNode(methodOop method, MethodInterval* parent, int begin_bci, int next_bci, InterpretedDLL_Cache* cache);
00481 };
00482
00483
00484 class MethodIterator: StackObj {
00485 private:
00486 void dispatch(MethodClosure* blk);
00487 void unknown_code(u_char code);
00488 void should_never_encounter(u_char code);
00489 MethodInterval* _interval;
00490 static MethodIntervalFactory defaultFactory;
00491 public:
00492 static AbstractMethodIntervalFactory* factory;
00493
00494 MethodIterator(methodOop m, MethodClosure* blk, AbstractMethodIntervalFactory* f = &defaultFactory);
00495 MethodIterator(MethodInterval* interval, MethodClosure* blk, AbstractMethodIntervalFactory* f = &defaultFactory);
00496 MethodInterval* interval() const { return _interval; }
00497 };