OLD | NEW |
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 3040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3051 __ cmp(ebp, 0); | 3051 __ cmp(ebp, 0); |
3052 __ j(equal, &skip, not_taken); | 3052 __ j(equal, &skip, not_taken); |
3053 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 3053 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
3054 __ bind(&skip); | 3054 __ bind(&skip); |
3055 | 3055 |
3056 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); | 3056 STATIC_ASSERT(StackHandlerConstants::kPCOffset == 3 * kPointerSize); |
3057 __ ret(0); | 3057 __ ret(0); |
3058 } | 3058 } |
3059 | 3059 |
3060 | 3060 |
3061 // If true, a Handle<T> passed by value is passed and returned by | |
3062 // using the location_ field directly. If false, it is passed and | |
3063 // returned as a pointer to a handle. | |
3064 #ifdef USING_BSD_ABI | |
3065 static const bool kPassHandlesDirectly = true; | |
3066 #else | |
3067 static const bool kPassHandlesDirectly = false; | |
3068 #endif | |
3069 | |
3070 | |
3071 void ApiGetterEntryStub::Generate(MacroAssembler* masm) { | 3061 void ApiGetterEntryStub::Generate(MacroAssembler* masm) { |
3072 Label empty_handle; | 3062 __ PrepareCallApiFunction(kStackSpace, kArgc); |
3073 Label prologue; | 3063 STATIC_ASSERT(kArgc == 2); |
3074 Label promote_scheduled_exception; | 3064 __ mov(ApiParameterOperand(0), ebx); // name. |
3075 __ EnterApiExitFrame(kStackSpace, kArgc); | 3065 __ mov(ApiParameterOperand(1), eax); // arguments pointer. |
3076 STATIC_ASSERT(kArgc == 4); | 3066 __ CallApiFunctionAndReturn(fun(), kArgc); |
3077 if (kPassHandlesDirectly) { | |
3078 // When handles as passed directly we don't have to allocate extra | |
3079 // space for and pass an out parameter. | |
3080 __ mov(Operand(esp, 0 * kPointerSize), ebx); // name. | |
3081 __ mov(Operand(esp, 1 * kPointerSize), eax); // arguments pointer. | |
3082 } else { | |
3083 // The function expects three arguments to be passed but we allocate | |
3084 // four to get space for the output cell. The argument slots are filled | |
3085 // as follows: | |
3086 // | |
3087 // 3: output cell | |
3088 // 2: arguments pointer | |
3089 // 1: name | |
3090 // 0: pointer to the output cell | |
3091 // | |
3092 // Note that this is one more "argument" than the function expects | |
3093 // so the out cell will have to be popped explicitly after returning | |
3094 // from the function. | |
3095 __ mov(Operand(esp, 1 * kPointerSize), ebx); // name. | |
3096 __ mov(Operand(esp, 2 * kPointerSize), eax); // arguments pointer. | |
3097 __ mov(ebx, esp); | |
3098 __ add(Operand(ebx), Immediate(3 * kPointerSize)); | |
3099 __ mov(Operand(esp, 0 * kPointerSize), ebx); // output | |
3100 __ mov(Operand(esp, 3 * kPointerSize), Immediate(0)); // out cell. | |
3101 } | |
3102 // Call the api function! | |
3103 __ call(fun()->address(), RelocInfo::RUNTIME_ENTRY); | |
3104 // Check if the function scheduled an exception. | |
3105 ExternalReference scheduled_exception_address = | |
3106 ExternalReference::scheduled_exception_address(); | |
3107 __ cmp(Operand::StaticVariable(scheduled_exception_address), | |
3108 Immediate(Factory::the_hole_value())); | |
3109 __ j(not_equal, &promote_scheduled_exception, not_taken); | |
3110 if (!kPassHandlesDirectly) { | |
3111 // The returned value is a pointer to the handle holding the result. | |
3112 // Dereference this to get to the location. | |
3113 __ mov(eax, Operand(eax, 0)); | |
3114 } | |
3115 // Check if the result handle holds 0. | |
3116 __ test(eax, Operand(eax)); | |
3117 __ j(zero, &empty_handle, not_taken); | |
3118 // It was non-zero. Dereference to get the result value. | |
3119 __ mov(eax, Operand(eax, 0)); | |
3120 __ bind(&prologue); | |
3121 __ LeaveExitFrame(); | |
3122 __ ret(0); | |
3123 __ bind(&promote_scheduled_exception); | |
3124 __ TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1); | |
3125 __ bind(&empty_handle); | |
3126 // It was zero; the result is undefined. | |
3127 __ mov(eax, Factory::undefined_value()); | |
3128 __ jmp(&prologue); | |
3129 } | 3067 } |
3130 | 3068 |
3131 | 3069 |
3132 void CEntryStub::GenerateCore(MacroAssembler* masm, | 3070 void CEntryStub::GenerateCore(MacroAssembler* masm, |
3133 Label* throw_normal_exception, | 3071 Label* throw_normal_exception, |
3134 Label* throw_termination_exception, | 3072 Label* throw_termination_exception, |
3135 Label* throw_out_of_memory_exception, | 3073 Label* throw_out_of_memory_exception, |
3136 bool do_gc, | 3074 bool do_gc, |
3137 bool always_allocate_scope, | 3075 bool always_allocate_scope, |
3138 int /* alignment_skew */) { | 3076 int /* alignment_skew */) { |
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4641 // tagged as a small integer. | 4579 // tagged as a small integer. |
4642 __ bind(&runtime); | 4580 __ bind(&runtime); |
4643 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 4581 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
4644 } | 4582 } |
4645 | 4583 |
4646 #undef __ | 4584 #undef __ |
4647 | 4585 |
4648 } } // namespace v8::internal | 4586 } } // namespace v8::internal |
4649 | 4587 |
4650 #endif // V8_TARGET_ARCH_IA32 | 4588 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |