278 279 // This constant used to initialize _out may be any non-null value. 280 // The value NULL is reserved for the top node only. 281 #define NO_OUT_ARRAY ((Node**)-1) 282 283 // Out-of-line code from node constructors. 284 // Executed only when extra debug info. is being passed around. 285 static void init_node_notes(Compile* C, int idx, Node_Notes* nn) { 286 C->set_node_notes_at(idx, nn); 287 } 288 289 // Shared initialization code. 290 inline int Node::Init(int req) { 291 Compile* C = Compile::current(); 292 int idx = C->next_unique(); 293 294 // Allocate memory for the necessary number of edges. 295 if (req > 0) { 296 // Allocate space for _in array to have double alignment. 297 _in = (Node **) ((char *) (C->node_arena()->Amalloc_D(req * sizeof(void*)))); 298 #ifdef ASSERT 299 _in[req-1] = this; // magic cookie for assertion check 300 #endif 301 } 302 // If there are default notes floating around, capture them: 303 Node_Notes* nn = C->default_node_notes(); 304 if (nn != NULL) init_node_notes(C, idx, nn); 305 306 // Note: At this point, C is dead, 307 // and we begin to initialize the new Node. 308 309 _cnt = _max = req; 310 _outcnt = _outmax = 0; 311 _class_id = Class_Node; 312 _flags = 0; 313 _out = NO_OUT_ARRAY; 314 return idx; 315 } 316 317 //------------------------------Node------------------------------------------- 318 // Create a Node, with a given number of required edges. 319 Node::Node(uint req) 320 : _idx(Init(req)) 321 #ifdef ASSERT 322 , _parse_idx(_idx) 323 #endif 324 { 325 assert( req < Compile::current()->max_node_limit() - NodeLimitFudgeFactor, "Input limit exceeded" ); 326 debug_only( verify_construction() ); 327 NOT_PRODUCT(nodes_created++); 328 if (req == 0) { 329 assert( _in == (Node**)this, "Must not pass arg count to 'new'" ); 330 _in = NULL; 331 } else { 332 assert( _in[req-1] == this, "Must pass arg count to 'new'" ); 333 Node** to = _in; 334 for(uint i = 0; i < req; i++) { 335 to[i] = NULL; 336 } 337 } 338 } 339 340 //------------------------------Node------------------------------------------- 341 Node::Node(Node *n0) 342 : _idx(Init(1)) 343 #ifdef ASSERT 344 , _parse_idx(_idx) 345 #endif 346 { 347 debug_only( verify_construction() ); 348 NOT_PRODUCT(nodes_created++); 349 // Assert we allocated space for input array already 350 assert( _in[0] == this, "Must pass arg count to 'new'" ); 351 assert( is_not_dead(n0), "can not use dead node"); 352 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 353 } 354 355 //------------------------------Node------------------------------------------- 356 Node::Node(Node *n0, Node *n1) 357 : _idx(Init(2)) 358 #ifdef ASSERT 359 , _parse_idx(_idx) 360 #endif 361 { 362 debug_only( verify_construction() ); 363 NOT_PRODUCT(nodes_created++); 364 // Assert we allocated space for input array already 365 assert( _in[1] == this, "Must pass arg count to 'new'" ); 366 assert( is_not_dead(n0), "can not use dead node"); 367 assert( is_not_dead(n1), "can not use dead node"); 368 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 369 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this); 370 } 371 372 //------------------------------Node------------------------------------------- 373 Node::Node(Node *n0, Node *n1, Node *n2) 374 : _idx(Init(3)) 375 #ifdef ASSERT 376 , _parse_idx(_idx) 377 #endif 378 { 379 debug_only( verify_construction() ); 380 NOT_PRODUCT(nodes_created++); 381 // Assert we allocated space for input array already 382 assert( _in[2] == this, "Must pass arg count to 'new'" ); 383 assert( is_not_dead(n0), "can not use dead node"); 384 assert( is_not_dead(n1), "can not use dead node"); 385 assert( is_not_dead(n2), "can not use dead node"); 386 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 387 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this); 388 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this); 389 } 390 391 //------------------------------Node------------------------------------------- 392 Node::Node(Node *n0, Node *n1, Node *n2, Node *n3) 393 : _idx(Init(4)) 394 #ifdef ASSERT 395 , _parse_idx(_idx) 396 #endif 397 { 398 debug_only( verify_construction() ); 399 NOT_PRODUCT(nodes_created++); 400 // Assert we allocated space for input array already 401 assert( _in[3] == this, "Must pass arg count to 'new'" ); 402 assert( is_not_dead(n0), "can not use dead node"); 403 assert( is_not_dead(n1), "can not use dead node"); 404 assert( is_not_dead(n2), "can not use dead node"); 405 assert( is_not_dead(n3), "can not use dead node"); 406 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 407 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this); 408 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this); 409 _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this); 410 } 411 412 //------------------------------Node------------------------------------------- 413 Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, Node *n4) 414 : _idx(Init(5)) 415 #ifdef ASSERT 416 , _parse_idx(_idx) 417 #endif 418 { 419 debug_only( verify_construction() ); 420 NOT_PRODUCT(nodes_created++); 421 // Assert we allocated space for input array already 422 assert( _in[4] == this, "Must pass arg count to 'new'" ); 423 assert( is_not_dead(n0), "can not use dead node"); 424 assert( is_not_dead(n1), "can not use dead node"); 425 assert( is_not_dead(n2), "can not use dead node"); 426 assert( is_not_dead(n3), "can not use dead node"); 427 assert( is_not_dead(n4), "can not use dead node"); 428 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 429 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this); 430 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this); 431 _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this); 432 _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this); 433 } 434 435 //------------------------------Node------------------------------------------- 436 Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, 437 Node *n4, Node *n5) 438 : _idx(Init(6)) 439 #ifdef ASSERT 440 , _parse_idx(_idx) 441 #endif 442 { 443 debug_only( verify_construction() ); 444 NOT_PRODUCT(nodes_created++); 445 // Assert we allocated space for input array already 446 assert( _in[5] == this, "Must pass arg count to 'new'" ); 447 assert( is_not_dead(n0), "can not use dead node"); 448 assert( is_not_dead(n1), "can not use dead node"); 449 assert( is_not_dead(n2), "can not use dead node"); 450 assert( is_not_dead(n3), "can not use dead node"); 451 assert( is_not_dead(n4), "can not use dead node"); 452 assert( is_not_dead(n5), "can not use dead node"); 453 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 454 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this); 455 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this); 456 _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this); 457 _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this); 458 _in[5] = n5; if (n5 != NULL) n5->add_out((Node *)this); 459 } 460 461 //------------------------------Node------------------------------------------- 462 Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, 463 Node *n4, Node *n5, Node *n6) 464 : _idx(Init(7)) 465 #ifdef ASSERT 466 , _parse_idx(_idx) 467 #endif 468 { 469 debug_only( verify_construction() ); 470 NOT_PRODUCT(nodes_created++); 471 // Assert we allocated space for input array already 472 assert( _in[6] == this, "Must pass arg count to 'new'" ); 473 assert( is_not_dead(n0), "can not use dead node"); 474 assert( is_not_dead(n1), "can not use dead node"); 475 assert( is_not_dead(n2), "can not use dead node"); 476 assert( is_not_dead(n3), "can not use dead node"); 477 assert( is_not_dead(n4), "can not use dead node"); 478 assert( is_not_dead(n5), "can not use dead node"); 479 assert( is_not_dead(n6), "can not use dead node"); 480 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 481 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this); 482 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this); 483 _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this); 484 _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this); 485 _in[5] = n5; if (n5 != NULL) n5->add_out((Node *)this); 486 _in[6] = n6; if (n6 != NULL) n6->add_out((Node *)this); 487 } 488 489 #ifdef __clang__ 490 #pragma clang diagnostic pop 491 #endif 492 | 278 279 // This constant used to initialize _out may be any non-null value. 280 // The value NULL is reserved for the top node only. 281 #define NO_OUT_ARRAY ((Node**)-1) 282 283 // Out-of-line code from node constructors. 284 // Executed only when extra debug info. is being passed around. 285 static void init_node_notes(Compile* C, int idx, Node_Notes* nn) { 286 C->set_node_notes_at(idx, nn); 287 } 288 289 // Shared initialization code. 290 inline int Node::Init(int req) { 291 Compile* C = Compile::current(); 292 int idx = C->next_unique(); 293 294 // Allocate memory for the necessary number of edges. 295 if (req > 0) { 296 // Allocate space for _in array to have double alignment. 297 _in = (Node **) ((char *) (C->node_arena()->Amalloc_D(req * sizeof(void*)))); 298 } 299 // If there are default notes floating around, capture them: 300 Node_Notes* nn = C->default_node_notes(); 301 if (nn != NULL) init_node_notes(C, idx, nn); 302 303 // Note: At this point, C is dead, 304 // and we begin to initialize the new Node. 305 306 _cnt = _max = req; 307 _outcnt = _outmax = 0; 308 _class_id = Class_Node; 309 _flags = 0; 310 _out = NO_OUT_ARRAY; 311 return idx; 312 } 313 314 //------------------------------Node------------------------------------------- 315 // Create a Node, with a given number of required edges. 316 Node::Node(uint req) 317 : _idx(Init(req)) 318 #ifdef ASSERT 319 , _parse_idx(_idx) 320 #endif 321 { 322 assert( req < Compile::current()->max_node_limit() - NodeLimitFudgeFactor, "Input limit exceeded" ); 323 debug_only( verify_construction() ); 324 NOT_PRODUCT(nodes_created++); 325 if (req == 0) { 326 _in = NULL; 327 } else { 328 Node** to = _in; 329 for(uint i = 0; i < req; i++) { 330 to[i] = NULL; 331 } 332 } 333 } 334 335 //------------------------------Node------------------------------------------- 336 Node::Node(Node *n0) 337 : _idx(Init(1)) 338 #ifdef ASSERT 339 , _parse_idx(_idx) 340 #endif 341 { 342 debug_only( verify_construction() ); 343 NOT_PRODUCT(nodes_created++); 344 assert( is_not_dead(n0), "can not use dead node"); 345 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 346 } 347 348 //------------------------------Node------------------------------------------- 349 Node::Node(Node *n0, Node *n1) 350 : _idx(Init(2)) 351 #ifdef ASSERT 352 , _parse_idx(_idx) 353 #endif 354 { 355 debug_only( verify_construction() ); 356 NOT_PRODUCT(nodes_created++); 357 assert( is_not_dead(n0), "can not use dead node"); 358 assert( is_not_dead(n1), "can not use dead node"); 359 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 360 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this); 361 } 362 363 //------------------------------Node------------------------------------------- 364 Node::Node(Node *n0, Node *n1, Node *n2) 365 : _idx(Init(3)) 366 #ifdef ASSERT 367 , _parse_idx(_idx) 368 #endif 369 { 370 debug_only( verify_construction() ); 371 NOT_PRODUCT(nodes_created++); 372 assert( is_not_dead(n0), "can not use dead node"); 373 assert( is_not_dead(n1), "can not use dead node"); 374 assert( is_not_dead(n2), "can not use dead node"); 375 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 376 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this); 377 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this); 378 } 379 380 //------------------------------Node------------------------------------------- 381 Node::Node(Node *n0, Node *n1, Node *n2, Node *n3) 382 : _idx(Init(4)) 383 #ifdef ASSERT 384 , _parse_idx(_idx) 385 #endif 386 { 387 debug_only( verify_construction() ); 388 NOT_PRODUCT(nodes_created++); 389 assert( is_not_dead(n0), "can not use dead node"); 390 assert( is_not_dead(n1), "can not use dead node"); 391 assert( is_not_dead(n2), "can not use dead node"); 392 assert( is_not_dead(n3), "can not use dead node"); 393 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 394 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this); 395 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this); 396 _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this); 397 } 398 399 //------------------------------Node------------------------------------------- 400 Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, Node *n4) 401 : _idx(Init(5)) 402 #ifdef ASSERT 403 , _parse_idx(_idx) 404 #endif 405 { 406 debug_only( verify_construction() ); 407 NOT_PRODUCT(nodes_created++); 408 assert( is_not_dead(n0), "can not use dead node"); 409 assert( is_not_dead(n1), "can not use dead node"); 410 assert( is_not_dead(n2), "can not use dead node"); 411 assert( is_not_dead(n3), "can not use dead node"); 412 assert( is_not_dead(n4), "can not use dead node"); 413 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 414 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this); 415 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this); 416 _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this); 417 _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this); 418 } 419 420 //------------------------------Node------------------------------------------- 421 Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, 422 Node *n4, Node *n5) 423 : _idx(Init(6)) 424 #ifdef ASSERT 425 , _parse_idx(_idx) 426 #endif 427 { 428 debug_only( verify_construction() ); 429 NOT_PRODUCT(nodes_created++); 430 assert( is_not_dead(n0), "can not use dead node"); 431 assert( is_not_dead(n1), "can not use dead node"); 432 assert( is_not_dead(n2), "can not use dead node"); 433 assert( is_not_dead(n3), "can not use dead node"); 434 assert( is_not_dead(n4), "can not use dead node"); 435 assert( is_not_dead(n5), "can not use dead node"); 436 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 437 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this); 438 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this); 439 _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this); 440 _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this); 441 _in[5] = n5; if (n5 != NULL) n5->add_out((Node *)this); 442 } 443 444 //------------------------------Node------------------------------------------- 445 Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, 446 Node *n4, Node *n5, Node *n6) 447 : _idx(Init(7)) 448 #ifdef ASSERT 449 , _parse_idx(_idx) 450 #endif 451 { 452 debug_only( verify_construction() ); 453 NOT_PRODUCT(nodes_created++); 454 assert( is_not_dead(n0), "can not use dead node"); 455 assert( is_not_dead(n1), "can not use dead node"); 456 assert( is_not_dead(n2), "can not use dead node"); 457 assert( is_not_dead(n3), "can not use dead node"); 458 assert( is_not_dead(n4), "can not use dead node"); 459 assert( is_not_dead(n5), "can not use dead node"); 460 assert( is_not_dead(n6), "can not use dead node"); 461 _in[0] = n0; if (n0 != NULL) n0->add_out((Node *)this); 462 _in[1] = n1; if (n1 != NULL) n1->add_out((Node *)this); 463 _in[2] = n2; if (n2 != NULL) n2->add_out((Node *)this); 464 _in[3] = n3; if (n3 != NULL) n3->add_out((Node *)this); 465 _in[4] = n4; if (n4 != NULL) n4->add_out((Node *)this); 466 _in[5] = n5; if (n5 != NULL) n5->add_out((Node *)this); 467 _in[6] = n6; if (n6 != NULL) n6->add_out((Node *)this); 468 } 469 470 #ifdef __clang__ 471 #pragma clang diagnostic pop 472 #endif 473 |