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

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 12494012: new style of property/function callbacks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: make arm look like other architectures Created 7 years, 7 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/ia32/macro-assembler-ia32.h ('k') | src/ia32/stub-cache-ia32.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 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 1936 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 // If false, it is returned as a pointer to a preallocated by caller memory 1947 // If false, it is returned as a pointer to a preallocated by caller memory
1948 // region. Pointer to this region should be passed to a function as an 1948 // region. Pointer to this region should be passed to a function as an
1949 // implicit first argument. 1949 // implicit first argument.
1950 #if defined(USING_BSD_ABI) || defined(__MINGW32__) || defined(__CYGWIN__) 1950 #if defined(USING_BSD_ABI) || defined(__MINGW32__) || defined(__CYGWIN__)
1951 static const bool kReturnHandlesDirectly = true; 1951 static const bool kReturnHandlesDirectly = true;
1952 #else 1952 #else
1953 static const bool kReturnHandlesDirectly = false; 1953 static const bool kReturnHandlesDirectly = false;
1954 #endif 1954 #endif
1955 1955
1956 1956
1957 Operand ApiParameterOperand(int index) { 1957 Operand ApiParameterOperand(int index, bool returns_handle) {
1958 return Operand( 1958 int offset = (index +(kReturnHandlesDirectly || !returns_handle ? 0 : 1));
1959 esp, (index + (kReturnHandlesDirectly ? 0 : 1)) * kPointerSize); 1959 return Operand(esp, offset * kPointerSize);
1960 } 1960 }
1961 1961
1962 1962
1963 void MacroAssembler::PrepareCallApiFunction(int argc) { 1963 void MacroAssembler::PrepareCallApiFunction(int argc, bool returns_handle) {
1964 if (kReturnHandlesDirectly) { 1964 if (kReturnHandlesDirectly || !returns_handle) {
1965 EnterApiExitFrame(argc); 1965 EnterApiExitFrame(argc);
1966 // When handles are returned directly we don't have to allocate extra 1966 // When handles are returned directly we don't have to allocate extra
1967 // space for and pass an out parameter. 1967 // space for and pass an out parameter.
1968 if (emit_debug_code()) { 1968 if (emit_debug_code()) {
1969 mov(esi, Immediate(BitCast<int32_t>(kZapValue))); 1969 mov(esi, Immediate(BitCast<int32_t>(kZapValue)));
1970 } 1970 }
1971 } else { 1971 } else {
1972 // We allocate two additional slots: return value and pointer to it. 1972 // We allocate two additional slots: return value and pointer to it.
1973 EnterApiExitFrame(argc + 2); 1973 EnterApiExitFrame(argc + 2);
1974 1974
1975 // The argument slots are filled as follows: 1975 // The argument slots are filled as follows:
1976 // 1976 //
1977 // n + 1: output slot 1977 // n + 1: output slot
1978 // n: arg n 1978 // n: arg n
1979 // ... 1979 // ...
1980 // 1: arg1 1980 // 1: arg1
1981 // 0: pointer to the output slot 1981 // 0: pointer to the output slot
1982 1982
1983 lea(esi, Operand(esp, (argc + 1) * kPointerSize)); 1983 lea(esi, Operand(esp, (argc + 1) * kPointerSize));
1984 mov(Operand(esp, 0 * kPointerSize), esi); 1984 mov(Operand(esp, 0 * kPointerSize), esi);
1985 if (emit_debug_code()) { 1985 if (emit_debug_code()) {
1986 mov(Operand(esi, 0), Immediate(0)); 1986 mov(Operand(esi, 0), Immediate(0));
1987 } 1987 }
1988 } 1988 }
1989 } 1989 }
1990 1990
1991 1991
1992 void MacroAssembler::CallApiFunctionAndReturn(Address function_address, 1992 void MacroAssembler::CallApiFunctionAndReturn(Address function_address,
1993 int stack_space) { 1993 int stack_space,
1994 bool returns_handle,
1995 int return_value_offset) {
1994 ExternalReference next_address = 1996 ExternalReference next_address =
1995 ExternalReference::handle_scope_next_address(isolate()); 1997 ExternalReference::handle_scope_next_address(isolate());
1996 ExternalReference limit_address = 1998 ExternalReference limit_address =
1997 ExternalReference::handle_scope_limit_address(isolate()); 1999 ExternalReference::handle_scope_limit_address(isolate());
1998 ExternalReference level_address = 2000 ExternalReference level_address =
1999 ExternalReference::handle_scope_level_address(isolate()); 2001 ExternalReference::handle_scope_level_address(isolate());
2000 2002
2001 // Allocate HandleScope in callee-save registers. 2003 // Allocate HandleScope in callee-save registers.
2002 mov(ebx, Operand::StaticVariable(next_address)); 2004 mov(ebx, Operand::StaticVariable(next_address));
2003 mov(edi, Operand::StaticVariable(limit_address)); 2005 mov(edi, Operand::StaticVariable(limit_address));
(...skipping 15 matching lines...) Expand all
2019 if (FLAG_log_timer_events) { 2021 if (FLAG_log_timer_events) {
2020 FrameScope frame(this, StackFrame::MANUAL); 2022 FrameScope frame(this, StackFrame::MANUAL);
2021 PushSafepointRegisters(); 2023 PushSafepointRegisters();
2022 PrepareCallCFunction(1, eax); 2024 PrepareCallCFunction(1, eax);
2023 mov(Operand(esp, 0), 2025 mov(Operand(esp, 0),
2024 Immediate(ExternalReference::isolate_address(isolate()))); 2026 Immediate(ExternalReference::isolate_address(isolate())));
2025 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); 2027 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1);
2026 PopSafepointRegisters(); 2028 PopSafepointRegisters();
2027 } 2029 }
2028 2030
2029 if (!kReturnHandlesDirectly) { 2031 Label prologue;
2030 // PrepareCallApiFunction saved pointer to the output slot into 2032 if (returns_handle) {
2031 // callee-save register esi. 2033 if (!kReturnHandlesDirectly) {
2032 mov(eax, Operand(esi, 0)); 2034 // PrepareCallApiFunction saved pointer to the output slot into
2035 // callee-save register esi.
2036 mov(eax, Operand(esi, 0));
2037 }
2038 Label empty_handle;
2039 // Check if the result handle holds 0.
2040 test(eax, eax);
2041 j(zero, &empty_handle);
2042 // It was non-zero. Dereference to get the result value.
2043 mov(eax, Operand(eax, 0));
2044 jmp(&prologue);
2045 bind(&empty_handle);
2033 } 2046 }
2047 // Load the value from ReturnValue
2048 mov(eax, Operand(ebp, return_value_offset * kPointerSize));
2034 2049
2035 Label empty_handle;
2036 Label prologue;
2037 Label promote_scheduled_exception; 2050 Label promote_scheduled_exception;
2038 Label delete_allocated_handles; 2051 Label delete_allocated_handles;
2039 Label leave_exit_frame; 2052 Label leave_exit_frame;
2040 2053
2041 // Check if the result handle holds 0.
2042 test(eax, eax);
2043 j(zero, &empty_handle);
2044 // It was non-zero. Dereference to get the result value.
2045 mov(eax, Operand(eax, 0));
2046 bind(&prologue); 2054 bind(&prologue);
2047 // No more valid handles (the result handle was the last one). Restore 2055 // No more valid handles (the result handle was the last one). Restore
2048 // previous handle scope. 2056 // previous handle scope.
2049 mov(Operand::StaticVariable(next_address), ebx); 2057 mov(Operand::StaticVariable(next_address), ebx);
2050 sub(Operand::StaticVariable(level_address), Immediate(1)); 2058 sub(Operand::StaticVariable(level_address), Immediate(1));
2051 Assert(above_equal, "Invalid HandleScope level"); 2059 Assert(above_equal, "Invalid HandleScope level");
2052 cmp(edi, Operand::StaticVariable(limit_address)); 2060 cmp(edi, Operand::StaticVariable(limit_address));
2053 j(not_equal, &delete_allocated_handles); 2061 j(not_equal, &delete_allocated_handles);
2054 bind(&leave_exit_frame); 2062 bind(&leave_exit_frame);
2055 2063
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 j(equal, &ok, Label::kNear); 2099 j(equal, &ok, Label::kNear);
2092 2100
2093 Abort("API call returned invalid object"); 2101 Abort("API call returned invalid object");
2094 2102
2095 bind(&ok); 2103 bind(&ok);
2096 #endif 2104 #endif
2097 2105
2098 LeaveApiExitFrame(); 2106 LeaveApiExitFrame();
2099 ret(stack_space * kPointerSize); 2107 ret(stack_space * kPointerSize);
2100 2108
2101 bind(&empty_handle);
2102 // It was zero; the result is undefined.
2103 mov(eax, isolate()->factory()->undefined_value());
2104 jmp(&prologue);
2105
2106 bind(&promote_scheduled_exception); 2109 bind(&promote_scheduled_exception);
2107 TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1); 2110 TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1);
2108 2111
2109 // HandleScope limit has changed. Delete allocated extensions. 2112 // HandleScope limit has changed. Delete allocated extensions.
2110 ExternalReference delete_extensions = 2113 ExternalReference delete_extensions =
2111 ExternalReference::delete_handle_scope_extensions(isolate()); 2114 ExternalReference::delete_handle_scope_extensions(isolate());
2112 bind(&delete_allocated_handles); 2115 bind(&delete_allocated_handles);
2113 mov(Operand::StaticVariable(limit_address), edi); 2116 mov(Operand::StaticVariable(limit_address), edi);
2114 mov(edi, eax); 2117 mov(edi, eax);
2115 mov(Operand(esp, 0), 2118 mov(Operand(esp, 0),
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after
3153 j(greater, &no_info_available); 3156 j(greater, &no_info_available);
3154 cmp(MemOperand(scratch_reg, -AllocationSiteInfo::kSize), 3157 cmp(MemOperand(scratch_reg, -AllocationSiteInfo::kSize),
3155 Immediate(Handle<Map>(isolate()->heap()->allocation_site_info_map()))); 3158 Immediate(Handle<Map>(isolate()->heap()->allocation_site_info_map())));
3156 bind(&no_info_available); 3159 bind(&no_info_available);
3157 } 3160 }
3158 3161
3159 3162
3160 } } // namespace v8::internal 3163 } } // namespace v8::internal
3161 3164
3162 #endif // V8_TARGET_ARCH_IA32 3165 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698