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

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

Issue 2840018: [Isolates] Moved more compilation-related globals (builtins, runtime, &c.)... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: rebase Created 10 years, 6 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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // edi: called object 95 // edi: called object
96 // eax: number of arguments 96 // eax: number of arguments
97 __ bind(&non_function_call); 97 __ bind(&non_function_call);
98 // CALL_NON_FUNCTION expects the non-function constructor as receiver 98 // CALL_NON_FUNCTION expects the non-function constructor as receiver
99 // (instead of the original receiver from the call site). The receiver is 99 // (instead of the original receiver from the call site). The receiver is
100 // stack element argc+1. 100 // stack element argc+1.
101 __ mov(Operand(esp, eax, times_4, kPointerSize), edi); 101 __ mov(Operand(esp, eax, times_4, kPointerSize), edi);
102 // Set expected number of arguments to zero (not changing eax). 102 // Set expected number of arguments to zero (not changing eax).
103 __ Set(ebx, Immediate(0)); 103 __ Set(ebx, Immediate(0));
104 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); 104 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR);
105 __ jmp(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), 105 __ jmp(Handle<Code>(Isolate::Current()->builtins()->builtin(
106 RelocInfo::CODE_TARGET); 106 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET);
107 } 107 }
108 108
109 109
110 static void Generate_JSConstructStubHelper(MacroAssembler* masm, 110 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
111 bool is_api_function) { 111 bool is_api_function) {
112 // Enter a construct frame. 112 // Enter a construct frame.
113 __ EnterConstructFrame(); 113 __ EnterConstructFrame();
114 114
115 // Store a smi-tagged arguments count on the stack. 115 // Store a smi-tagged arguments count on the stack.
116 __ SmiTag(eax); 116 __ SmiTag(eax);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 __ bind(&loop); 301 __ bind(&loop);
302 __ push(Operand(ebx, ecx, times_4, 0)); 302 __ push(Operand(ebx, ecx, times_4, 0));
303 __ bind(&entry); 303 __ bind(&entry);
304 __ dec(ecx); 304 __ dec(ecx);
305 __ j(greater_equal, &loop); 305 __ j(greater_equal, &loop);
306 306
307 // Call the function. 307 // Call the function.
308 if (is_api_function) { 308 if (is_api_function) {
309 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); 309 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
310 Handle<Code> code = Handle<Code>( 310 Handle<Code> code = Handle<Code>(
311 Builtins::builtin(Builtins::HandleApiCallConstruct)); 311 Isolate::Current()->builtins()->builtin(
312 Builtins::HandleApiCallConstruct));
312 ParameterCount expected(0); 313 ParameterCount expected(0);
313 __ InvokeCode(code, expected, expected, 314 __ InvokeCode(code, expected, expected,
314 RelocInfo::CODE_TARGET, CALL_FUNCTION); 315 RelocInfo::CODE_TARGET, CALL_FUNCTION);
315 } else { 316 } else {
316 ParameterCount actual(eax); 317 ParameterCount actual(eax);
317 __ InvokeFunction(edi, actual, CALL_FUNCTION); 318 __ InvokeFunction(edi, actual, CALL_FUNCTION);
318 } 319 }
319 320
320 // Restore context from the frame. 321 // Restore context from the frame.
321 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 322 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 __ inc(Operand(ecx)); 398 __ inc(Operand(ecx));
398 __ bind(&entry); 399 __ bind(&entry);
399 __ cmp(ecx, Operand(eax)); 400 __ cmp(ecx, Operand(eax));
400 __ j(not_equal, &loop); 401 __ j(not_equal, &loop);
401 402
402 // Get the function from the stack and call it. 403 // Get the function from the stack and call it.
403 __ mov(edi, Operand(esp, eax, times_4, +1 * kPointerSize)); // +1 ~ receiver 404 __ mov(edi, Operand(esp, eax, times_4, +1 * kPointerSize)); // +1 ~ receiver
404 405
405 // Invoke the code. 406 // Invoke the code.
406 if (is_construct) { 407 if (is_construct) {
407 __ call(Handle<Code>(Builtins::builtin(Builtins::JSConstructCall)), 408 __ call(Handle<Code>(Isolate::Current()->builtins()->builtin(
408 RelocInfo::CODE_TARGET); 409 Builtins::JSConstructCall)), RelocInfo::CODE_TARGET);
409 } else { 410 } else {
410 ParameterCount actual(eax); 411 ParameterCount actual(eax);
411 __ InvokeFunction(edi, actual, CALL_FUNCTION); 412 __ InvokeFunction(edi, actual, CALL_FUNCTION);
412 } 413 }
413 414
414 // Exit the JS frame. Notice that this also removes the empty 415 // Exit the JS frame. Notice that this also removes the empty
415 // context and the function left on the stack by the code 416 // context and the function left on the stack by the code
416 // invocation. 417 // invocation.
417 __ LeaveInternalFrame(); 418 __ LeaveInternalFrame();
418 __ ret(1 * kPointerSize); // remove receiver 419 __ ret(1 * kPointerSize); // remove receiver
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 __ pop(ebx); // Discard copy of return address. 530 __ pop(ebx); // Discard copy of return address.
530 __ dec(eax); // One fewer argument (first argument is new receiver). 531 __ dec(eax); // One fewer argument (first argument is new receiver).
531 } 532 }
532 533
533 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. 534 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin.
534 { Label function; 535 { Label function;
535 __ test(edi, Operand(edi)); 536 __ test(edi, Operand(edi));
536 __ j(not_zero, &function, taken); 537 __ j(not_zero, &function, taken);
537 __ xor_(ebx, Operand(ebx)); 538 __ xor_(ebx, Operand(ebx));
538 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); 539 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION);
539 __ jmp(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), 540 __ jmp(Handle<Code>(Isolate::Current()->builtins()->builtin(
540 RelocInfo::CODE_TARGET); 541 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET);
541 __ bind(&function); 542 __ bind(&function);
542 } 543 }
543 544
544 // 5b. Get the code to call from the function and check that the number of 545 // 5b. Get the code to call from the function and check that the number of
545 // expected arguments matches what we're providing. If so, jump 546 // expected arguments matches what we're providing. If so, jump
546 // (tail-call) to the code in register edx without checking arguments. 547 // (tail-call) to the code in register edx without checking arguments.
547 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 548 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
548 __ mov(ebx, 549 __ mov(ebx,
549 FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); 550 FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset));
550 __ SmiUntag(ebx); 551 __ SmiUntag(ebx);
551 __ mov(edx, FieldOperand(edx, SharedFunctionInfo::kCodeOffset)); 552 __ mov(edx, FieldOperand(edx, SharedFunctionInfo::kCodeOffset));
552 __ lea(edx, FieldOperand(edx, Code::kHeaderSize)); 553 __ lea(edx, FieldOperand(edx, Code::kHeaderSize));
553 __ cmp(eax, Operand(ebx)); 554 __ cmp(eax, Operand(ebx));
554 __ j(not_equal, Handle<Code>(builtin(ArgumentsAdaptorTrampoline))); 555 __ j(not_equal, Handle<Code>(Isolate::Current()->builtins()->builtin(
556 ArgumentsAdaptorTrampoline)));
555 557
556 ParameterCount expected(0); 558 ParameterCount expected(0);
557 __ InvokeCode(Operand(edx), expected, expected, JUMP_FUNCTION); 559 __ InvokeCode(Operand(edx), expected, expected, JUMP_FUNCTION);
558 } 560 }
559 561
560 562
561 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { 563 void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
562 __ EnterInternalFrame(); 564 __ EnterInternalFrame();
563 565
564 __ push(Operand(ebp, 4 * kPointerSize)); // push this 566 __ push(Operand(ebp, 4 * kPointerSize)); // push this
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 __ push(ebx); 645 __ push(ebx);
644 646
645 // Copy all arguments from the array to the stack. 647 // Copy all arguments from the array to the stack.
646 Label entry, loop; 648 Label entry, loop;
647 __ mov(eax, Operand(ebp, kIndexOffset)); 649 __ mov(eax, Operand(ebp, kIndexOffset));
648 __ jmp(&entry); 650 __ jmp(&entry);
649 __ bind(&loop); 651 __ bind(&loop);
650 __ mov(edx, Operand(ebp, 2 * kPointerSize)); // load arguments 652 __ mov(edx, Operand(ebp, 2 * kPointerSize)); // load arguments
651 653
652 // Use inline caching to speed up access to arguments. 654 // Use inline caching to speed up access to arguments.
653 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); 655 Handle<Code> ic(Isolate::Current()->builtins()->builtin(
656 Builtins::KeyedLoadIC_Initialize));
654 __ call(ic, RelocInfo::CODE_TARGET); 657 __ call(ic, RelocInfo::CODE_TARGET);
655 // It is important that we do not have a test instruction after the 658 // It is important that we do not have a test instruction after the
656 // call. A test instruction after the call is used to indicate that 659 // call. A test instruction after the call is used to indicate that
657 // we have generated an inline version of the keyed load. In this 660 // we have generated an inline version of the keyed load. In this
658 // case, we know that we are not generating a test instruction next. 661 // case, we know that we are not generating a test instruction next.
659 662
660 // Push the nth argument. 663 // Push the nth argument.
661 __ push(eax); 664 __ push(eax);
662 665
663 // Update the index on the stack and in register eax. 666 // Update the index on the stack and in register eax.
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 __ CmpObjectType(ebx, MAP_TYPE, ecx); 1094 __ CmpObjectType(ebx, MAP_TYPE, ecx);
1092 __ Assert(equal, "Unexpected initial map for Array function"); 1095 __ Assert(equal, "Unexpected initial map for Array function");
1093 } 1096 }
1094 1097
1095 // Run the native code for the Array function called as a normal function. 1098 // Run the native code for the Array function called as a normal function.
1096 ArrayNativeCode(masm, false, &generic_array_code); 1099 ArrayNativeCode(masm, false, &generic_array_code);
1097 1100
1098 // Jump to the generic array code in case the specialized code cannot handle 1101 // Jump to the generic array code in case the specialized code cannot handle
1099 // the construction. 1102 // the construction.
1100 __ bind(&generic_array_code); 1103 __ bind(&generic_array_code);
1101 Code* code = Builtins::builtin(Builtins::ArrayCodeGeneric); 1104 Code* code = Isolate::Current()->builtins()->builtin(
1105 Builtins::ArrayCodeGeneric);
1102 Handle<Code> array_code(code); 1106 Handle<Code> array_code(code);
1103 __ jmp(array_code, RelocInfo::CODE_TARGET); 1107 __ jmp(array_code, RelocInfo::CODE_TARGET);
1104 } 1108 }
1105 1109
1106 1110
1107 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { 1111 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) {
1108 // ----------- S t a t e ------------- 1112 // ----------- S t a t e -------------
1109 // -- eax : argc 1113 // -- eax : argc
1110 // -- edi : constructor 1114 // -- edi : constructor
1111 // -- esp[0] : return address 1115 // -- esp[0] : return address
(...skipping 15 matching lines...) Expand all
1127 __ CmpObjectType(ebx, MAP_TYPE, ecx); 1131 __ CmpObjectType(ebx, MAP_TYPE, ecx);
1128 __ Assert(equal, "Unexpected initial map for Array function"); 1132 __ Assert(equal, "Unexpected initial map for Array function");
1129 } 1133 }
1130 1134
1131 // Run the native code for the Array function called as constructor. 1135 // Run the native code for the Array function called as constructor.
1132 ArrayNativeCode(masm, true, &generic_constructor); 1136 ArrayNativeCode(masm, true, &generic_constructor);
1133 1137
1134 // Jump to the generic construct code in case the specialized code cannot 1138 // Jump to the generic construct code in case the specialized code cannot
1135 // handle the construction. 1139 // handle the construction.
1136 __ bind(&generic_constructor); 1140 __ bind(&generic_constructor);
1137 Code* code = Builtins::builtin(Builtins::JSConstructStubGeneric); 1141 Code* code = Isolate::Current()->builtins()->builtin(
1142 Builtins::JSConstructStubGeneric);
1138 Handle<Code> generic_construct_stub(code); 1143 Handle<Code> generic_construct_stub(code);
1139 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); 1144 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET);
1140 } 1145 }
1141 1146
1142 1147
1143 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { 1148 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
1144 __ push(ebp); 1149 __ push(ebp);
1145 __ mov(ebp, Operand(esp)); 1150 __ mov(ebp, Operand(esp));
1146 1151
1147 // Store the arguments adaptor context sentinel. 1152 // Store the arguments adaptor context sentinel.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 __ bind(&dont_adapt_arguments); 1257 __ bind(&dont_adapt_arguments);
1253 __ jmp(Operand(edx)); 1258 __ jmp(Operand(edx));
1254 } 1259 }
1255 1260
1256 1261
1257 #undef __ 1262 #undef __
1258 1263
1259 } } // namespace v8::internal 1264 } } // namespace v8::internal
1260 1265
1261 #endif // V8_TARGET_ARCH_IA32 1266 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/ia32/codegen-ia32.h » ('j') | src/runtime.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698