Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 6880010: Merge (7265, 7271] from bleeding_edge to experimental/gc branch.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 27 matching lines...) Expand all
38 namespace v8 { 38 namespace v8 {
39 namespace internal { 39 namespace internal {
40 40
41 // ------------------------------------------------------------------------- 41 // -------------------------------------------------------------------------
42 // MacroAssembler implementation. 42 // MacroAssembler implementation.
43 43
44 MacroAssembler::MacroAssembler(void* buffer, int size) 44 MacroAssembler::MacroAssembler(void* buffer, int size)
45 : Assembler(buffer, size), 45 : Assembler(buffer, size),
46 generating_stub_(false), 46 generating_stub_(false),
47 allow_stub_calls_(true), 47 allow_stub_calls_(true),
48 code_object_(Heap::undefined_value()) { 48 code_object_(HEAP->undefined_value()) {
49 } 49 }
50 50
51 51
52 void MacroAssembler::IncrementalMarkingRecordWriteHelper( 52 void MacroAssembler::IncrementalMarkingRecordWriteHelper(
53 Register object, 53 Register object,
54 Register value, 54 Register value,
55 Register address) { 55 Register address) {
56 ASSERT(!object.is(address)); 56 ASSERT(!object.is(address));
57 ASSERT(!value.is(address)); 57 ASSERT(!value.is(address));
58 ASSERT(!value.is(object)); 58 ASSERT(!value.is(object));
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 Register scratch, 280 Register scratch,
281 Label* fail) { 281 Label* fail) {
282 movzx_b(scratch, FieldOperand(map, Map::kInstanceTypeOffset)); 282 movzx_b(scratch, FieldOperand(map, Map::kInstanceTypeOffset));
283 sub(Operand(scratch), Immediate(FIRST_JS_OBJECT_TYPE)); 283 sub(Operand(scratch), Immediate(FIRST_JS_OBJECT_TYPE));
284 cmp(scratch, LAST_JS_OBJECT_TYPE - FIRST_JS_OBJECT_TYPE); 284 cmp(scratch, LAST_JS_OBJECT_TYPE - FIRST_JS_OBJECT_TYPE);
285 j(above, fail); 285 j(above, fail);
286 } 286 }
287 287
288 288
289 void MacroAssembler::FCmp() { 289 void MacroAssembler::FCmp() {
290 if (CpuFeatures::IsSupported(CMOV)) { 290 if (Isolate::Current()->cpu_features()->IsSupported(CMOV)) {
291 fucomip(); 291 fucomip();
292 ffree(0); 292 ffree(0);
293 fincstp(); 293 fincstp();
294 } else { 294 } else {
295 fucompp(); 295 fucompp();
296 push(eax); 296 push(eax);
297 fnstsw_ax(); 297 fnstsw_ax();
298 sahf(); 298 sahf();
299 pop(eax); 299 pop(eax);
300 } 300 }
301 } 301 }
302 302
303 303
304 void MacroAssembler::AbortIfNotNumber(Register object) { 304 void MacroAssembler::AbortIfNotNumber(Register object) {
305 Label ok; 305 Label ok;
306 test(object, Immediate(kSmiTagMask)); 306 test(object, Immediate(kSmiTagMask));
307 j(zero, &ok); 307 j(zero, &ok);
308 cmp(FieldOperand(object, HeapObject::kMapOffset), 308 cmp(FieldOperand(object, HeapObject::kMapOffset),
309 Factory::heap_number_map()); 309 FACTORY->heap_number_map());
310 Assert(equal, "Operand not a number"); 310 Assert(equal, "Operand not a number");
311 bind(&ok); 311 bind(&ok);
312 } 312 }
313 313
314 314
315 void MacroAssembler::AbortIfNotSmi(Register object) { 315 void MacroAssembler::AbortIfNotSmi(Register object) {
316 test(object, Immediate(kSmiTagMask)); 316 test(object, Immediate(kSmiTagMask));
317 Assert(equal, "Operand is not a smi"); 317 Assert(equal, "Operand is not a smi");
318 } 318 }
319 319
(...skipping 15 matching lines...) Expand all
335 } 335 }
336 336
337 337
338 void MacroAssembler::EnterFrame(StackFrame::Type type) { 338 void MacroAssembler::EnterFrame(StackFrame::Type type) {
339 push(ebp); 339 push(ebp);
340 mov(ebp, Operand(esp)); 340 mov(ebp, Operand(esp));
341 push(esi); 341 push(esi);
342 push(Immediate(Smi::FromInt(type))); 342 push(Immediate(Smi::FromInt(type)));
343 push(Immediate(CodeObject())); 343 push(Immediate(CodeObject()));
344 if (emit_debug_code()) { 344 if (emit_debug_code()) {
345 cmp(Operand(esp, 0), Immediate(Factory::undefined_value())); 345 cmp(Operand(esp, 0), Immediate(FACTORY->undefined_value()));
346 Check(not_equal, "code object not properly patched"); 346 Check(not_equal, "code object not properly patched");
347 } 347 }
348 } 348 }
349 349
350 350
351 void MacroAssembler::LeaveFrame(StackFrame::Type type) { 351 void MacroAssembler::LeaveFrame(StackFrame::Type type) {
352 if (emit_debug_code()) { 352 if (emit_debug_code()) {
353 cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset), 353 cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset),
354 Immediate(Smi::FromInt(type))); 354 Immediate(Smi::FromInt(type)));
355 Check(equal, "stack frame types must match"); 355 Check(equal, "stack frame types must match");
356 } 356 }
357 leave(); 357 leave();
358 } 358 }
359 359
360 360
361 void MacroAssembler::EnterExitFramePrologue() { 361 void MacroAssembler::EnterExitFramePrologue() {
362 // Setup the frame structure on the stack. 362 // Setup the frame structure on the stack.
363 ASSERT(ExitFrameConstants::kCallerSPDisplacement == +2 * kPointerSize); 363 ASSERT(ExitFrameConstants::kCallerSPDisplacement == +2 * kPointerSize);
364 ASSERT(ExitFrameConstants::kCallerPCOffset == +1 * kPointerSize); 364 ASSERT(ExitFrameConstants::kCallerPCOffset == +1 * kPointerSize);
365 ASSERT(ExitFrameConstants::kCallerFPOffset == 0 * kPointerSize); 365 ASSERT(ExitFrameConstants::kCallerFPOffset == 0 * kPointerSize);
366 push(ebp); 366 push(ebp);
367 mov(ebp, Operand(esp)); 367 mov(ebp, Operand(esp));
368 368
369 // Reserve room for entry stack pointer and push the code object. 369 // Reserve room for entry stack pointer and push the code object.
370 ASSERT(ExitFrameConstants::kSPOffset == -1 * kPointerSize); 370 ASSERT(ExitFrameConstants::kSPOffset == -1 * kPointerSize);
371 push(Immediate(0)); // Saved entry sp, patched before call. 371 push(Immediate(0)); // Saved entry sp, patched before call.
372 push(Immediate(CodeObject())); // Accessed from ExitFrame::code_slot. 372 push(Immediate(CodeObject())); // Accessed from ExitFrame::code_slot.
373 373
374 // Save the frame pointer and the context in top. 374 // Save the frame pointer and the context in top.
375 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); 375 ExternalReference c_entry_fp_address(Isolate::k_c_entry_fp_address);
376 ExternalReference context_address(Top::k_context_address); 376 ExternalReference context_address(Isolate::k_context_address);
377 mov(Operand::StaticVariable(c_entry_fp_address), ebp); 377 mov(Operand::StaticVariable(c_entry_fp_address), ebp);
378 mov(Operand::StaticVariable(context_address), esi); 378 mov(Operand::StaticVariable(context_address), esi);
379 } 379 }
380 380
381 381
382 void MacroAssembler::EnterExitFrameEpilogue(int argc, bool save_doubles) { 382 void MacroAssembler::EnterExitFrameEpilogue(int argc, bool save_doubles) {
383 // Optionally save all XMM registers. 383 // Optionally save all XMM registers.
384 if (save_doubles) { 384 if (save_doubles) {
385 CpuFeatures::Scope scope(SSE2); 385 CpuFeatures::Scope scope(SSE2);
386 int space = XMMRegister::kNumRegisters * kDoubleSize + argc * kPointerSize; 386 int space = XMMRegister::kNumRegisters * kDoubleSize + argc * kPointerSize;
387 sub(Operand(esp), Immediate(space)); 387 sub(Operand(esp), Immediate(space));
388 const int offset = -2 * kPointerSize; 388 const int offset = -2 * kPointerSize;
389 for (int i = 0; i < XMMRegister::kNumRegisters; i++) { 389 for (int i = 0; i < XMMRegister::kNumRegisters; i++) {
390 XMMRegister reg = XMMRegister::from_code(i); 390 XMMRegister reg = XMMRegister::from_code(i);
391 movdbl(Operand(ebp, offset - ((i + 1) * kDoubleSize)), reg); 391 movdbl(Operand(ebp, offset - ((i + 1) * kDoubleSize)), reg);
392 } 392 }
393 } else { 393 } else {
394 sub(Operand(esp), Immediate(argc * kPointerSize)); 394 sub(Operand(esp), Immediate(argc * kPointerSize));
395 } 395 }
396 396
397 // Get the required frame alignment for the OS. 397 // Get the required frame alignment for the OS.
398 static const int kFrameAlignment = OS::ActivationFrameAlignment(); 398 const int kFrameAlignment = OS::ActivationFrameAlignment();
399 if (kFrameAlignment > 0) { 399 if (kFrameAlignment > 0) {
400 ASSERT(IsPowerOf2(kFrameAlignment)); 400 ASSERT(IsPowerOf2(kFrameAlignment));
401 and_(esp, -kFrameAlignment); 401 and_(esp, -kFrameAlignment);
402 } 402 }
403 403
404 // Patch the saved entry sp. 404 // Patch the saved entry sp.
405 mov(Operand(ebp, ExitFrameConstants::kSPOffset), esp); 405 mov(Operand(ebp, ExitFrameConstants::kSPOffset), esp);
406 } 406 }
407 407
408 408
409 void MacroAssembler::EnterExitFrame(bool save_doubles) { 409 void MacroAssembler::EnterExitFrame(bool save_doubles) {
410 EnterExitFramePrologue(); 410 EnterExitFramePrologue();
411 411
412 // Setup argc and argv in callee-saved registers. 412 // Setup argc and argv in callee-saved registers.
413 int offset = StandardFrameConstants::kCallerSPOffset - kPointerSize; 413 int offset = StandardFrameConstants::kCallerSPOffset - kPointerSize;
414 mov(edi, Operand(eax)); 414 mov(edi, Operand(eax));
415 lea(esi, Operand(ebp, eax, times_4, offset)); 415 lea(esi, Operand(ebp, eax, times_4, offset));
416 416
417 EnterExitFrameEpilogue(2, save_doubles); 417 // Reserve space for argc, argv and isolate.
418 EnterExitFrameEpilogue(3, save_doubles);
418 } 419 }
419 420
420 421
421 void MacroAssembler::EnterApiExitFrame(int argc) { 422 void MacroAssembler::EnterApiExitFrame(int argc) {
422 EnterExitFramePrologue(); 423 EnterExitFramePrologue();
423 EnterExitFrameEpilogue(argc, false); 424 EnterExitFrameEpilogue(argc, false);
424 } 425 }
425 426
426 427
427 void MacroAssembler::LeaveExitFrame(bool save_doubles) { 428 void MacroAssembler::LeaveExitFrame(bool save_doubles) {
(...skipping 15 matching lines...) Expand all
443 lea(esp, Operand(esi, 1 * kPointerSize)); 444 lea(esp, Operand(esi, 1 * kPointerSize));
444 445
445 // Push the return address to get ready to return. 446 // Push the return address to get ready to return.
446 push(ecx); 447 push(ecx);
447 448
448 LeaveExitFrameEpilogue(); 449 LeaveExitFrameEpilogue();
449 } 450 }
450 451
451 void MacroAssembler::LeaveExitFrameEpilogue() { 452 void MacroAssembler::LeaveExitFrameEpilogue() {
452 // Restore current context from top and clear it in debug mode. 453 // Restore current context from top and clear it in debug mode.
453 ExternalReference context_address(Top::k_context_address); 454 ExternalReference context_address(Isolate::k_context_address);
454 mov(esi, Operand::StaticVariable(context_address)); 455 mov(esi, Operand::StaticVariable(context_address));
455 #ifdef DEBUG 456 #ifdef DEBUG
456 mov(Operand::StaticVariable(context_address), Immediate(0)); 457 mov(Operand::StaticVariable(context_address), Immediate(0));
457 #endif 458 #endif
458 459
459 // Clear the top frame. 460 // Clear the top frame.
460 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); 461 ExternalReference c_entry_fp_address(Isolate::k_c_entry_fp_address);
461 mov(Operand::StaticVariable(c_entry_fp_address), Immediate(0)); 462 mov(Operand::StaticVariable(c_entry_fp_address), Immediate(0));
462 } 463 }
463 464
464 465
465 void MacroAssembler::LeaveApiExitFrame() { 466 void MacroAssembler::LeaveApiExitFrame() {
466 mov(esp, Operand(ebp)); 467 mov(esp, Operand(ebp));
467 pop(ebp); 468 pop(ebp);
468 469
469 LeaveExitFrameEpilogue(); 470 LeaveExitFrameEpilogue();
470 } 471 }
(...skipping 13 matching lines...) Expand all
484 push(ebp); 485 push(ebp);
485 } else { 486 } else {
486 ASSERT(try_location == IN_JS_ENTRY); 487 ASSERT(try_location == IN_JS_ENTRY);
487 // The frame pointer does not point to a JS frame so we save NULL 488 // The frame pointer does not point to a JS frame so we save NULL
488 // for ebp. We expect the code throwing an exception to check ebp 489 // for ebp. We expect the code throwing an exception to check ebp
489 // before dereferencing it to restore the context. 490 // before dereferencing it to restore the context.
490 push(Immediate(StackHandler::ENTRY)); 491 push(Immediate(StackHandler::ENTRY));
491 push(Immediate(0)); // NULL frame pointer. 492 push(Immediate(0)); // NULL frame pointer.
492 } 493 }
493 // Save the current handler as the next handler. 494 // Save the current handler as the next handler.
494 push(Operand::StaticVariable(ExternalReference(Top::k_handler_address))); 495 push(Operand::StaticVariable(ExternalReference(Isolate::k_handler_address)));
495 // Link this handler as the new current one. 496 // Link this handler as the new current one.
496 mov(Operand::StaticVariable(ExternalReference(Top::k_handler_address)), esp); 497 mov(Operand::StaticVariable(ExternalReference(Isolate::k_handler_address)),
498 esp);
497 } 499 }
498 500
499 501
500 void MacroAssembler::PopTryHandler() { 502 void MacroAssembler::PopTryHandler() {
501 ASSERT_EQ(0, StackHandlerConstants::kNextOffset); 503 ASSERT_EQ(0, StackHandlerConstants::kNextOffset);
502 pop(Operand::StaticVariable(ExternalReference(Top::k_handler_address))); 504 pop(Operand::StaticVariable(ExternalReference(Isolate::k_handler_address)));
503 add(Operand(esp), Immediate(StackHandlerConstants::kSize - kPointerSize)); 505 add(Operand(esp), Immediate(StackHandlerConstants::kSize - kPointerSize));
504 } 506 }
505 507
506 508
507 void MacroAssembler::Throw(Register value) { 509 void MacroAssembler::Throw(Register value) {
508 // Adjust this code if not the case. 510 // Adjust this code if not the case.
509 STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); 511 STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize);
510 512
511 // eax must hold the exception. 513 // eax must hold the exception.
512 if (!value.is(eax)) { 514 if (!value.is(eax)) {
513 mov(eax, value); 515 mov(eax, value);
514 } 516 }
515 517
516 // Drop the sp to the top of the handler. 518 // Drop the sp to the top of the handler.
517 ExternalReference handler_address(Top::k_handler_address); 519 ExternalReference handler_address(Isolate::k_handler_address);
518 mov(esp, Operand::StaticVariable(handler_address)); 520 mov(esp, Operand::StaticVariable(handler_address));
519 521
520 // Restore next handler and frame pointer, discard handler state. 522 // Restore next handler and frame pointer, discard handler state.
521 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); 523 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
522 pop(Operand::StaticVariable(handler_address)); 524 pop(Operand::StaticVariable(handler_address));
523 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 1 * kPointerSize); 525 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 1 * kPointerSize);
524 pop(ebp); 526 pop(ebp);
525 pop(edx); // Remove state. 527 pop(edx); // Remove state.
526 528
527 // Before returning we restore the context from the frame pointer if 529 // Before returning we restore the context from the frame pointer if
(...skipping 15 matching lines...) Expand all
543 Register value) { 545 Register value) {
544 // Adjust this code if not the case. 546 // Adjust this code if not the case.
545 STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); 547 STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize);
546 548
547 // eax must hold the exception. 549 // eax must hold the exception.
548 if (!value.is(eax)) { 550 if (!value.is(eax)) {
549 mov(eax, value); 551 mov(eax, value);
550 } 552 }
551 553
552 // Drop sp to the top stack handler. 554 // Drop sp to the top stack handler.
553 ExternalReference handler_address(Top::k_handler_address); 555 ExternalReference handler_address(Isolate::k_handler_address);
554 mov(esp, Operand::StaticVariable(handler_address)); 556 mov(esp, Operand::StaticVariable(handler_address));
555 557
556 // Unwind the handlers until the ENTRY handler is found. 558 // Unwind the handlers until the ENTRY handler is found.
557 NearLabel loop, done; 559 NearLabel loop, done;
558 bind(&loop); 560 bind(&loop);
559 // Load the type of the current stack handler. 561 // Load the type of the current stack handler.
560 const int kStateOffset = StackHandlerConstants::kStateOffset; 562 const int kStateOffset = StackHandlerConstants::kStateOffset;
561 cmp(Operand(esp, kStateOffset), Immediate(StackHandler::ENTRY)); 563 cmp(Operand(esp, kStateOffset), Immediate(StackHandler::ENTRY));
562 j(equal, &done); 564 j(equal, &done);
563 // Fetch the next handler in the list. 565 // Fetch the next handler in the list.
564 const int kNextOffset = StackHandlerConstants::kNextOffset; 566 const int kNextOffset = StackHandlerConstants::kNextOffset;
565 mov(esp, Operand(esp, kNextOffset)); 567 mov(esp, Operand(esp, kNextOffset));
566 jmp(&loop); 568 jmp(&loop);
567 bind(&done); 569 bind(&done);
568 570
569 // Set the top handler address to next handler past the current ENTRY handler. 571 // Set the top handler address to next handler past the current ENTRY handler.
570 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); 572 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
571 pop(Operand::StaticVariable(handler_address)); 573 pop(Operand::StaticVariable(handler_address));
572 574
573 if (type == OUT_OF_MEMORY) { 575 if (type == OUT_OF_MEMORY) {
574 // Set external caught exception to false. 576 // Set external caught exception to false.
575 ExternalReference external_caught(Top::k_external_caught_exception_address); 577 ExternalReference external_caught(
578 Isolate::k_external_caught_exception_address);
576 mov(eax, false); 579 mov(eax, false);
577 mov(Operand::StaticVariable(external_caught), eax); 580 mov(Operand::StaticVariable(external_caught), eax);
578 581
579 // Set pending exception and eax to out of memory exception. 582 // Set pending exception and eax to out of memory exception.
580 ExternalReference pending_exception(Top::k_pending_exception_address); 583 ExternalReference pending_exception(Isolate::k_pending_exception_address);
581 mov(eax, reinterpret_cast<int32_t>(Failure::OutOfMemoryException())); 584 mov(eax, reinterpret_cast<int32_t>(Failure::OutOfMemoryException()));
582 mov(Operand::StaticVariable(pending_exception), eax); 585 mov(Operand::StaticVariable(pending_exception), eax);
583 } 586 }
584 587
585 // Clear the context pointer. 588 // Clear the context pointer.
586 Set(esi, Immediate(0)); 589 Set(esi, Immediate(0));
587 590
588 // Restore fp from handler and discard handler state. 591 // Restore fp from handler and discard handler state.
589 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 1 * kPointerSize); 592 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 1 * kPointerSize);
590 pop(ebp); 593 pop(ebp);
(...skipping 22 matching lines...) Expand all
613 // Load the global context of the current context. 616 // Load the global context of the current context.
614 int offset = Context::kHeaderSize + Context::GLOBAL_INDEX * kPointerSize; 617 int offset = Context::kHeaderSize + Context::GLOBAL_INDEX * kPointerSize;
615 mov(scratch, FieldOperand(scratch, offset)); 618 mov(scratch, FieldOperand(scratch, offset));
616 mov(scratch, FieldOperand(scratch, GlobalObject::kGlobalContextOffset)); 619 mov(scratch, FieldOperand(scratch, GlobalObject::kGlobalContextOffset));
617 620
618 // Check the context is a global context. 621 // Check the context is a global context.
619 if (emit_debug_code()) { 622 if (emit_debug_code()) {
620 push(scratch); 623 push(scratch);
621 // Read the first word and compare to global_context_map. 624 // Read the first word and compare to global_context_map.
622 mov(scratch, FieldOperand(scratch, HeapObject::kMapOffset)); 625 mov(scratch, FieldOperand(scratch, HeapObject::kMapOffset));
623 cmp(scratch, Factory::global_context_map()); 626 cmp(scratch, FACTORY->global_context_map());
624 Check(equal, "JSGlobalObject::global_context should be a global context."); 627 Check(equal, "JSGlobalObject::global_context should be a global context.");
625 pop(scratch); 628 pop(scratch);
626 } 629 }
627 630
628 // Check if both contexts are the same. 631 // Check if both contexts are the same.
629 cmp(scratch, FieldOperand(holder_reg, JSGlobalProxy::kContextOffset)); 632 cmp(scratch, FieldOperand(holder_reg, JSGlobalProxy::kContextOffset));
630 j(equal, &same_contexts, taken); 633 j(equal, &same_contexts, taken);
631 634
632 // Compare security tokens, save holder_reg on the stack so we can use it 635 // Compare security tokens, save holder_reg on the stack so we can use it
633 // as a temporary register. 636 // as a temporary register.
634 // 637 //
635 // TODO(119): avoid push(holder_reg)/pop(holder_reg) 638 // TODO(119): avoid push(holder_reg)/pop(holder_reg)
636 push(holder_reg); 639 push(holder_reg);
637 // Check that the security token in the calling global object is 640 // Check that the security token in the calling global object is
638 // compatible with the security token in the receiving global 641 // compatible with the security token in the receiving global
639 // object. 642 // object.
640 mov(holder_reg, FieldOperand(holder_reg, JSGlobalProxy::kContextOffset)); 643 mov(holder_reg, FieldOperand(holder_reg, JSGlobalProxy::kContextOffset));
641 644
642 // Check the context is a global context. 645 // Check the context is a global context.
643 if (emit_debug_code()) { 646 if (emit_debug_code()) {
644 cmp(holder_reg, Factory::null_value()); 647 cmp(holder_reg, FACTORY->null_value());
645 Check(not_equal, "JSGlobalProxy::context() should not be null."); 648 Check(not_equal, "JSGlobalProxy::context() should not be null.");
646 649
647 push(holder_reg); 650 push(holder_reg);
648 // Read the first word and compare to global_context_map(), 651 // Read the first word and compare to global_context_map(),
649 mov(holder_reg, FieldOperand(holder_reg, HeapObject::kMapOffset)); 652 mov(holder_reg, FieldOperand(holder_reg, HeapObject::kMapOffset));
650 cmp(holder_reg, Factory::global_context_map()); 653 cmp(holder_reg, FACTORY->global_context_map());
651 Check(equal, "JSGlobalObject::global_context should be a global context."); 654 Check(equal, "JSGlobalObject::global_context should be a global context.");
652 pop(holder_reg); 655 pop(holder_reg);
653 } 656 }
654 657
655 int token_offset = Context::kHeaderSize + 658 int token_offset = Context::kHeaderSize +
656 Context::SECURITY_TOKEN_INDEX * kPointerSize; 659 Context::SECURITY_TOKEN_INDEX * kPointerSize;
657 mov(scratch, FieldOperand(scratch, token_offset)); 660 mov(scratch, FieldOperand(scratch, token_offset));
658 cmp(scratch, FieldOperand(holder_reg, token_offset)); 661 cmp(scratch, FieldOperand(holder_reg, token_offset));
659 pop(holder_reg); 662 pop(holder_reg);
660 j(not_equal, miss, not_taken); 663 j(not_equal, miss, not_taken);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 // Allocate heap number in new space. 882 // Allocate heap number in new space.
880 AllocateInNewSpace(HeapNumber::kSize, 883 AllocateInNewSpace(HeapNumber::kSize,
881 result, 884 result,
882 scratch1, 885 scratch1,
883 scratch2, 886 scratch2,
884 gc_required, 887 gc_required,
885 TAG_OBJECT); 888 TAG_OBJECT);
886 889
887 // Set the map. 890 // Set the map.
888 mov(FieldOperand(result, HeapObject::kMapOffset), 891 mov(FieldOperand(result, HeapObject::kMapOffset),
889 Immediate(Factory::heap_number_map())); 892 Immediate(FACTORY->heap_number_map()));
890 } 893 }
891 894
892 895
893 void MacroAssembler::AllocateTwoByteString(Register result, 896 void MacroAssembler::AllocateTwoByteString(Register result,
894 Register length, 897 Register length,
895 Register scratch1, 898 Register scratch1,
896 Register scratch2, 899 Register scratch2,
897 Register scratch3, 900 Register scratch3,
898 Label* gc_required) { 901 Label* gc_required) {
899 // Calculate the number of bytes needed for the characters in the string while 902 // Calculate the number of bytes needed for the characters in the string while
900 // observing object alignment. 903 // observing object alignment.
901 ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); 904 ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0);
902 ASSERT(kShortSize == 2); 905 ASSERT(kShortSize == 2);
903 // scratch1 = length * 2 + kObjectAlignmentMask. 906 // scratch1 = length * 2 + kObjectAlignmentMask.
904 lea(scratch1, Operand(length, length, times_1, kObjectAlignmentMask)); 907 lea(scratch1, Operand(length, length, times_1, kObjectAlignmentMask));
905 and_(Operand(scratch1), Immediate(~kObjectAlignmentMask)); 908 and_(Operand(scratch1), Immediate(~kObjectAlignmentMask));
906 909
907 // Allocate two byte string in new space. 910 // Allocate two byte string in new space.
908 AllocateInNewSpace(SeqTwoByteString::kHeaderSize, 911 AllocateInNewSpace(SeqTwoByteString::kHeaderSize,
909 times_1, 912 times_1,
910 scratch1, 913 scratch1,
911 result, 914 result,
912 scratch2, 915 scratch2,
913 scratch3, 916 scratch3,
914 gc_required, 917 gc_required,
915 TAG_OBJECT); 918 TAG_OBJECT);
916 919
917 // Set the map, length and hash field. 920 // Set the map, length and hash field.
918 mov(FieldOperand(result, HeapObject::kMapOffset), 921 mov(FieldOperand(result, HeapObject::kMapOffset),
919 Immediate(Factory::string_map())); 922 Immediate(FACTORY->string_map()));
920 mov(scratch1, length); 923 mov(scratch1, length);
921 SmiTag(scratch1); 924 SmiTag(scratch1);
922 mov(FieldOperand(result, String::kLengthOffset), scratch1); 925 mov(FieldOperand(result, String::kLengthOffset), scratch1);
923 mov(FieldOperand(result, String::kHashFieldOffset), 926 mov(FieldOperand(result, String::kHashFieldOffset),
924 Immediate(String::kEmptyHashField)); 927 Immediate(String::kEmptyHashField));
925 } 928 }
926 929
927 930
928 void MacroAssembler::AllocateAsciiString(Register result, 931 void MacroAssembler::AllocateAsciiString(Register result,
929 Register length, 932 Register length,
(...skipping 14 matching lines...) Expand all
944 times_1, 947 times_1,
945 scratch1, 948 scratch1,
946 result, 949 result,
947 scratch2, 950 scratch2,
948 scratch3, 951 scratch3,
949 gc_required, 952 gc_required,
950 TAG_OBJECT); 953 TAG_OBJECT);
951 954
952 // Set the map, length and hash field. 955 // Set the map, length and hash field.
953 mov(FieldOperand(result, HeapObject::kMapOffset), 956 mov(FieldOperand(result, HeapObject::kMapOffset),
954 Immediate(Factory::ascii_string_map())); 957 Immediate(FACTORY->ascii_string_map()));
955 mov(scratch1, length); 958 mov(scratch1, length);
956 SmiTag(scratch1); 959 SmiTag(scratch1);
957 mov(FieldOperand(result, String::kLengthOffset), scratch1); 960 mov(FieldOperand(result, String::kLengthOffset), scratch1);
958 mov(FieldOperand(result, String::kHashFieldOffset), 961 mov(FieldOperand(result, String::kHashFieldOffset),
959 Immediate(String::kEmptyHashField)); 962 Immediate(String::kEmptyHashField));
960 } 963 }
961 964
962 965
963 void MacroAssembler::AllocateAsciiString(Register result, 966 void MacroAssembler::AllocateAsciiString(Register result,
964 int length, 967 int length,
965 Register scratch1, 968 Register scratch1,
966 Register scratch2, 969 Register scratch2,
967 Label* gc_required) { 970 Label* gc_required) {
968 ASSERT(length > 0); 971 ASSERT(length > 0);
969 972
970 // Allocate ascii string in new space. 973 // Allocate ascii string in new space.
971 AllocateInNewSpace(SeqAsciiString::SizeFor(length), 974 AllocateInNewSpace(SeqAsciiString::SizeFor(length),
972 result, 975 result,
973 scratch1, 976 scratch1,
974 scratch2, 977 scratch2,
975 gc_required, 978 gc_required,
976 TAG_OBJECT); 979 TAG_OBJECT);
977 980
978 // Set the map, length and hash field. 981 // Set the map, length and hash field.
979 mov(FieldOperand(result, HeapObject::kMapOffset), 982 mov(FieldOperand(result, HeapObject::kMapOffset),
980 Immediate(Factory::ascii_string_map())); 983 Immediate(FACTORY->ascii_string_map()));
981 mov(FieldOperand(result, String::kLengthOffset), 984 mov(FieldOperand(result, String::kLengthOffset),
982 Immediate(Smi::FromInt(length))); 985 Immediate(Smi::FromInt(length)));
983 mov(FieldOperand(result, String::kHashFieldOffset), 986 mov(FieldOperand(result, String::kHashFieldOffset),
984 Immediate(String::kEmptyHashField)); 987 Immediate(String::kEmptyHashField));
985 } 988 }
986 989
987 990
988 void MacroAssembler::AllocateConsString(Register result, 991 void MacroAssembler::AllocateConsString(Register result,
989 Register scratch1, 992 Register scratch1,
990 Register scratch2, 993 Register scratch2,
991 Label* gc_required) { 994 Label* gc_required) {
992 // Allocate heap number in new space. 995 // Allocate heap number in new space.
993 AllocateInNewSpace(ConsString::kSize, 996 AllocateInNewSpace(ConsString::kSize,
994 result, 997 result,
995 scratch1, 998 scratch1,
996 scratch2, 999 scratch2,
997 gc_required, 1000 gc_required,
998 TAG_OBJECT); 1001 TAG_OBJECT);
999 1002
1000 // Set the map. The other fields are left uninitialized. 1003 // Set the map. The other fields are left uninitialized.
1001 mov(FieldOperand(result, HeapObject::kMapOffset), 1004 mov(FieldOperand(result, HeapObject::kMapOffset),
1002 Immediate(Factory::cons_string_map())); 1005 Immediate(FACTORY->cons_string_map()));
1003 } 1006 }
1004 1007
1005 1008
1006 void MacroAssembler::AllocateAsciiConsString(Register result, 1009 void MacroAssembler::AllocateAsciiConsString(Register result,
1007 Register scratch1, 1010 Register scratch1,
1008 Register scratch2, 1011 Register scratch2,
1009 Label* gc_required) { 1012 Label* gc_required) {
1010 // Allocate heap number in new space. 1013 // Allocate heap number in new space.
1011 AllocateInNewSpace(ConsString::kSize, 1014 AllocateInNewSpace(ConsString::kSize,
1012 result, 1015 result,
1013 scratch1, 1016 scratch1,
1014 scratch2, 1017 scratch2,
1015 gc_required, 1018 gc_required,
1016 TAG_OBJECT); 1019 TAG_OBJECT);
1017 1020
1018 // Set the map. The other fields are left uninitialized. 1021 // Set the map. The other fields are left uninitialized.
1019 mov(FieldOperand(result, HeapObject::kMapOffset), 1022 mov(FieldOperand(result, HeapObject::kMapOffset),
1020 Immediate(Factory::cons_ascii_string_map())); 1023 Immediate(FACTORY->cons_ascii_string_map()));
1021 } 1024 }
1022 1025
1023 1026
1024 // Copy memory, byte-by-byte, from source to destination. Not optimized for 1027 // Copy memory, byte-by-byte, from source to destination. Not optimized for
1025 // long or aligned copies. The contents of scratch and length are destroyed. 1028 // long or aligned copies. The contents of scratch and length are destroyed.
1026 // Source and destination are incremented by length. 1029 // Source and destination are incremented by length.
1027 // Many variants of movsb, loop unrolling, word moves, and indexed operands 1030 // Many variants of movsb, loop unrolling, word moves, and indexed operands
1028 // have been tried here already, and this is fastest. 1031 // have been tried here already, and this is fastest.
1029 // A simpler loop is faster on small copies, but 30% slower on large ones. 1032 // A simpler loop is faster on small copies, but 30% slower on large ones.
1030 // The cld() instruction must have been emitted, to set the direction flag(), 1033 // The cld() instruction must have been emitted, to set the direction flag(),
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 test(scratch, Immediate(1 << Map::kHasNonInstancePrototype)); 1131 test(scratch, Immediate(1 << Map::kHasNonInstancePrototype));
1129 j(not_zero, &non_instance, not_taken); 1132 j(not_zero, &non_instance, not_taken);
1130 1133
1131 // Get the prototype or initial map from the function. 1134 // Get the prototype or initial map from the function.
1132 mov(result, 1135 mov(result,
1133 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); 1136 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset));
1134 1137
1135 // If the prototype or initial map is the hole, don't return it and 1138 // If the prototype or initial map is the hole, don't return it and
1136 // simply miss the cache instead. This will allow us to allocate a 1139 // simply miss the cache instead. This will allow us to allocate a
1137 // prototype object on-demand in the runtime system. 1140 // prototype object on-demand in the runtime system.
1138 cmp(Operand(result), Immediate(Factory::the_hole_value())); 1141 cmp(Operand(result), Immediate(FACTORY->the_hole_value()));
1139 j(equal, miss, not_taken); 1142 j(equal, miss, not_taken);
1140 1143
1141 // If the function does not have an initial map, we're done. 1144 // If the function does not have an initial map, we're done.
1142 Label done; 1145 Label done;
1143 CmpObjectType(result, MAP_TYPE, scratch); 1146 CmpObjectType(result, MAP_TYPE, scratch);
1144 j(not_equal, &done); 1147 j(not_equal, &done);
1145 1148
1146 // Get the prototype from the initial map. 1149 // Get the prototype from the initial map.
1147 mov(result, FieldOperand(result, Map::kPrototypeOffset)); 1150 mov(result, FieldOperand(result, Map::kPrototypeOffset));
1148 jmp(&done); 1151 jmp(&done);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 void MacroAssembler::StubReturn(int argc) { 1197 void MacroAssembler::StubReturn(int argc) {
1195 ASSERT(argc >= 1 && generating_stub()); 1198 ASSERT(argc >= 1 && generating_stub());
1196 ret((argc - 1) * kPointerSize); 1199 ret((argc - 1) * kPointerSize);
1197 } 1200 }
1198 1201
1199 1202
1200 void MacroAssembler::IllegalOperation(int num_arguments) { 1203 void MacroAssembler::IllegalOperation(int num_arguments) {
1201 if (num_arguments > 0) { 1204 if (num_arguments > 0) {
1202 add(Operand(esp), Immediate(num_arguments * kPointerSize)); 1205 add(Operand(esp), Immediate(num_arguments * kPointerSize));
1203 } 1206 }
1204 mov(eax, Immediate(Factory::undefined_value())); 1207 mov(eax, Immediate(FACTORY->undefined_value()));
1205 } 1208 }
1206 1209
1207 1210
1208 void MacroAssembler::IndexFromHash(Register hash, Register index) { 1211 void MacroAssembler::IndexFromHash(Register hash, Register index) {
1209 // The assert checks that the constants for the maximum number of digits 1212 // The assert checks that the constants for the maximum number of digits
1210 // for an array index cached in the hash field and the number of bits 1213 // for an array index cached in the hash field and the number of bits
1211 // reserved for it does not conflict. 1214 // reserved for it does not conflict.
1212 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < 1215 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
1213 (1 << String::kArrayIndexValueBits)); 1216 (1 << String::kArrayIndexValueBits));
1214 // We want the smi-tagged index in key. kArrayIndexValueMask has zeros in 1217 // We want the smi-tagged index in key. kArrayIndexValueMask has zeros in
1215 // the low kHashShift bits. 1218 // the low kHashShift bits.
1216 and_(hash, String::kArrayIndexValueMask); 1219 and_(hash, String::kArrayIndexValueMask);
1217 STATIC_ASSERT(String::kHashShift >= kSmiTagSize && kSmiTag == 0); 1220 STATIC_ASSERT(String::kHashShift >= kSmiTagSize && kSmiTag == 0);
1218 if (String::kHashShift > kSmiTagSize) { 1221 if (String::kHashShift > kSmiTagSize) {
1219 shr(hash, String::kHashShift - kSmiTagSize); 1222 shr(hash, String::kHashShift - kSmiTagSize);
1220 } 1223 }
1221 if (!index.is(hash)) { 1224 if (!index.is(hash)) {
1222 mov(index, hash); 1225 mov(index, hash);
1223 } 1226 }
1224 } 1227 }
1225 1228
1226 1229
1227 void MacroAssembler::CallRuntime(Runtime::FunctionId id, int num_arguments) { 1230 void MacroAssembler::CallRuntime(Runtime::FunctionId id, int num_arguments) {
1228 CallRuntime(Runtime::FunctionForId(id), num_arguments); 1231 CallRuntime(Runtime::FunctionForId(id), num_arguments);
1229 } 1232 }
1230 1233
1231 1234
1232 void MacroAssembler::CallRuntimeSaveDoubles(Runtime::FunctionId id) { 1235 void MacroAssembler::CallRuntimeSaveDoubles(Runtime::FunctionId id) {
1233 Runtime::Function* function = Runtime::FunctionForId(id); 1236 const Runtime::Function* function = Runtime::FunctionForId(id);
1234 Set(eax, Immediate(function->nargs)); 1237 Set(eax, Immediate(function->nargs));
1235 mov(ebx, Immediate(ExternalReference(function))); 1238 mov(ebx, Immediate(ExternalReference(function)));
1236 CEntryStub ces(1, kSaveFPRegs); 1239 CEntryStub ces(1, kSaveFPRegs);
1237 CallStub(&ces); 1240 CallStub(&ces);
1238 } 1241 }
1239 1242
1240 1243
1241 MaybeObject* MacroAssembler::TryCallRuntime(Runtime::FunctionId id, 1244 MaybeObject* MacroAssembler::TryCallRuntime(Runtime::FunctionId id,
1242 int num_arguments) { 1245 int num_arguments) {
1243 return TryCallRuntime(Runtime::FunctionForId(id), num_arguments); 1246 return TryCallRuntime(Runtime::FunctionForId(id), num_arguments);
1244 } 1247 }
1245 1248
1246 1249
1247 void MacroAssembler::CallRuntime(Runtime::Function* f, int num_arguments) { 1250 void MacroAssembler::CallRuntime(const Runtime::Function* f,
1251 int num_arguments) {
1248 // If the expected number of arguments of the runtime function is 1252 // If the expected number of arguments of the runtime function is
1249 // constant, we check that the actual number of arguments match the 1253 // constant, we check that the actual number of arguments match the
1250 // expectation. 1254 // expectation.
1251 if (f->nargs >= 0 && f->nargs != num_arguments) { 1255 if (f->nargs >= 0 && f->nargs != num_arguments) {
1252 IllegalOperation(num_arguments); 1256 IllegalOperation(num_arguments);
1253 return; 1257 return;
1254 } 1258 }
1255 1259
1256 // TODO(1236192): Most runtime routines don't need the number of 1260 // TODO(1236192): Most runtime routines don't need the number of
1257 // arguments passed in because it is constant. At some point we 1261 // arguments passed in because it is constant. At some point we
1258 // should remove this need and make the runtime routine entry code 1262 // should remove this need and make the runtime routine entry code
1259 // smarter. 1263 // smarter.
1260 Set(eax, Immediate(num_arguments)); 1264 Set(eax, Immediate(num_arguments));
1261 mov(ebx, Immediate(ExternalReference(f))); 1265 mov(ebx, Immediate(ExternalReference(f)));
1262 CEntryStub ces(1); 1266 CEntryStub ces(1);
1263 CallStub(&ces); 1267 CallStub(&ces);
1264 } 1268 }
1265 1269
1266 1270
1267 MaybeObject* MacroAssembler::TryCallRuntime(Runtime::Function* f, 1271 MaybeObject* MacroAssembler::TryCallRuntime(const Runtime::Function* f,
1268 int num_arguments) { 1272 int num_arguments) {
1269 if (f->nargs >= 0 && f->nargs != num_arguments) { 1273 if (f->nargs >= 0 && f->nargs != num_arguments) {
1270 IllegalOperation(num_arguments); 1274 IllegalOperation(num_arguments);
1271 // Since we did not call the stub, there was no allocation failure. 1275 // Since we did not call the stub, there was no allocation failure.
1272 // Return some non-failure object. 1276 // Return some non-failure object.
1273 return Heap::undefined_value(); 1277 return HEAP->undefined_value();
1274 } 1278 }
1275 1279
1276 // TODO(1236192): Most runtime routines don't need the number of 1280 // TODO(1236192): Most runtime routines don't need the number of
1277 // arguments passed in because it is constant. At some point we 1281 // arguments passed in because it is constant. At some point we
1278 // should remove this need and make the runtime routine entry code 1282 // should remove this need and make the runtime routine entry code
1279 // smarter. 1283 // smarter.
1280 Set(eax, Immediate(num_arguments)); 1284 Set(eax, Immediate(num_arguments));
1281 mov(ebx, Immediate(ExternalReference(f))); 1285 mov(ebx, Immediate(ExternalReference(f)));
1282 CEntryStub ces(1); 1286 CEntryStub ces(1);
1283 return TryCallStub(&ces); 1287 return TryCallStub(&ces);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 sub(Operand::StaticVariable(level_address), Immediate(1)); 1427 sub(Operand::StaticVariable(level_address), Immediate(1));
1424 Assert(above_equal, "Invalid HandleScope level"); 1428 Assert(above_equal, "Invalid HandleScope level");
1425 cmp(edi, Operand::StaticVariable(limit_address)); 1429 cmp(edi, Operand::StaticVariable(limit_address));
1426 j(not_equal, &delete_allocated_handles, not_taken); 1430 j(not_equal, &delete_allocated_handles, not_taken);
1427 bind(&leave_exit_frame); 1431 bind(&leave_exit_frame);
1428 1432
1429 // Check if the function scheduled an exception. 1433 // Check if the function scheduled an exception.
1430 ExternalReference scheduled_exception_address = 1434 ExternalReference scheduled_exception_address =
1431 ExternalReference::scheduled_exception_address(); 1435 ExternalReference::scheduled_exception_address();
1432 cmp(Operand::StaticVariable(scheduled_exception_address), 1436 cmp(Operand::StaticVariable(scheduled_exception_address),
1433 Immediate(Factory::the_hole_value())); 1437 Immediate(FACTORY->the_hole_value()));
1434 j(not_equal, &promote_scheduled_exception, not_taken); 1438 j(not_equal, &promote_scheduled_exception, not_taken);
1435 LeaveApiExitFrame(); 1439 LeaveApiExitFrame();
1436 ret(stack_space * kPointerSize); 1440 ret(stack_space * kPointerSize);
1437 bind(&promote_scheduled_exception); 1441 bind(&promote_scheduled_exception);
1438 MaybeObject* result = 1442 MaybeObject* result =
1439 TryTailCallRuntime(Runtime::kPromoteScheduledException, 0, 1); 1443 TryTailCallRuntime(Runtime::kPromoteScheduledException, 0, 1);
1440 if (result->IsFailure()) { 1444 if (result->IsFailure()) {
1441 return result; 1445 return result;
1442 } 1446 }
1443 bind(&empty_handle); 1447 bind(&empty_handle);
1444 // It was zero; the result is undefined. 1448 // It was zero; the result is undefined.
1445 mov(eax, Factory::undefined_value()); 1449 mov(eax, FACTORY->undefined_value());
1446 jmp(&prologue); 1450 jmp(&prologue);
1447 1451
1448 // HandleScope limit has changed. Delete allocated extensions. 1452 // HandleScope limit has changed. Delete allocated extensions.
1449 bind(&delete_allocated_handles); 1453 bind(&delete_allocated_handles);
1450 mov(Operand::StaticVariable(limit_address), edi); 1454 mov(Operand::StaticVariable(limit_address), edi);
1451 mov(edi, eax); 1455 mov(edi, eax);
1456 mov(Operand(esp, 0), Immediate(ExternalReference::isolate_address()));
1452 mov(eax, Immediate(ExternalReference::delete_handle_scope_extensions())); 1457 mov(eax, Immediate(ExternalReference::delete_handle_scope_extensions()));
1453 call(Operand(eax)); 1458 call(Operand(eax));
1454 mov(eax, edi); 1459 mov(eax, edi);
1455 jmp(&leave_exit_frame); 1460 jmp(&leave_exit_frame);
1456 1461
1457 return result; 1462 return result;
1458 } 1463 }
1459 1464
1460 1465
1461 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext) { 1466 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 // is the case when we invoke functions using call and apply. 1520 // is the case when we invoke functions using call and apply.
1516 cmp(expected.reg(), Operand(actual.reg())); 1521 cmp(expected.reg(), Operand(actual.reg()));
1517 j(equal, &invoke); 1522 j(equal, &invoke);
1518 ASSERT(actual.reg().is(eax)); 1523 ASSERT(actual.reg().is(eax));
1519 ASSERT(expected.reg().is(ebx)); 1524 ASSERT(expected.reg().is(ebx));
1520 } 1525 }
1521 } 1526 }
1522 1527
1523 if (!definitely_matches) { 1528 if (!definitely_matches) {
1524 Handle<Code> adaptor = 1529 Handle<Code> adaptor =
1525 Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)); 1530 Handle<Code>(Isolate::Current()->builtins()->builtin(
1531 Builtins::ArgumentsAdaptorTrampoline));
1526 if (!code_constant.is_null()) { 1532 if (!code_constant.is_null()) {
1527 mov(edx, Immediate(code_constant)); 1533 mov(edx, Immediate(code_constant));
1528 add(Operand(edx), Immediate(Code::kHeaderSize - kHeapObjectTag)); 1534 add(Operand(edx), Immediate(Code::kHeaderSize - kHeapObjectTag));
1529 } else if (!code_operand.is_reg(edx)) { 1535 } else if (!code_operand.is_reg(edx)) {
1530 mov(edx, code_operand); 1536 mov(edx, code_operand);
1531 } 1537 }
1532 1538
1533 if (flag == CALL_FUNCTION) { 1539 if (flag == CALL_FUNCTION) {
1534 call(adaptor, RelocInfo::CODE_TARGET); 1540 call(adaptor, RelocInfo::CODE_TARGET);
1535 if (post_call_generator != NULL) post_call_generator->Generate(); 1541 if (post_call_generator != NULL) post_call_generator->Generate();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 mov(function, Operand(function, Context::SlotOffset(index))); 1699 mov(function, Operand(function, Context::SlotOffset(index)));
1694 } 1700 }
1695 1701
1696 1702
1697 void MacroAssembler::LoadGlobalFunctionInitialMap(Register function, 1703 void MacroAssembler::LoadGlobalFunctionInitialMap(Register function,
1698 Register map) { 1704 Register map) {
1699 // Load the initial map. The global functions all have initial maps. 1705 // Load the initial map. The global functions all have initial maps.
1700 mov(map, FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); 1706 mov(map, FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset));
1701 if (emit_debug_code()) { 1707 if (emit_debug_code()) {
1702 Label ok, fail; 1708 Label ok, fail;
1703 CheckMap(map, Factory::meta_map(), &fail, false); 1709 CheckMap(map, FACTORY->meta_map(), &fail, false);
1704 jmp(&ok); 1710 jmp(&ok);
1705 bind(&fail); 1711 bind(&fail);
1706 Abort("Global functions must have initial map"); 1712 Abort("Global functions must have initial map");
1707 bind(&ok); 1713 bind(&ok);
1708 } 1714 }
1709 } 1715 }
1710 1716
1711 1717
1712 // Store the value in register src in the safepoint register stack 1718 // Store the value in register src in the safepoint register stack
1713 // slot for register dst. 1719 // slot for register dst.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 1849
1844 void MacroAssembler::Assert(Condition cc, const char* msg) { 1850 void MacroAssembler::Assert(Condition cc, const char* msg) {
1845 if (emit_debug_code()) Check(cc, msg); 1851 if (emit_debug_code()) Check(cc, msg);
1846 } 1852 }
1847 1853
1848 1854
1849 void MacroAssembler::AssertFastElements(Register elements) { 1855 void MacroAssembler::AssertFastElements(Register elements) {
1850 if (emit_debug_code()) { 1856 if (emit_debug_code()) {
1851 Label ok; 1857 Label ok;
1852 cmp(FieldOperand(elements, HeapObject::kMapOffset), 1858 cmp(FieldOperand(elements, HeapObject::kMapOffset),
1853 Immediate(Factory::fixed_array_map())); 1859 Immediate(FACTORY->fixed_array_map()));
1854 j(equal, &ok); 1860 j(equal, &ok);
1855 cmp(FieldOperand(elements, HeapObject::kMapOffset), 1861 cmp(FieldOperand(elements, HeapObject::kMapOffset),
1856 Immediate(Factory::fixed_cow_array_map())); 1862 Immediate(FACTORY->fixed_cow_array_map()));
1857 j(equal, &ok); 1863 j(equal, &ok);
1858 Abort("JSObject with fast elements map has slow elements"); 1864 Abort("JSObject with fast elements map has slow elements");
1859 bind(&ok); 1865 bind(&ok);
1860 } 1866 }
1861 } 1867 }
1862 1868
1863 1869
1864 void MacroAssembler::Check(Condition cc, const char* msg) { 1870 void MacroAssembler::Check(Condition cc, const char* msg) {
1865 Label L; 1871 Label L;
1866 j(cc, &L, taken); 1872 j(cc, &L, taken);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 int3(); 1917 int3();
1912 } 1918 }
1913 1919
1914 1920
1915 void MacroAssembler::JumpIfNotNumber(Register reg, 1921 void MacroAssembler::JumpIfNotNumber(Register reg,
1916 TypeInfo info, 1922 TypeInfo info,
1917 Label* on_not_number) { 1923 Label* on_not_number) {
1918 if (emit_debug_code()) AbortIfSmi(reg); 1924 if (emit_debug_code()) AbortIfSmi(reg);
1919 if (!info.IsNumber()) { 1925 if (!info.IsNumber()) {
1920 cmp(FieldOperand(reg, HeapObject::kMapOffset), 1926 cmp(FieldOperand(reg, HeapObject::kMapOffset),
1921 Factory::heap_number_map()); 1927 FACTORY->heap_number_map());
1922 j(not_equal, on_not_number); 1928 j(not_equal, on_not_number);
1923 } 1929 }
1924 } 1930 }
1925 1931
1926 1932
1927 void MacroAssembler::ConvertToInt32(Register dst, 1933 void MacroAssembler::ConvertToInt32(Register dst,
1928 Register source, 1934 Register source,
1929 Register scratch, 1935 Register scratch,
1930 TypeInfo info, 1936 TypeInfo info,
1931 Label* on_not_int32) { 1937 Label* on_not_int32) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 ASSERT_EQ(0, kFlatAsciiStringMask & (kFlatAsciiStringMask << 3)); 2022 ASSERT_EQ(0, kFlatAsciiStringMask & (kFlatAsciiStringMask << 3));
2017 and_(scratch1, kFlatAsciiStringMask); 2023 and_(scratch1, kFlatAsciiStringMask);
2018 and_(scratch2, kFlatAsciiStringMask); 2024 and_(scratch2, kFlatAsciiStringMask);
2019 lea(scratch1, Operand(scratch1, scratch2, times_8, 0)); 2025 lea(scratch1, Operand(scratch1, scratch2, times_8, 0));
2020 cmp(scratch1, kFlatAsciiStringTag | (kFlatAsciiStringTag << 3)); 2026 cmp(scratch1, kFlatAsciiStringTag | (kFlatAsciiStringTag << 3));
2021 j(not_equal, failure); 2027 j(not_equal, failure);
2022 } 2028 }
2023 2029
2024 2030
2025 void MacroAssembler::PrepareCallCFunction(int num_arguments, Register scratch) { 2031 void MacroAssembler::PrepareCallCFunction(int num_arguments, Register scratch) {
2032 // Reserve space for Isolate address which is always passed as last parameter
2033 num_arguments += 1;
2034
2026 int frameAlignment = OS::ActivationFrameAlignment(); 2035 int frameAlignment = OS::ActivationFrameAlignment();
2027 if (frameAlignment != 0) { 2036 if (frameAlignment != 0) {
2028 // Make stack end at alignment and make room for num_arguments words 2037 // Make stack end at alignment and make room for num_arguments words
2029 // and the original value of esp. 2038 // and the original value of esp.
2030 mov(scratch, esp); 2039 mov(scratch, esp);
2031 sub(Operand(esp), Immediate((num_arguments + 1) * kPointerSize)); 2040 sub(Operand(esp), Immediate((num_arguments + 1) * kPointerSize));
2032 ASSERT(IsPowerOf2(frameAlignment)); 2041 ASSERT(IsPowerOf2(frameAlignment));
2033 and_(esp, -frameAlignment); 2042 and_(esp, -frameAlignment);
2034 mov(Operand(esp, num_arguments * kPointerSize), scratch); 2043 mov(Operand(esp, num_arguments * kPointerSize), scratch);
2035 } else { 2044 } else {
2036 sub(Operand(esp), Immediate(num_arguments * kPointerSize)); 2045 sub(Operand(esp), Immediate(num_arguments * kPointerSize));
2037 } 2046 }
2038 } 2047 }
2039 2048
2040 2049
2041 void MacroAssembler::CallCFunction(ExternalReference function, 2050 void MacroAssembler::CallCFunction(ExternalReference function,
2042 int num_arguments) { 2051 int num_arguments) {
2043 // Trashing eax is ok as it will be the return value. 2052 // Trashing eax is ok as it will be the return value.
2044 mov(Operand(eax), Immediate(function)); 2053 mov(Operand(eax), Immediate(function));
2045 CallCFunction(eax, num_arguments); 2054 CallCFunction(eax, num_arguments);
2046 } 2055 }
2047 2056
2048 2057
2049 void MacroAssembler::CallCFunction(Register function, 2058 void MacroAssembler::CallCFunction(Register function,
2050 int num_arguments) { 2059 int num_arguments) {
2060 // Pass current isolate address as additional parameter.
2061 mov(Operand(esp, num_arguments * kPointerSize),
2062 Immediate(ExternalReference::isolate_address()));
2063 num_arguments += 1;
2064
2051 // Check stack alignment. 2065 // Check stack alignment.
2052 if (emit_debug_code()) { 2066 if (emit_debug_code()) {
2053 CheckStackAlignment(); 2067 CheckStackAlignment();
2054 } 2068 }
2055 2069
2056 call(Operand(function)); 2070 call(Operand(function));
2057 if (OS::ActivationFrameAlignment() != 0) { 2071 if (OS::ActivationFrameAlignment() != 0) {
2058 mov(esp, Operand(esp, num_arguments * kPointerSize)); 2072 mov(esp, Operand(esp, num_arguments * kPointerSize));
2059 } else { 2073 } else {
2060 add(Operand(esp), Immediate(num_arguments * sizeof(int32_t))); 2074 add(Operand(esp), Immediate(num_arguments * sizeof(int32_t)));
(...skipping 16 matching lines...) Expand all
2077 2091
2078 // Check that the code was patched as expected. 2092 // Check that the code was patched as expected.
2079 ASSERT(masm_.pc_ == address_ + size_); 2093 ASSERT(masm_.pc_ == address_ + size_);
2080 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2094 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2081 } 2095 }
2082 2096
2083 2097
2084 } } // namespace v8::internal 2098 } } // namespace v8::internal
2085 2099
2086 #endif // V8_TARGET_ARCH_IA32 2100 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698