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

Side by Side Diff: src/arm/builtins-arm.cc

Issue 6713074: Require an isolate parameter for most external reference creation to (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Further cleanup Created 9 years, 9 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/arm/assembler-arm.cc ('k') | src/arm/code-stubs-arm.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 if (extra_args == NEEDS_CALLED_FUNCTION) { 61 if (extra_args == NEEDS_CALLED_FUNCTION) {
62 num_extra_args = 1; 62 num_extra_args = 1;
63 __ push(r1); 63 __ push(r1);
64 } else { 64 } else {
65 ASSERT(extra_args == NO_EXTRA_ARGUMENTS); 65 ASSERT(extra_args == NO_EXTRA_ARGUMENTS);
66 } 66 }
67 67
68 // JumpToExternalReference expects r0 to contain the number of arguments 68 // JumpToExternalReference expects r0 to contain the number of arguments
69 // including the receiver and the extra arguments. 69 // including the receiver and the extra arguments.
70 __ add(r0, r0, Operand(num_extra_args + 1)); 70 __ add(r0, r0, Operand(num_extra_args + 1));
71 __ JumpToExternalReference(ExternalReference(id)); 71 __ JumpToExternalReference(ExternalReference(id, masm->isolate()));
72 } 72 }
73 73
74 74
75 // Load the built-in Array function from the current context. 75 // Load the built-in Array function from the current context.
76 static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) { 76 static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
77 // Load the global context. 77 // Load the global context.
78 78
79 __ ldr(result, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); 79 __ ldr(result, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX)));
80 __ ldr(result, 80 __ ldr(result,
81 FieldMemOperand(result, GlobalObject::kGlobalContextOffset)); 81 FieldMemOperand(result, GlobalObject::kGlobalContextOffset));
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 __ CompareObjectType(r2, r3, r4, MAP_TYPE); 435 __ CompareObjectType(r2, r3, r4, MAP_TYPE);
436 __ Assert(eq, "Unexpected initial map for Array function"); 436 __ Assert(eq, "Unexpected initial map for Array function");
437 } 437 }
438 438
439 // Run the native code for the Array function called as a normal function. 439 // Run the native code for the Array function called as a normal function.
440 ArrayNativeCode(masm, &generic_array_code); 440 ArrayNativeCode(masm, &generic_array_code);
441 441
442 // Jump to the generic array code if the specialized code cannot handle 442 // Jump to the generic array code if the specialized code cannot handle
443 // the construction. 443 // the construction.
444 __ bind(&generic_array_code); 444 __ bind(&generic_array_code);
445 Code* code = Isolate::Current()->builtins()->builtin( 445 Code* code = masm->isolate()->builtins()->builtin(
446 Builtins::ArrayCodeGeneric); 446 Builtins::ArrayCodeGeneric);
447 Handle<Code> array_code(code); 447 Handle<Code> array_code(code);
448 __ Jump(array_code, RelocInfo::CODE_TARGET); 448 __ Jump(array_code, RelocInfo::CODE_TARGET);
449 } 449 }
450 450
451 451
452 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { 452 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) {
453 // ----------- S t a t e ------------- 453 // ----------- S t a t e -------------
454 // -- r0 : number of arguments 454 // -- r0 : number of arguments
455 // -- r1 : constructor function 455 // -- r1 : constructor function
(...skipping 12 matching lines...) Expand all
468 __ CompareObjectType(r2, r3, r4, MAP_TYPE); 468 __ CompareObjectType(r2, r3, r4, MAP_TYPE);
469 __ Assert(eq, "Unexpected initial map for Array function"); 469 __ Assert(eq, "Unexpected initial map for Array function");
470 } 470 }
471 471
472 // Run the native code for the Array function called as a constructor. 472 // Run the native code for the Array function called as a constructor.
473 ArrayNativeCode(masm, &generic_constructor); 473 ArrayNativeCode(masm, &generic_constructor);
474 474
475 // Jump to the generic construct code in case the specialized code cannot 475 // Jump to the generic construct code in case the specialized code cannot
476 // handle the construction. 476 // handle the construction.
477 __ bind(&generic_constructor); 477 __ bind(&generic_constructor);
478 Code* code = Isolate::Current()->builtins()->builtin( 478 Code* code = masm->isolate()->builtins()->builtin(
479 Builtins::JSConstructStubGeneric); 479 Builtins::JSConstructStubGeneric);
480 Handle<Code> generic_construct_stub(code); 480 Handle<Code> generic_construct_stub(code);
481 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); 481 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET);
482 } 482 }
483 483
484 484
485 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { 485 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
486 // ----------- S t a t e ------------- 486 // ----------- S t a t e -------------
487 // -- r0 : number of arguments 487 // -- r0 : number of arguments
488 // -- r1 : constructor function 488 // -- r1 : constructor function
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); 628 __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
629 __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kConstructStubOffset)); 629 __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kConstructStubOffset));
630 __ add(pc, r2, Operand(Code::kHeaderSize - kHeapObjectTag)); 630 __ add(pc, r2, Operand(Code::kHeaderSize - kHeapObjectTag));
631 631
632 // r0: number of arguments 632 // r0: number of arguments
633 // r1: called object 633 // r1: called object
634 __ bind(&non_function_call); 634 __ bind(&non_function_call);
635 // Set expected number of arguments to zero (not changing r0). 635 // Set expected number of arguments to zero (not changing r0).
636 __ mov(r2, Operand(0, RelocInfo::NONE)); 636 __ mov(r2, Operand(0, RelocInfo::NONE));
637 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); 637 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR);
638 __ Jump(Handle<Code>(Isolate::Current()->builtins()->builtin( 638 __ Jump(Handle<Code>(masm->isolate()->builtins()->builtin(
639 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); 639 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET);
640 } 640 }
641 641
642 642
643 static void Generate_JSConstructStubHelper(MacroAssembler* masm, 643 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
644 bool is_api_function, 644 bool is_api_function,
645 bool count_constructions) { 645 bool count_constructions) {
646 // Should never count constructions for api objects. 646 // Should never count constructions for api objects.
647 ASSERT(!is_api_function || !count_constructions); 647 ASSERT(!is_api_function || !count_constructions);
648 648
649 // Enter a construct frame. 649 // Enter a construct frame.
650 __ EnterConstructFrame(); 650 __ EnterConstructFrame();
651 651
652 // Preserve the two incoming parameters on the stack. 652 // Preserve the two incoming parameters on the stack.
653 __ mov(r0, Operand(r0, LSL, kSmiTagSize)); 653 __ mov(r0, Operand(r0, LSL, kSmiTagSize));
654 __ push(r0); // Smi-tagged arguments count. 654 __ push(r0); // Smi-tagged arguments count.
655 __ push(r1); // Constructor function. 655 __ push(r1); // Constructor function.
656 656
657 // Try to allocate the object without transitioning into C code. If any of the 657 // Try to allocate the object without transitioning into C code. If any of the
658 // preconditions is not met, the code bails out to the runtime call. 658 // preconditions is not met, the code bails out to the runtime call.
659 Label rt_call, allocated; 659 Label rt_call, allocated;
660 if (FLAG_inline_new) { 660 if (FLAG_inline_new) {
661 Label undo_allocation; 661 Label undo_allocation;
662 #ifdef ENABLE_DEBUGGER_SUPPORT 662 #ifdef ENABLE_DEBUGGER_SUPPORT
663 ExternalReference debug_step_in_fp = 663 ExternalReference debug_step_in_fp =
664 ExternalReference::debug_step_in_fp_address(); 664 ExternalReference::debug_step_in_fp_address(masm->isolate());
665 __ mov(r2, Operand(debug_step_in_fp)); 665 __ mov(r2, Operand(debug_step_in_fp));
666 __ ldr(r2, MemOperand(r2)); 666 __ ldr(r2, MemOperand(r2));
667 __ tst(r2, r2); 667 __ tst(r2, r2);
668 __ b(ne, &rt_call); 668 __ b(ne, &rt_call);
669 #endif 669 #endif
670 670
671 // Load the initial map and verify that it is in fact a map. 671 // Load the initial map and verify that it is in fact a map.
672 // r1: constructor function 672 // r1: constructor function
673 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); 673 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset));
674 __ tst(r2, Operand(kSmiTagMask)); 674 __ tst(r2, Operand(kSmiTagMask));
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 __ bind(&entry); 901 __ bind(&entry);
902 __ sub(r3, r3, Operand(2), SetCC); 902 __ sub(r3, r3, Operand(2), SetCC);
903 __ b(ge, &loop); 903 __ b(ge, &loop);
904 904
905 // Call the function. 905 // Call the function.
906 // r0: number of arguments 906 // r0: number of arguments
907 // r1: constructor function 907 // r1: constructor function
908 if (is_api_function) { 908 if (is_api_function) {
909 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); 909 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
910 Handle<Code> code = Handle<Code>( 910 Handle<Code> code = Handle<Code>(
911 Isolate::Current()->builtins()->builtin( 911 masm->isolate()->builtins()->builtin(
912 Builtins::HandleApiCallConstruct)); 912 Builtins::HandleApiCallConstruct));
913 ParameterCount expected(0); 913 ParameterCount expected(0);
914 __ InvokeCode(code, expected, expected, 914 __ InvokeCode(code, expected, expected,
915 RelocInfo::CODE_TARGET, CALL_FUNCTION); 915 RelocInfo::CODE_TARGET, CALL_FUNCTION);
916 } else { 916 } else {
917 ParameterCount actual(r0); 917 ParameterCount actual(r0);
918 __ InvokeFunction(r1, actual, CALL_FUNCTION); 918 __ InvokeFunction(r1, actual, CALL_FUNCTION);
919 } 919 }
920 920
921 // Pop the function from the stack. 921 // Pop the function from the stack.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 // Clear the context before we push it when entering the JS frame. 999 // Clear the context before we push it when entering the JS frame.
1000 __ mov(cp, Operand(0, RelocInfo::NONE)); 1000 __ mov(cp, Operand(0, RelocInfo::NONE));
1001 1001
1002 // Enter an internal frame. 1002 // Enter an internal frame.
1003 __ EnterInternalFrame(); 1003 __ EnterInternalFrame();
1004 1004
1005 // Set up the context from the function argument. 1005 // Set up the context from the function argument.
1006 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); 1006 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
1007 1007
1008 // Set up the roots register. 1008 // Set up the roots register.
1009 ExternalReference roots_address = ExternalReference::roots_address(); 1009 ExternalReference roots_address =
1010 ExternalReference::roots_address(masm->isolate());
1010 __ mov(r10, Operand(roots_address)); 1011 __ mov(r10, Operand(roots_address));
1011 1012
1012 // Push the function and the receiver onto the stack. 1013 // Push the function and the receiver onto the stack.
1013 __ push(r1); 1014 __ push(r1);
1014 __ push(r2); 1015 __ push(r2);
1015 1016
1016 // Copy arguments to the stack in a loop. 1017 // Copy arguments to the stack in a loop.
1017 // r1: function 1018 // r1: function
1018 // r3: argc 1019 // r3: argc
1019 // r4: argv, i.e. points to first arg 1020 // r4: argv, i.e. points to first arg
(...skipping 15 matching lines...) Expand all
1035 __ mov(r5, Operand(r4)); 1036 __ mov(r5, Operand(r4));
1036 __ mov(r6, Operand(r4)); 1037 __ mov(r6, Operand(r4));
1037 __ mov(r7, Operand(r4)); 1038 __ mov(r7, Operand(r4));
1038 if (kR9Available == 1) { 1039 if (kR9Available == 1) {
1039 __ mov(r9, Operand(r4)); 1040 __ mov(r9, Operand(r4));
1040 } 1041 }
1041 1042
1042 // Invoke the code and pass argc as r0. 1043 // Invoke the code and pass argc as r0.
1043 __ mov(r0, Operand(r3)); 1044 __ mov(r0, Operand(r3));
1044 if (is_construct) { 1045 if (is_construct) {
1045 __ Call(Handle<Code>(Isolate::Current()->builtins()->builtin( 1046 __ Call(Handle<Code>(masm->isolate()->builtins()->builtin(
1046 Builtins::JSConstructCall)), RelocInfo::CODE_TARGET); 1047 Builtins::JSConstructCall)), RelocInfo::CODE_TARGET);
1047 } else { 1048 } else {
1048 ParameterCount actual(r0); 1049 ParameterCount actual(r0);
1049 __ InvokeFunction(r1, actual, CALL_FUNCTION); 1050 __ InvokeFunction(r1, actual, CALL_FUNCTION);
1050 } 1051 }
1051 1052
1052 // Exit the JS frame and remove the parameters (except function), and return. 1053 // Exit the JS frame and remove the parameters (except function), and return.
1053 // Respect ABI stack constraint. 1054 // Respect ABI stack constraint.
1054 __ LeaveInternalFrame(); 1055 __ LeaveInternalFrame();
1055 __ Jump(lr); 1056 __ Jump(lr);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 __ CallRuntime(Runtime::kNotifyOSR, 0); 1166 __ CallRuntime(Runtime::kNotifyOSR, 0);
1166 __ LeaveInternalFrame(); 1167 __ LeaveInternalFrame();
1167 __ ldm(ia_w, sp, kJSCallerSaved | kCalleeSaved | lr.bit() | fp.bit()); 1168 __ ldm(ia_w, sp, kJSCallerSaved | kCalleeSaved | lr.bit() | fp.bit());
1168 __ Ret(); 1169 __ Ret();
1169 } 1170 }
1170 1171
1171 1172
1172 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { 1173 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
1173 // Probe the CPU to set the supported features, because this builtin 1174 // Probe the CPU to set the supported features, because this builtin
1174 // may be called before the initialization performs CPU setup. 1175 // may be called before the initialization performs CPU setup.
1175 Isolate::Current()->cpu_features()->Probe(false); 1176 masm->isolate()->cpu_features()->Probe(false);
1176 1177
1177 // Lookup the function in the JavaScript frame and push it as an 1178 // Lookup the function in the JavaScript frame and push it as an
1178 // argument to the on-stack replacement function. 1179 // argument to the on-stack replacement function.
1179 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1180 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1180 __ EnterInternalFrame(); 1181 __ EnterInternalFrame();
1181 __ push(r0); 1182 __ push(r0);
1182 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); 1183 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1);
1183 __ LeaveInternalFrame(); 1184 __ LeaveInternalFrame();
1184 1185
1185 // If the result was -1 it means that we couldn't optimize the 1186 // If the result was -1 it means that we couldn't optimize the
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 1329
1329 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. 1330 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin.
1330 // r0: actual number of arguments 1331 // r0: actual number of arguments
1331 // r1: function 1332 // r1: function
1332 { Label function; 1333 { Label function;
1333 __ tst(r1, r1); 1334 __ tst(r1, r1);
1334 __ b(ne, &function); 1335 __ b(ne, &function);
1335 // Expected number of arguments is 0 for CALL_NON_FUNCTION. 1336 // Expected number of arguments is 0 for CALL_NON_FUNCTION.
1336 __ mov(r2, Operand(0, RelocInfo::NONE)); 1337 __ mov(r2, Operand(0, RelocInfo::NONE));
1337 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); 1338 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION);
1338 __ Jump(Handle<Code>(Isolate::Current()->builtins()->builtin( 1339 __ Jump(Handle<Code>(masm->isolate()->builtins()->builtin(
1339 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); 1340 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET);
1340 __ bind(&function); 1341 __ bind(&function);
1341 } 1342 }
1342 1343
1343 // 5b. Get the code to call from the function and check that the number of 1344 // 5b. Get the code to call from the function and check that the number of
1344 // expected arguments matches what we're providing. If so, jump 1345 // expected arguments matches what we're providing. If so, jump
1345 // (tail-call) to the code in register edx without checking arguments. 1346 // (tail-call) to the code in register edx without checking arguments.
1346 // r0: actual number of arguments 1347 // r0: actual number of arguments
1347 // r1: function 1348 // r1: function
1348 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); 1349 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
1349 __ ldr(r2, 1350 __ ldr(r2,
1350 FieldMemOperand(r3, SharedFunctionInfo::kFormalParameterCountOffset)); 1351 FieldMemOperand(r3, SharedFunctionInfo::kFormalParameterCountOffset));
1351 __ mov(r2, Operand(r2, ASR, kSmiTagSize)); 1352 __ mov(r2, Operand(r2, ASR, kSmiTagSize));
1352 __ ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); 1353 __ ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset));
1353 __ cmp(r2, r0); // Check formal and actual parameter counts. 1354 __ cmp(r2, r0); // Check formal and actual parameter counts.
1354 __ Jump(Handle<Code>(Isolate::Current()->builtins()->builtin( 1355 __ Jump(Handle<Code>(masm->isolate()->builtins()->builtin(
1355 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET, ne); 1356 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET, ne);
1356 1357
1357 ParameterCount expected(0); 1358 ParameterCount expected(0);
1358 __ InvokeCode(r3, expected, expected, JUMP_FUNCTION); 1359 __ InvokeCode(r3, expected, expected, JUMP_FUNCTION);
1359 } 1360 }
1360 1361
1361 1362
1362 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { 1363 void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
1363 const int kIndexOffset = -5 * kPointerSize; 1364 const int kIndexOffset = -5 * kPointerSize;
1364 const int kLimitOffset = -4 * kPointerSize; 1365 const int kLimitOffset = -4 * kPointerSize;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 __ bind(&dont_adapt_arguments); 1620 __ bind(&dont_adapt_arguments);
1620 __ Jump(r3); 1621 __ Jump(r3);
1621 } 1622 }
1622 1623
1623 1624
1624 #undef __ 1625 #undef __
1625 1626
1626 } } // namespace v8::internal 1627 } } // namespace v8::internal
1627 1628
1628 #endif // V8_TARGET_ARCH_ARM 1629 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/assembler-arm.cc ('k') | src/arm/code-stubs-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698