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

Side by Side Diff: src/x64/regexp-macro-assembler-x64.cc

Issue 14429003: Refactor ExternalReference::isolate_address() to not rely on Isolate::Current(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 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
« no previous file with comments | « src/x64/regexp-macro-assembler-x64.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // size_t byte_length - length of capture in bytes(!) 430 // size_t byte_length - length of capture in bytes(!)
431 // Isolate* isolate 431 // Isolate* isolate
432 #ifdef _WIN64 432 #ifdef _WIN64
433 // Compute and set byte_offset1 (start of capture). 433 // Compute and set byte_offset1 (start of capture).
434 __ lea(rcx, Operand(rsi, rdx, times_1, 0)); 434 __ lea(rcx, Operand(rsi, rdx, times_1, 0));
435 // Set byte_offset2. 435 // Set byte_offset2.
436 __ lea(rdx, Operand(rsi, rdi, times_1, 0)); 436 __ lea(rdx, Operand(rsi, rdi, times_1, 0));
437 // Set byte_length. 437 // Set byte_length.
438 __ movq(r8, rbx); 438 __ movq(r8, rbx);
439 // Isolate. 439 // Isolate.
440 __ LoadAddress(r9, ExternalReference::isolate_address()); 440 __ LoadAddress(r9, ExternalReference::isolate_address(isolate()));
441 #else // AMD64 calling convention 441 #else // AMD64 calling convention
442 // Compute byte_offset2 (current position = rsi+rdi). 442 // Compute byte_offset2 (current position = rsi+rdi).
443 __ lea(rax, Operand(rsi, rdi, times_1, 0)); 443 __ lea(rax, Operand(rsi, rdi, times_1, 0));
444 // Compute and set byte_offset1 (start of capture). 444 // Compute and set byte_offset1 (start of capture).
445 __ lea(rdi, Operand(rsi, rdx, times_1, 0)); 445 __ lea(rdi, Operand(rsi, rdx, times_1, 0));
446 // Set byte_offset2. 446 // Set byte_offset2.
447 __ movq(rsi, rax); 447 __ movq(rsi, rax);
448 // Set byte_length. 448 // Set byte_length.
449 __ movq(rdx, rbx); 449 __ movq(rdx, rbx);
450 // Isolate. 450 // Isolate.
451 __ LoadAddress(rcx, ExternalReference::isolate_address()); 451 __ LoadAddress(rcx, ExternalReference::isolate_address(isolate()));
452 #endif 452 #endif
453 453
454 { // NOLINT: Can't find a way to open this scope without confusing the 454 { // NOLINT: Can't find a way to open this scope without confusing the
455 // linter. 455 // linter.
456 AllowExternalCallThatCantCauseGC scope(&masm_); 456 AllowExternalCallThatCantCauseGC scope(&masm_);
457 ExternalReference compare = 457 ExternalReference compare =
458 ExternalReference::re_case_insensitive_compare_uc16(masm_.isolate()); 458 ExternalReference::re_case_insensitive_compare_uc16(isolate());
459 __ CallCFunction(compare, num_arguments); 459 __ CallCFunction(compare, num_arguments);
460 } 460 }
461 461
462 // Restore original values before reacting on result value. 462 // Restore original values before reacting on result value.
463 __ Move(code_object_pointer(), masm_.CodeObject()); 463 __ Move(code_object_pointer(), masm_.CodeObject());
464 __ pop(backtrack_stackpointer()); 464 __ pop(backtrack_stackpointer());
465 #ifndef _WIN64 465 #ifndef _WIN64
466 __ pop(rdi); 466 __ pop(rdi);
467 __ pop(rsi); 467 __ pop(rsi);
468 #endif 468 #endif
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 #endif 803 #endif
804 804
805 __ push(Immediate(0)); // Number of successful matches in a global regexp. 805 __ push(Immediate(0)); // Number of successful matches in a global regexp.
806 __ push(Immediate(0)); // Make room for "input start - 1" constant. 806 __ push(Immediate(0)); // Make room for "input start - 1" constant.
807 807
808 // Check if we have space on the stack for registers. 808 // Check if we have space on the stack for registers.
809 Label stack_limit_hit; 809 Label stack_limit_hit;
810 Label stack_ok; 810 Label stack_ok;
811 811
812 ExternalReference stack_limit = 812 ExternalReference stack_limit =
813 ExternalReference::address_of_stack_limit(masm_.isolate()); 813 ExternalReference::address_of_stack_limit(isolate());
814 __ movq(rcx, rsp); 814 __ movq(rcx, rsp);
815 __ movq(kScratchRegister, stack_limit); 815 __ movq(kScratchRegister, stack_limit);
816 __ subq(rcx, Operand(kScratchRegister, 0)); 816 __ subq(rcx, Operand(kScratchRegister, 0));
817 // Handle it if the stack pointer is already below the stack limit. 817 // Handle it if the stack pointer is already below the stack limit.
818 __ j(below_equal, &stack_limit_hit); 818 __ j(below_equal, &stack_limit_hit);
819 // Check if there is room for the variable number of registers above 819 // Check if there is room for the variable number of registers above
820 // the stack limit. 820 // the stack limit.
821 __ cmpq(rcx, Immediate(num_registers_ * kPointerSize)); 821 __ cmpq(rcx, Immediate(num_registers_ * kPointerSize));
822 __ j(above_equal, &stack_ok); 822 __ j(above_equal, &stack_ok);
823 // Exit with OutOfMemory exception. There is not enough space on the stack 823 // Exit with OutOfMemory exception. There is not enough space on the stack
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 __ push(rdi); 1048 __ push(rdi);
1049 #endif 1049 #endif
1050 1050
1051 // Call GrowStack(backtrack_stackpointer()) 1051 // Call GrowStack(backtrack_stackpointer())
1052 static const int num_arguments = 3; 1052 static const int num_arguments = 3;
1053 __ PrepareCallCFunction(num_arguments); 1053 __ PrepareCallCFunction(num_arguments);
1054 #ifdef _WIN64 1054 #ifdef _WIN64
1055 // Microsoft passes parameters in rcx, rdx, r8. 1055 // Microsoft passes parameters in rcx, rdx, r8.
1056 // First argument, backtrack stackpointer, is already in rcx. 1056 // First argument, backtrack stackpointer, is already in rcx.
1057 __ lea(rdx, Operand(rbp, kStackHighEnd)); // Second argument 1057 __ lea(rdx, Operand(rbp, kStackHighEnd)); // Second argument
1058 __ LoadAddress(r8, ExternalReference::isolate_address()); 1058 __ LoadAddress(r8, ExternalReference::isolate_address(isolate()));
1059 #else 1059 #else
1060 // AMD64 ABI passes parameters in rdi, rsi, rdx. 1060 // AMD64 ABI passes parameters in rdi, rsi, rdx.
1061 __ movq(rdi, backtrack_stackpointer()); // First argument. 1061 __ movq(rdi, backtrack_stackpointer()); // First argument.
1062 __ lea(rsi, Operand(rbp, kStackHighEnd)); // Second argument. 1062 __ lea(rsi, Operand(rbp, kStackHighEnd)); // Second argument.
1063 __ LoadAddress(rdx, ExternalReference::isolate_address()); 1063 __ LoadAddress(rdx, ExternalReference::isolate_address(isolate()));
1064 #endif 1064 #endif
1065 ExternalReference grow_stack = 1065 ExternalReference grow_stack =
1066 ExternalReference::re_grow_stack(masm_.isolate()); 1066 ExternalReference::re_grow_stack(isolate());
1067 __ CallCFunction(grow_stack, num_arguments); 1067 __ CallCFunction(grow_stack, num_arguments);
1068 // If return NULL, we have failed to grow the stack, and 1068 // If return NULL, we have failed to grow the stack, and
1069 // must exit with a stack-overflow exception. 1069 // must exit with a stack-overflow exception.
1070 __ testq(rax, rax); 1070 __ testq(rax, rax);
1071 __ j(equal, &exit_with_exception); 1071 __ j(equal, &exit_with_exception);
1072 // Otherwise use return value as new stack pointer. 1072 // Otherwise use return value as new stack pointer.
1073 __ movq(backtrack_stackpointer(), rax); 1073 __ movq(backtrack_stackpointer(), rax);
1074 // Restore saved registers and continue. 1074 // Restore saved registers and continue.
1075 __ Move(code_object_pointer(), masm_.CodeObject()); 1075 __ Move(code_object_pointer(), masm_.CodeObject());
1076 #ifndef _WIN64 1076 #ifndef _WIN64
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 #else 1259 #else
1260 // Third argument: RegExp code frame pointer. 1260 // Third argument: RegExp code frame pointer.
1261 __ movq(rdx, rbp); 1261 __ movq(rdx, rbp);
1262 // Second argument: Code* of self. 1262 // Second argument: Code* of self.
1263 __ movq(rsi, code_object_pointer()); 1263 __ movq(rsi, code_object_pointer());
1264 // First argument: Next address on the stack (will be address of 1264 // First argument: Next address on the stack (will be address of
1265 // return address). 1265 // return address).
1266 __ lea(rdi, Operand(rsp, -kPointerSize)); 1266 __ lea(rdi, Operand(rsp, -kPointerSize));
1267 #endif 1267 #endif
1268 ExternalReference stack_check = 1268 ExternalReference stack_check =
1269 ExternalReference::re_check_stack_guard_state(masm_.isolate()); 1269 ExternalReference::re_check_stack_guard_state(isolate());
1270 __ CallCFunction(stack_check, num_arguments); 1270 __ CallCFunction(stack_check, num_arguments);
1271 } 1271 }
1272 1272
1273 1273
1274 // Helper function for reading a value out of a stack frame. 1274 // Helper function for reading a value out of a stack frame.
1275 template <typename T> 1275 template <typename T>
1276 static T& frame_entry(Address re_frame, int frame_offset) { 1276 static T& frame_entry(Address re_frame, int frame_offset) {
1277 return reinterpret_cast<T&>(Memory::int32_at(re_frame + frame_offset)); 1277 return reinterpret_cast<T&>(Memory::int32_at(re_frame + frame_offset));
1278 } 1278 }
1279 1279
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 1478
1479 void RegExpMacroAssemblerX64::Drop() { 1479 void RegExpMacroAssemblerX64::Drop() {
1480 __ addq(backtrack_stackpointer(), Immediate(kIntSize)); 1480 __ addq(backtrack_stackpointer(), Immediate(kIntSize));
1481 } 1481 }
1482 1482
1483 1483
1484 void RegExpMacroAssemblerX64::CheckPreemption() { 1484 void RegExpMacroAssemblerX64::CheckPreemption() {
1485 // Check for preemption. 1485 // Check for preemption.
1486 Label no_preempt; 1486 Label no_preempt;
1487 ExternalReference stack_limit = 1487 ExternalReference stack_limit =
1488 ExternalReference::address_of_stack_limit(masm_.isolate()); 1488 ExternalReference::address_of_stack_limit(isolate());
1489 __ load_rax(stack_limit); 1489 __ load_rax(stack_limit);
1490 __ cmpq(rsp, rax); 1490 __ cmpq(rsp, rax);
1491 __ j(above, &no_preempt); 1491 __ j(above, &no_preempt);
1492 1492
1493 SafeCall(&check_preempt_label_); 1493 SafeCall(&check_preempt_label_);
1494 1494
1495 __ bind(&no_preempt); 1495 __ bind(&no_preempt);
1496 } 1496 }
1497 1497
1498 1498
1499 void RegExpMacroAssemblerX64::CheckStackLimit() { 1499 void RegExpMacroAssemblerX64::CheckStackLimit() {
1500 Label no_stack_overflow; 1500 Label no_stack_overflow;
1501 ExternalReference stack_limit = 1501 ExternalReference stack_limit =
1502 ExternalReference::address_of_regexp_stack_limit(masm_.isolate()); 1502 ExternalReference::address_of_regexp_stack_limit(isolate());
1503 __ load_rax(stack_limit); 1503 __ load_rax(stack_limit);
1504 __ cmpq(backtrack_stackpointer(), rax); 1504 __ cmpq(backtrack_stackpointer(), rax);
1505 __ j(above, &no_stack_overflow); 1505 __ j(above, &no_stack_overflow);
1506 1506
1507 SafeCall(&stack_overflow_label_); 1507 SafeCall(&stack_overflow_label_);
1508 1508
1509 __ bind(&no_stack_overflow); 1509 __ bind(&no_stack_overflow);
1510 } 1510 }
1511 1511
1512 1512
(...skipping 21 matching lines...) Expand all
1534 } 1534 }
1535 } 1535 }
1536 1536
1537 #undef __ 1537 #undef __
1538 1538
1539 #endif // V8_INTERPRETED_REGEXP 1539 #endif // V8_INTERPRETED_REGEXP
1540 1540
1541 }} // namespace v8::internal 1541 }} // namespace v8::internal
1542 1542
1543 #endif // V8_TARGET_ARCH_X64 1543 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/regexp-macro-assembler-x64.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698