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

Side by Side Diff: src/ia32/stub-cache-ia32.cc

Issue 4695003: Removing redundant stubs for API functions. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 1 month 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 Handle<CallHandlerInfo> api_call_info_handle(optimization.api_call_info()); 479 Handle<CallHandlerInfo> api_call_info_handle(optimization.api_call_info());
480 if (Heap::InNewSpace(call_data)) { 480 if (Heap::InNewSpace(call_data)) {
481 __ mov(ecx, api_call_info_handle); 481 __ mov(ecx, api_call_info_handle);
482 __ mov(ebx, FieldOperand(ecx, CallHandlerInfo::kDataOffset)); 482 __ mov(ebx, FieldOperand(ecx, CallHandlerInfo::kDataOffset));
483 __ mov(Operand(esp, 3 * kPointerSize), ebx); 483 __ mov(Operand(esp, 3 * kPointerSize), ebx);
484 } else { 484 } else {
485 __ mov(Operand(esp, 3 * kPointerSize), 485 __ mov(Operand(esp, 3 * kPointerSize),
486 Immediate(Handle<Object>(call_data))); 486 Immediate(Handle<Object>(call_data)));
487 } 487 }
488 488
489 // Prepare arguments for ApiCallEntryStub. 489 // Prepare arguments.
490 __ lea(eax, Operand(esp, 3 * kPointerSize)); 490 __ lea(eax, Operand(esp, 3 * kPointerSize));
491 __ lea(ebx, Operand(esp, (argc + 3) * kPointerSize));
492 __ Set(edx, Immediate(argc));
493 491
494 Object* callback = optimization.api_call_info()->callback(); 492 Object* callback = optimization.api_call_info()->callback();
495 Address api_function_address = v8::ToCData<Address>(callback); 493 Address api_function_address = v8::ToCData<Address>(callback);
496 ApiFunction fun(api_function_address); 494 ApiFunction fun(api_function_address);
497 495
498 ApiCallEntryStub stub(api_call_info_handle, &fun); 496 const int kApiArgc = 1; // API function gets reference to the v8::Arguments.
499 497
500 __ EnterInternalFrame(); 498 // Allocate the v8::Arguments structure in the arguments' space since
499 // it's not controlled by GC.
500 const int kApiStackSpace = 4;
501
502 __ PrepareCallApiFunction(argc + kFastApiCallArguments + 1,
503 kApiArgc + kApiStackSpace);
504
505 __ mov(ApiParameterOperand(1), eax); // v8::Arguments::implicit_args_.
506 __ add(Operand(eax), Immediate(argc * kPointerSize));
507 __ mov(ApiParameterOperand(2), eax); // v8::Arguments::values_.
508 __ Set(ApiParameterOperand(3), Immediate(argc)); // v8::Arguments::length_.
509 // v8::Arguments::is_construct_call_.
510 __ mov(ApiParameterOperand(4), Immediate(0));
511
512 // v8::InvocationCallback's argument.
513 __ lea(eax, ApiParameterOperand(1));
514 __ mov(ApiParameterOperand(0), eax);
501 515
502 // Emitting a stub call may try to allocate (if the code is not 516 // Emitting a stub call may try to allocate (if the code is not
503 // already generated). Do not allow the assembler to perform a 517 // already generated). Do not allow the assembler to perform a
504 // garbage collection but instead return the allocation failure 518 // garbage collection but instead return the allocation failure
505 // object. 519 // object.
506 MaybeObject* result = masm->TryCallStub(&stub); 520 MaybeObject* result =
521 masm->TryCallApiFunctionAndReturn(&fun, kApiArgc + kApiStackSpace);
507 if (result->IsFailure()) { 522 if (result->IsFailure()) {
508 *failure = Failure::cast(result); 523 *failure = Failure::cast(result);
509 return false; 524 return false;
510 } 525 }
511
512 __ LeaveInternalFrame();
513 __ ret((argc + 4) * kPointerSize);
514 return true; 526 return true;
515 } 527 }
516 528
517 529
518 class CallInterceptorCompiler BASE_EMBEDDED { 530 class CallInterceptorCompiler BASE_EMBEDDED {
519 public: 531 public:
520 CallInterceptorCompiler(StubCompiler* stub_compiler, 532 CallInterceptorCompiler(StubCompiler* stub_compiler,
521 const ParameterCount& arguments, 533 const ParameterCount& arguments,
522 Register name) 534 Register name)
523 : stub_compiler_(stub_compiler), 535 : stub_compiler_(stub_compiler),
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 __ test(receiver, Immediate(kSmiTagMask)); 1068 __ test(receiver, Immediate(kSmiTagMask));
1057 __ j(zero, miss, not_taken); 1069 __ j(zero, miss, not_taken);
1058 1070
1059 // Check that the maps haven't changed. 1071 // Check that the maps haven't changed.
1060 Register reg = 1072 Register reg =
1061 CheckPrototypes(object, receiver, holder, scratch1, 1073 CheckPrototypes(object, receiver, holder, scratch1,
1062 scratch2, scratch3, name, miss); 1074 scratch2, scratch3, name, miss);
1063 1075
1064 Handle<AccessorInfo> callback_handle(callback); 1076 Handle<AccessorInfo> callback_handle(callback);
1065 1077
1066 __ EnterInternalFrame(); 1078 // Insert additional parameters into the stack frame above return address.
1067 // Push the stack address where the list of arguments ends. 1079 ASSERT(!scratch3.is(reg));
1068 __ lea(scratch2, Operand(esp, -2 * kPointerSize)); 1080 __ pop(scratch3); // Get return address to place it below.
1069 __ push(scratch2); 1081
1070 __ push(receiver); // receiver 1082 __ push(receiver); // receiver
1083 __ mov(scratch2, Operand(esp));
1084 ASSERT(!scratch2.is(reg));
1071 __ push(reg); // holder 1085 __ push(reg); // holder
1072 // Push data from AccessorInfo. 1086 // Push data from AccessorInfo.
1073 if (Heap::InNewSpace(callback_handle->data())) { 1087 if (Heap::InNewSpace(callback_handle->data())) {
1074 __ mov(scratch2, Immediate(callback_handle)); 1088 __ mov(scratch1, Immediate(callback_handle));
1075 __ push(FieldOperand(scratch2, AccessorInfo::kDataOffset)); 1089 __ push(FieldOperand(scratch1, AccessorInfo::kDataOffset));
1076 } else { 1090 } else {
1077 __ push(Immediate(Handle<Object>(callback_handle->data()))); 1091 __ push(Immediate(Handle<Object>(callback_handle->data())));
1078 } 1092 }
1079 __ push(name_reg); // name 1093
1080 // Save a pointer to where we pushed the arguments pointer. 1094 // Save a pointer to where we pushed the arguments pointer.
1081 // This will be passed as the const AccessorInfo& to the C++ callback. 1095 // This will be passed as the const AccessorInfo& to the C++ callback.
1082 STATIC_ASSERT(ApiGetterEntryStub::kStackSpace == 5); 1096 __ push(scratch2);
1083 __ lea(eax, Operand(esp, 4 * kPointerSize)); 1097
1084 __ mov(ebx, esp); 1098 __ push(name_reg); // name
1099 __ mov(ebx, esp); // esp points to reference to name (handler).
1100
1101 __ push(scratch3); // Restore return address.
1085 1102
1086 // Do call through the api. 1103 // Do call through the api.
1087 Address getter_address = v8::ToCData<Address>(callback->getter()); 1104 Address getter_address = v8::ToCData<Address>(callback->getter());
1088 ApiFunction fun(getter_address); 1105 ApiFunction fun(getter_address);
1089 ApiGetterEntryStub stub(callback_handle, &fun); 1106
1107 // 3 elements array for v8::Agruments::values_, handler for name and pointer
1108 // to the values (it considered as smi in GC).
1109 const int kStackSpace = 5;
1110 const int kApiArgc = 2;
1111
1112 __ PrepareCallApiFunction(kStackSpace, kApiArgc);
1113 __ mov(ApiParameterOperand(0), ebx); // name.
1114 __ add(Operand(ebx), Immediate(kPointerSize));
1115 __ mov(ApiParameterOperand(1), ebx); // arguments pointer.
1116
1090 // Emitting a stub call may try to allocate (if the code is not 1117 // Emitting a stub call may try to allocate (if the code is not
1091 // already generated). Do not allow the assembler to perform a 1118 // already generated). Do not allow the assembler to perform a
1092 // garbage collection but instead return the allocation failure 1119 // garbage collection but instead return the allocation failure
1093 // object. 1120 // object.
1094 Object* result = NULL; // Initialization to please compiler. 1121 MaybeObject* result = masm()->TryCallApiFunctionAndReturn(&fun, kApiArgc);
1095 { MaybeObject* try_call_result = masm()->TryCallStub(&stub); 1122 if (result->IsFailure()) {
1096 if (!try_call_result->ToObject(&result)) { 1123 *failure = Failure::cast(result);
1097 *failure = Failure::cast(try_call_result); 1124 return false;
1098 return false;
1099 }
1100 } 1125 }
1101 __ LeaveInternalFrame();
1102 1126
1103 __ ret(0);
1104 return true; 1127 return true;
1105 } 1128 }
1106 1129
1107 1130
1108 void StubCompiler::GenerateLoadConstant(JSObject* object, 1131 void StubCompiler::GenerateLoadConstant(JSObject* object,
1109 JSObject* holder, 1132 JSObject* holder,
1110 Register receiver, 1133 Register receiver,
1111 Register scratch1, 1134 Register scratch1,
1112 Register scratch2, 1135 Register scratch2,
1113 Register scratch3, 1136 Register scratch3,
(...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after
3124 // Return the generated code. 3147 // Return the generated code.
3125 return GetCode(); 3148 return GetCode();
3126 } 3149 }
3127 3150
3128 3151
3129 #undef __ 3152 #undef __
3130 3153
3131 } } // namespace v8::internal 3154 } } // namespace v8::internal
3132 3155
3133 #endif // V8_TARGET_ARCH_IA32 3156 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698