87 }
88
89 void CompilerDirectives::finalize(outputStream* st) {
90 if (_c1_store != NULL) {
91 _c1_store->finalize(st);
92 }
93 if (_c2_store != NULL) {
94 _c2_store->finalize(st);
95 }
96 }
97
98 void DirectiveSet::finalize(outputStream* st) {
99 // Check LogOption and warn
100 if (LogOption && !LogCompilation) {
101 st->print_cr("Warning: +LogCompilation must be set to enable compilation logging from directives");
102 }
103
104 // if any flag has been modified - set directive as enabled
105 // unless it already has been explicitly set.
106 if (!_modified[EnableIndex]) {
107 if (_inlinematchers != NULL) {
108 EnableOption = true;
109 return;
110 }
111 int i;
112 for (i = 0; i < number_of_flags; i++) {
113 if (_modified[i]) {
114 EnableOption = true;
115 return;
116 }
117 }
118 }
119 }
120
121 CompilerDirectives* CompilerDirectives::next() {
122 return _next;
123 }
124
125 bool CompilerDirectives::match(methodHandle method) {
126 if (is_default_directive()) {
127 return true;
128 }
129 if (method == NULL) {
130 return false;
131 }
132 if (_match->match(method)) {
133 return true;
134 }
135 return false;
136 }
137
138 bool CompilerDirectives::add_match(char* str, const char*& error_msg) {
139 BasicMatcher* bm = BasicMatcher::parse_method_pattern(str, error_msg);
140 if (bm == NULL) {
352 } else {
353 assert(error_msg != NULL, "Error message must be set");
354 return false;
355 }
356 }
357
358 void DirectiveSet::append_inline(InlineMatcher* m) {
359 if (_inlinematchers == NULL) {
360 _inlinematchers = m;
361 return;
362 }
363 InlineMatcher* tmp = _inlinematchers;
364 while (tmp->next() != NULL) {
365 tmp = tmp->next();
366 }
367 tmp->set_next(m);
368 }
369
370 void DirectiveSet::print_inline(outputStream* st) {
371 if (_inlinematchers == NULL) {
372 st->print_cr(" inline: -");
373 } else {
374 st->print(" inline: ");
375 _inlinematchers->print(st);
376 InlineMatcher* tmp = _inlinematchers->next();
377 while (tmp != NULL) {
378 st->print(", ");
379 tmp->print(st);
380 tmp = tmp->next();
381 }
382 st->cr();
383 }
384 }
385
386 bool DirectiveSet::is_intrinsic_disabled(methodHandle method) {
387 vmIntrinsics::ID id = method->intrinsic_id();
388 assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
389
390 ResourceMark rm;
391
392 // Create a copy of the string that contains the list of disabled
424 compilerdirectives_c2_flags(copy_members_definition)
425 compilerdirectives_c1_flags(copy_members_definition)
426
427 // Create a local copy of the DisableIntrinsicOption.
428 assert(src->DisableIntrinsicOption != NULL, "");
429 size_t len = strlen(src->DisableIntrinsicOption) + 1;
430 char* s = NEW_C_HEAP_ARRAY(char, len, mtCompiler);
431 strncpy(s, src->DisableIntrinsicOption, len);
432 assert(s[len-1] == '\0', "");
433 set->DisableIntrinsicOption = s;
434 return set;
435 }
436
437 // Create a new dirstack and push a default directive
438 void DirectivesStack::init() {
439 CompilerDirectives* _default_directives = new CompilerDirectives();
440 char str[] = "*.*";
441 const char* error_msg = NULL;
442 _default_directives->add_match(str, error_msg);
443 #ifdef COMPILER1
444 _default_directives->_c1_store->EnableOption = true;
445 #endif
446 #ifdef COMPILER2
447 _default_directives->_c2_store->EnableOption = true;
448 #endif
449 assert(error_msg == NULL, "Must succeed.");
450 push(_default_directives);
451 }
452
453 DirectiveSet* DirectivesStack::getDefaultDirective(AbstractCompiler* comp) {
454 MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
455
456 assert(_bottom != NULL, "Must never be empty");
457 _bottom->inc_refcount();
458 return _bottom->get_for(comp);
459 }
460
461 void DirectivesStack::push(CompilerDirectives* directive) {
462 MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
463
464 directive->inc_refcount();
465 if (_top == NULL) {
466 assert(_bottom == NULL, "There can only be one default directive");
467 _bottom = directive; // default directive, can never be removed.
475 void DirectivesStack::pop() {
476 MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
477 pop_inner();
478 }
479
480 void DirectivesStack::pop_inner() {
481 assert(DirectivesStack_lock->owned_by_self(), "");
482
483 if (_top->next() == NULL) {
484 return; // Do nothing - don't allow an empty stack
485 }
486 CompilerDirectives* tmp = _top;
487 _top = _top->next();
488 _depth--;
489
490 DirectivesStack::release(tmp);
491 }
492
493 bool DirectivesStack::check_capacity(int request_size, outputStream* st) {
494 if ((request_size + _depth) > CompilerDirectivesLimit) {
495 st->print_cr("Could not add %i more directives. Currently %i/%i directives.", request_size, _depth, CompilerDirectivesLimit);
496 return false;
497 }
498 return true;
499 }
500
501 void DirectivesStack::clear() {
502 // holding the lock during the whole operation ensuring consistent result
503 MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
504 while (_top->next() != NULL) {
505 pop_inner();
506 }
507 }
508
509 void DirectivesStack::print(outputStream* st) {
510 MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
511 CompilerDirectives* tmp = _top;
512 while (tmp != NULL) {
513 tmp->print(st);
514 tmp = tmp->next();
515 st->cr();
|
87 }
88
89 void CompilerDirectives::finalize(outputStream* st) {
90 if (_c1_store != NULL) {
91 _c1_store->finalize(st);
92 }
93 if (_c2_store != NULL) {
94 _c2_store->finalize(st);
95 }
96 }
97
98 void DirectiveSet::finalize(outputStream* st) {
99 // Check LogOption and warn
100 if (LogOption && !LogCompilation) {
101 st->print_cr("Warning: +LogCompilation must be set to enable compilation logging from directives");
102 }
103
104 // if any flag has been modified - set directive as enabled
105 // unless it already has been explicitly set.
106 if (!_modified[EnableIndex]) {
107 EnableOption = false;
108 if (_inlinematchers != NULL) {
109 EnableOption = true;
110 return;
111 }
112 int i;
113 for (i = 0; i < number_of_flags; i++) {
114 if (_modified[i]) {
115 EnableOption = true;
116 return;
117 }
118 }
119 }
120 }
121
122 bool DirectiveSet::is_default_set() {
123 if (_directive != NULL) {
124 return _directive->is_default_directive();
125 } else {
126 return false;
127 }
128 }
129
130 CompilerDirectives* CompilerDirectives::next() {
131 return _next;
132 }
133
134 bool CompilerDirectives::match(methodHandle method) {
135 if (is_default_directive()) {
136 return true;
137 }
138 if (method == NULL) {
139 return false;
140 }
141 if (_match->match(method)) {
142 return true;
143 }
144 return false;
145 }
146
147 bool CompilerDirectives::add_match(char* str, const char*& error_msg) {
148 BasicMatcher* bm = BasicMatcher::parse_method_pattern(str, error_msg);
149 if (bm == NULL) {
361 } else {
362 assert(error_msg != NULL, "Error message must be set");
363 return false;
364 }
365 }
366
367 void DirectiveSet::append_inline(InlineMatcher* m) {
368 if (_inlinematchers == NULL) {
369 _inlinematchers = m;
370 return;
371 }
372 InlineMatcher* tmp = _inlinematchers;
373 while (tmp->next() != NULL) {
374 tmp = tmp->next();
375 }
376 tmp->set_next(m);
377 }
378
379 void DirectiveSet::print_inline(outputStream* st) {
380 if (_inlinematchers == NULL) {
381 st->print(" No inline rules in directive.");
382 CompilerOracle::print_inlinecommands(st);
383 } else {
384 st->print(" inline: ");
385 _inlinematchers->print(st);
386 InlineMatcher* tmp = _inlinematchers->next();
387 while (tmp != NULL) {
388 st->print(", ");
389 tmp->print(st);
390 tmp = tmp->next();
391 }
392 st->cr();
393 }
394 }
395
396 bool DirectiveSet::is_intrinsic_disabled(methodHandle method) {
397 vmIntrinsics::ID id = method->intrinsic_id();
398 assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
399
400 ResourceMark rm;
401
402 // Create a copy of the string that contains the list of disabled
434 compilerdirectives_c2_flags(copy_members_definition)
435 compilerdirectives_c1_flags(copy_members_definition)
436
437 // Create a local copy of the DisableIntrinsicOption.
438 assert(src->DisableIntrinsicOption != NULL, "");
439 size_t len = strlen(src->DisableIntrinsicOption) + 1;
440 char* s = NEW_C_HEAP_ARRAY(char, len, mtCompiler);
441 strncpy(s, src->DisableIntrinsicOption, len);
442 assert(s[len-1] == '\0', "");
443 set->DisableIntrinsicOption = s;
444 return set;
445 }
446
447 // Create a new dirstack and push a default directive
448 void DirectivesStack::init() {
449 CompilerDirectives* _default_directives = new CompilerDirectives();
450 char str[] = "*.*";
451 const char* error_msg = NULL;
452 _default_directives->add_match(str, error_msg);
453 #ifdef COMPILER1
454 assert(_default_directives->_c1_store->EnableOption, "Default must be active");
455 #endif
456 #ifdef COMPILER2
457 assert(_default_directives->_c2_store->EnableOption, "Default must be active");
458 #endif
459 assert(error_msg == NULL, "Must succeed.");
460 push(_default_directives);
461 }
462
463 DirectiveSet* DirectivesStack::getDefaultDirective(AbstractCompiler* comp) {
464 MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
465
466 assert(_bottom != NULL, "Must never be empty");
467 _bottom->inc_refcount();
468 return _bottom->get_for(comp);
469 }
470
471 void DirectivesStack::push(CompilerDirectives* directive) {
472 MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
473
474 directive->inc_refcount();
475 if (_top == NULL) {
476 assert(_bottom == NULL, "There can only be one default directive");
477 _bottom = directive; // default directive, can never be removed.
485 void DirectivesStack::pop() {
486 MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
487 pop_inner();
488 }
489
490 void DirectivesStack::pop_inner() {
491 assert(DirectivesStack_lock->owned_by_self(), "");
492
493 if (_top->next() == NULL) {
494 return; // Do nothing - don't allow an empty stack
495 }
496 CompilerDirectives* tmp = _top;
497 _top = _top->next();
498 _depth--;
499
500 DirectivesStack::release(tmp);
501 }
502
503 bool DirectivesStack::check_capacity(int request_size, outputStream* st) {
504 if ((request_size + _depth) > CompilerDirectivesLimit) {
505 st->print_cr("Could not add %i more directives. Currently %i of %i directives.", request_size, _depth, CompilerDirectivesLimit);
506 return false;
507 }
508 return true;
509 }
510
511 void DirectivesStack::clear() {
512 // holding the lock during the whole operation ensuring consistent result
513 MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
514 while (_top->next() != NULL) {
515 pop_inner();
516 }
517 }
518
519 void DirectivesStack::print(outputStream* st) {
520 MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
521 CompilerDirectives* tmp = _top;
522 while (tmp != NULL) {
523 tmp->print(st);
524 tmp = tmp->next();
525 st->cr();
|