OLD | NEW |
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 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1961 lea(esi, Operand(esp, (argc + 1) * kPointerSize)); | 1961 lea(esi, Operand(esp, (argc + 1) * kPointerSize)); |
1962 mov(Operand(esp, 0 * kPointerSize), esi); | 1962 mov(Operand(esp, 0 * kPointerSize), esi); |
1963 if (emit_debug_code()) { | 1963 if (emit_debug_code()) { |
1964 mov(Operand(esi, 0), Immediate(0)); | 1964 mov(Operand(esi, 0), Immediate(0)); |
1965 } | 1965 } |
1966 } | 1966 } |
1967 } | 1967 } |
1968 | 1968 |
1969 | 1969 |
1970 void MacroAssembler::CallApiFunctionAndReturn(Address function_address, | 1970 void MacroAssembler::CallApiFunctionAndReturn(Address function_address, |
1971 int stack_space) { | 1971 int stack_space, |
| 1972 int return_value_offset) { |
1972 ExternalReference next_address = | 1973 ExternalReference next_address = |
1973 ExternalReference::handle_scope_next_address(isolate()); | 1974 ExternalReference::handle_scope_next_address(isolate()); |
1974 ExternalReference limit_address = | 1975 ExternalReference limit_address = |
1975 ExternalReference::handle_scope_limit_address(isolate()); | 1976 ExternalReference::handle_scope_limit_address(isolate()); |
1976 ExternalReference level_address = | 1977 ExternalReference level_address = |
1977 ExternalReference::handle_scope_level_address(isolate()); | 1978 ExternalReference::handle_scope_level_address(isolate()); |
1978 | 1979 |
1979 // Allocate HandleScope in callee-save registers. | 1980 // Allocate HandleScope in callee-save registers. |
1980 mov(ebx, Operand::StaticVariable(next_address)); | 1981 mov(ebx, Operand::StaticVariable(next_address)); |
1981 mov(edi, Operand::StaticVariable(limit_address)); | 1982 mov(edi, Operand::StaticVariable(limit_address)); |
(...skipping 15 matching lines...) Expand all Loading... |
1997 if (FLAG_log_timer_events) { | 1998 if (FLAG_log_timer_events) { |
1998 FrameScope frame(this, StackFrame::MANUAL); | 1999 FrameScope frame(this, StackFrame::MANUAL); |
1999 PushSafepointRegisters(); | 2000 PushSafepointRegisters(); |
2000 PrepareCallCFunction(1, eax); | 2001 PrepareCallCFunction(1, eax); |
2001 mov(Operand(esp, 0), | 2002 mov(Operand(esp, 0), |
2002 Immediate(ExternalReference::isolate_address(isolate()))); | 2003 Immediate(ExternalReference::isolate_address(isolate()))); |
2003 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); | 2004 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); |
2004 PopSafepointRegisters(); | 2005 PopSafepointRegisters(); |
2005 } | 2006 } |
2006 | 2007 |
2007 if (!kReturnHandlesDirectly) { | 2008 Label prologue; |
2008 // PrepareCallApiFunction saved pointer to the output slot into | 2009 if (!CallbackTable::ReturnsVoid(isolate(), function_address)) { |
2009 // callee-save register esi. | 2010 if (!kReturnHandlesDirectly) { |
2010 mov(eax, Operand(esi, 0)); | 2011 // PrepareCallApiFunction saved pointer to the output slot into |
| 2012 // callee-save register esi. |
| 2013 mov(eax, Operand(esi, 0)); |
| 2014 } |
| 2015 Label empty_handle; |
| 2016 // Check if the result handle holds 0. |
| 2017 test(eax, eax); |
| 2018 j(zero, &empty_handle); |
| 2019 // It was non-zero. Dereference to get the result value. |
| 2020 mov(eax, Operand(eax, 0)); |
| 2021 jmp(&prologue); |
| 2022 bind(&empty_handle); |
2011 } | 2023 } |
| 2024 // Load the value from ReturnValue |
| 2025 mov(eax, Operand(esp, return_value_offset * kPointerSize)); |
2012 | 2026 |
2013 Label empty_handle; | |
2014 Label prologue; | |
2015 Label promote_scheduled_exception; | 2027 Label promote_scheduled_exception; |
2016 Label delete_allocated_handles; | 2028 Label delete_allocated_handles; |
2017 Label leave_exit_frame; | 2029 Label leave_exit_frame; |
2018 | 2030 |
2019 // Check if the result handle holds 0. | |
2020 test(eax, eax); | |
2021 j(zero, &empty_handle); | |
2022 // It was non-zero. Dereference to get the result value. | |
2023 mov(eax, Operand(eax, 0)); | |
2024 bind(&prologue); | 2031 bind(&prologue); |
2025 // No more valid handles (the result handle was the last one). Restore | 2032 // No more valid handles (the result handle was the last one). Restore |
2026 // previous handle scope. | 2033 // previous handle scope. |
2027 mov(Operand::StaticVariable(next_address), ebx); | 2034 mov(Operand::StaticVariable(next_address), ebx); |
2028 sub(Operand::StaticVariable(level_address), Immediate(1)); | 2035 sub(Operand::StaticVariable(level_address), Immediate(1)); |
2029 Assert(above_equal, "Invalid HandleScope level"); | 2036 Assert(above_equal, "Invalid HandleScope level"); |
2030 cmp(edi, Operand::StaticVariable(limit_address)); | 2037 cmp(edi, Operand::StaticVariable(limit_address)); |
2031 j(not_equal, &delete_allocated_handles); | 2038 j(not_equal, &delete_allocated_handles); |
2032 bind(&leave_exit_frame); | 2039 bind(&leave_exit_frame); |
2033 | 2040 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 j(equal, &ok, Label::kNear); | 2076 j(equal, &ok, Label::kNear); |
2070 | 2077 |
2071 Abort("API call returned invalid object"); | 2078 Abort("API call returned invalid object"); |
2072 | 2079 |
2073 bind(&ok); | 2080 bind(&ok); |
2074 #endif | 2081 #endif |
2075 | 2082 |
2076 LeaveApiExitFrame(); | 2083 LeaveApiExitFrame(); |
2077 ret(stack_space * kPointerSize); | 2084 ret(stack_space * kPointerSize); |
2078 | 2085 |
2079 bind(&empty_handle); | |
2080 // It was zero; the result is undefined. | |
2081 mov(eax, isolate()->factory()->undefined_value()); | |
2082 jmp(&prologue); | |
2083 | |
2084 bind(&promote_scheduled_exception); | 2086 bind(&promote_scheduled_exception); |
2085 TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1); | 2087 TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1); |
2086 | 2088 |
2087 // HandleScope limit has changed. Delete allocated extensions. | 2089 // HandleScope limit has changed. Delete allocated extensions. |
2088 ExternalReference delete_extensions = | 2090 ExternalReference delete_extensions = |
2089 ExternalReference::delete_handle_scope_extensions(isolate()); | 2091 ExternalReference::delete_handle_scope_extensions(isolate()); |
2090 bind(&delete_allocated_handles); | 2092 bind(&delete_allocated_handles); |
2091 mov(Operand::StaticVariable(limit_address), edi); | 2093 mov(Operand::StaticVariable(limit_address), edi); |
2092 mov(edi, eax); | 2094 mov(edi, eax); |
2093 mov(Operand(esp, 0), | 2095 mov(Operand(esp, 0), |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3119 j(greater, &no_info_available); | 3121 j(greater, &no_info_available); |
3120 cmp(MemOperand(scratch_reg, -AllocationSiteInfo::kSize), | 3122 cmp(MemOperand(scratch_reg, -AllocationSiteInfo::kSize), |
3121 Immediate(Handle<Map>(isolate()->heap()->allocation_site_info_map()))); | 3123 Immediate(Handle<Map>(isolate()->heap()->allocation_site_info_map()))); |
3122 bind(&no_info_available); | 3124 bind(&no_info_available); |
3123 } | 3125 } |
3124 | 3126 |
3125 | 3127 |
3126 } } // namespace v8::internal | 3128 } } // namespace v8::internal |
3127 | 3129 |
3128 #endif // V8_TARGET_ARCH_IA32 | 3130 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |