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

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

Issue 146213004: A64: Synchronize with r16849. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 // Get the return address from the stack and restore the frame pointer. 1108 // Get the return address from the stack and restore the frame pointer.
1109 mov(ecx, Operand(ebp, 1 * kPointerSize)); 1109 mov(ecx, Operand(ebp, 1 * kPointerSize));
1110 mov(ebp, Operand(ebp, 0 * kPointerSize)); 1110 mov(ebp, Operand(ebp, 0 * kPointerSize));
1111 1111
1112 // Pop the arguments and the receiver from the caller stack. 1112 // Pop the arguments and the receiver from the caller stack.
1113 lea(esp, Operand(esi, 1 * kPointerSize)); 1113 lea(esp, Operand(esi, 1 * kPointerSize));
1114 1114
1115 // Push the return address to get ready to return. 1115 // Push the return address to get ready to return.
1116 push(ecx); 1116 push(ecx);
1117 1117
1118 LeaveExitFrameEpilogue(); 1118 LeaveExitFrameEpilogue(true);
1119 } 1119 }
1120 1120
1121 1121
1122 void MacroAssembler::LeaveExitFrameEpilogue() { 1122 void MacroAssembler::LeaveExitFrameEpilogue(bool restore_context) {
1123 // Restore current context from top and clear it in debug mode. 1123 // Restore current context from top and clear it in debug mode.
1124 ExternalReference context_address(Isolate::kContextAddress, isolate()); 1124 ExternalReference context_address(Isolate::kContextAddress, isolate());
1125 mov(esi, Operand::StaticVariable(context_address)); 1125 if (restore_context) {
1126 mov(esi, Operand::StaticVariable(context_address));
1127 }
1126 #ifdef DEBUG 1128 #ifdef DEBUG
1127 mov(Operand::StaticVariable(context_address), Immediate(0)); 1129 mov(Operand::StaticVariable(context_address), Immediate(0));
1128 #endif 1130 #endif
1129 1131
1130 // Clear the top frame. 1132 // Clear the top frame.
1131 ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress, 1133 ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress,
1132 isolate()); 1134 isolate());
1133 mov(Operand::StaticVariable(c_entry_fp_address), Immediate(0)); 1135 mov(Operand::StaticVariable(c_entry_fp_address), Immediate(0));
1134 } 1136 }
1135 1137
1136 1138
1137 void MacroAssembler::LeaveApiExitFrame() { 1139 void MacroAssembler::LeaveApiExitFrame(bool restore_context) {
1138 mov(esp, ebp); 1140 mov(esp, ebp);
1139 pop(ebp); 1141 pop(ebp);
1140 1142
1141 LeaveExitFrameEpilogue(); 1143 LeaveExitFrameEpilogue(restore_context);
1142 } 1144 }
1143 1145
1144 1146
1145 void MacroAssembler::PushTryHandler(StackHandler::Kind kind, 1147 void MacroAssembler::PushTryHandler(StackHandler::Kind kind,
1146 int handler_index) { 1148 int handler_index) {
1147 // Adjust this code if not the case. 1149 // Adjust this code if not the case.
1148 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); 1150 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize);
1149 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); 1151 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
1150 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); 1152 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize);
1151 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); 1153 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize);
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 2222
2221 2223
2222 void MacroAssembler::PrepareCallApiFunction(int argc) { 2224 void MacroAssembler::PrepareCallApiFunction(int argc) {
2223 EnterApiExitFrame(argc); 2225 EnterApiExitFrame(argc);
2224 if (emit_debug_code()) { 2226 if (emit_debug_code()) {
2225 mov(esi, Immediate(BitCast<int32_t>(kZapValue))); 2227 mov(esi, Immediate(BitCast<int32_t>(kZapValue)));
2226 } 2228 }
2227 } 2229 }
2228 2230
2229 2231
2230 void MacroAssembler::CallApiFunctionAndReturn(Address function_address, 2232 void MacroAssembler::CallApiFunctionAndReturn(
2231 Address thunk_address, 2233 Address function_address,
2232 Operand thunk_last_arg, 2234 Address thunk_address,
2233 int stack_space, 2235 Operand thunk_last_arg,
2234 int return_value_offset) { 2236 int stack_space,
2237 Operand return_value_operand,
2238 Operand* context_restore_operand) {
2235 ExternalReference next_address = 2239 ExternalReference next_address =
2236 ExternalReference::handle_scope_next_address(isolate()); 2240 ExternalReference::handle_scope_next_address(isolate());
2237 ExternalReference limit_address = 2241 ExternalReference limit_address =
2238 ExternalReference::handle_scope_limit_address(isolate()); 2242 ExternalReference::handle_scope_limit_address(isolate());
2239 ExternalReference level_address = 2243 ExternalReference level_address =
2240 ExternalReference::handle_scope_level_address(isolate()); 2244 ExternalReference::handle_scope_level_address(isolate());
2241 2245
2242 // Allocate HandleScope in callee-save registers. 2246 // Allocate HandleScope in callee-save registers.
2243 mov(ebx, Operand::StaticVariable(next_address)); 2247 mov(ebx, Operand::StaticVariable(next_address));
2244 mov(edi, Operand::StaticVariable(limit_address)); 2248 mov(edi, Operand::StaticVariable(limit_address));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 PushSafepointRegisters(); 2284 PushSafepointRegisters();
2281 PrepareCallCFunction(1, eax); 2285 PrepareCallCFunction(1, eax);
2282 mov(Operand(esp, 0), 2286 mov(Operand(esp, 0),
2283 Immediate(ExternalReference::isolate_address(isolate()))); 2287 Immediate(ExternalReference::isolate_address(isolate())));
2284 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); 2288 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1);
2285 PopSafepointRegisters(); 2289 PopSafepointRegisters();
2286 } 2290 }
2287 2291
2288 Label prologue; 2292 Label prologue;
2289 // Load the value from ReturnValue 2293 // Load the value from ReturnValue
2290 mov(eax, Operand(ebp, return_value_offset * kPointerSize)); 2294 mov(eax, return_value_operand);
2291 2295
2292 Label promote_scheduled_exception; 2296 Label promote_scheduled_exception;
2297 Label exception_handled;
2293 Label delete_allocated_handles; 2298 Label delete_allocated_handles;
2294 Label leave_exit_frame; 2299 Label leave_exit_frame;
2295 2300
2296 bind(&prologue); 2301 bind(&prologue);
2297 // No more valid handles (the result handle was the last one). Restore 2302 // No more valid handles (the result handle was the last one). Restore
2298 // previous handle scope. 2303 // previous handle scope.
2299 mov(Operand::StaticVariable(next_address), ebx); 2304 mov(Operand::StaticVariable(next_address), ebx);
2300 sub(Operand::StaticVariable(level_address), Immediate(1)); 2305 sub(Operand::StaticVariable(level_address), Immediate(1));
2301 Assert(above_equal, kInvalidHandleScopeLevel); 2306 Assert(above_equal, kInvalidHandleScopeLevel);
2302 cmp(edi, Operand::StaticVariable(limit_address)); 2307 cmp(edi, Operand::StaticVariable(limit_address));
2303 j(not_equal, &delete_allocated_handles); 2308 j(not_equal, &delete_allocated_handles);
2304 bind(&leave_exit_frame); 2309 bind(&leave_exit_frame);
2305 2310
2306 // Check if the function scheduled an exception. 2311 // Check if the function scheduled an exception.
2307 ExternalReference scheduled_exception_address = 2312 ExternalReference scheduled_exception_address =
2308 ExternalReference::scheduled_exception_address(isolate()); 2313 ExternalReference::scheduled_exception_address(isolate());
2309 cmp(Operand::StaticVariable(scheduled_exception_address), 2314 cmp(Operand::StaticVariable(scheduled_exception_address),
2310 Immediate(isolate()->factory()->the_hole_value())); 2315 Immediate(isolate()->factory()->the_hole_value()));
2311 j(not_equal, &promote_scheduled_exception); 2316 j(not_equal, &promote_scheduled_exception);
2317 bind(&exception_handled);
2312 2318
2313 #if ENABLE_EXTRA_CHECKS 2319 #if ENABLE_EXTRA_CHECKS
2314 // Check if the function returned a valid JavaScript value. 2320 // Check if the function returned a valid JavaScript value.
2315 Label ok; 2321 Label ok;
2316 Register return_value = eax; 2322 Register return_value = eax;
2317 Register map = ecx; 2323 Register map = ecx;
2318 2324
2319 JumpIfSmi(return_value, &ok, Label::kNear); 2325 JumpIfSmi(return_value, &ok, Label::kNear);
2320 mov(map, FieldOperand(return_value, HeapObject::kMapOffset)); 2326 mov(map, FieldOperand(return_value, HeapObject::kMapOffset));
2321 2327
(...skipping 16 matching lines...) Expand all
2338 j(equal, &ok, Label::kNear); 2344 j(equal, &ok, Label::kNear);
2339 2345
2340 cmp(return_value, isolate()->factory()->null_value()); 2346 cmp(return_value, isolate()->factory()->null_value());
2341 j(equal, &ok, Label::kNear); 2347 j(equal, &ok, Label::kNear);
2342 2348
2343 Abort(kAPICallReturnedInvalidObject); 2349 Abort(kAPICallReturnedInvalidObject);
2344 2350
2345 bind(&ok); 2351 bind(&ok);
2346 #endif 2352 #endif
2347 2353
2348 LeaveApiExitFrame(); 2354 bool restore_context = context_restore_operand != NULL;
2355 if (restore_context) {
2356 mov(esi, *context_restore_operand);
2357 }
2358 LeaveApiExitFrame(!restore_context);
2349 ret(stack_space * kPointerSize); 2359 ret(stack_space * kPointerSize);
2350 2360
2351 bind(&promote_scheduled_exception); 2361 bind(&promote_scheduled_exception);
2352 TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1); 2362 {
2363 FrameScope frame(this, StackFrame::INTERNAL);
2364 CallRuntime(Runtime::kPromoteScheduledException, 0);
2365 }
2366 jmp(&exception_handled);
2353 2367
2354 // HandleScope limit has changed. Delete allocated extensions. 2368 // HandleScope limit has changed. Delete allocated extensions.
2355 ExternalReference delete_extensions = 2369 ExternalReference delete_extensions =
2356 ExternalReference::delete_handle_scope_extensions(isolate()); 2370 ExternalReference::delete_handle_scope_extensions(isolate());
2357 bind(&delete_allocated_handles); 2371 bind(&delete_allocated_handles);
2358 mov(Operand::StaticVariable(limit_address), edi); 2372 mov(Operand::StaticVariable(limit_address), edi);
2359 mov(edi, eax); 2373 mov(edi, eax);
2360 mov(Operand(esp, 0), 2374 mov(Operand(esp, 0),
2361 Immediate(ExternalReference::isolate_address(isolate()))); 2375 Immediate(ExternalReference::isolate_address(isolate())));
2362 mov(eax, Immediate(delete_extensions)); 2376 mov(eax, Immediate(delete_extensions));
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
3002 Register scratch, 3016 Register scratch,
3003 int power) { 3017 int power) {
3004 ASSERT(is_uintn(power + HeapNumber::kExponentBias, 3018 ASSERT(is_uintn(power + HeapNumber::kExponentBias,
3005 HeapNumber::kExponentBits)); 3019 HeapNumber::kExponentBits));
3006 mov(scratch, Immediate(power + HeapNumber::kExponentBias)); 3020 mov(scratch, Immediate(power + HeapNumber::kExponentBias));
3007 movd(dst, scratch); 3021 movd(dst, scratch);
3008 psllq(dst, HeapNumber::kMantissaBits); 3022 psllq(dst, HeapNumber::kMantissaBits);
3009 } 3023 }
3010 3024
3011 3025
3026 void MacroAssembler::LookupNumberStringCache(Register object,
3027 Register result,
3028 Register scratch1,
3029 Register scratch2,
3030 Label* not_found) {
3031 // Use of registers. Register result is used as a temporary.
3032 Register number_string_cache = result;
3033 Register mask = scratch1;
3034 Register scratch = scratch2;
3035
3036 // Load the number string cache.
3037 LoadRoot(number_string_cache, Heap::kNumberStringCacheRootIndex);
3038 // Make the hash mask from the length of the number string cache. It
3039 // contains two elements (number and string) for each cache entry.
3040 mov(mask, FieldOperand(number_string_cache, FixedArray::kLengthOffset));
3041 shr(mask, kSmiTagSize + 1); // Untag length and divide it by two.
3042 sub(mask, Immediate(1)); // Make mask.
3043
3044 // Calculate the entry in the number string cache. The hash value in the
3045 // number string cache for smis is just the smi value, and the hash for
3046 // doubles is the xor of the upper and lower words. See
3047 // Heap::GetNumberStringCache.
3048 Label smi_hash_calculated;
3049 Label load_result_from_cache;
3050 Label not_smi;
3051 STATIC_ASSERT(kSmiTag == 0);
3052 JumpIfNotSmi(object, &not_smi, Label::kNear);
3053 mov(scratch, object);
3054 SmiUntag(scratch);
3055 jmp(&smi_hash_calculated, Label::kNear);
3056 bind(&not_smi);
3057 cmp(FieldOperand(object, HeapObject::kMapOffset),
3058 isolate()->factory()->heap_number_map());
3059 j(not_equal, not_found);
3060 STATIC_ASSERT(8 == kDoubleSize);
3061 mov(scratch, FieldOperand(object, HeapNumber::kValueOffset));
3062 xor_(scratch, FieldOperand(object, HeapNumber::kValueOffset + 4));
3063 // Object is heap number and hash is now in scratch. Calculate cache index.
3064 and_(scratch, mask);
3065 Register index = scratch;
3066 Register probe = mask;
3067 mov(probe,
3068 FieldOperand(number_string_cache,
3069 index,
3070 times_twice_pointer_size,
3071 FixedArray::kHeaderSize));
3072 JumpIfSmi(probe, not_found);
3073 if (CpuFeatures::IsSupported(SSE2)) {
3074 CpuFeatureScope fscope(this, SSE2);
3075 movdbl(xmm0, FieldOperand(object, HeapNumber::kValueOffset));
3076 ucomisd(xmm0, FieldOperand(probe, HeapNumber::kValueOffset));
3077 } else {
3078 fld_d(FieldOperand(object, HeapNumber::kValueOffset));
3079 fld_d(FieldOperand(probe, HeapNumber::kValueOffset));
3080 FCmp();
3081 }
3082 j(parity_even, not_found); // Bail out if NaN is involved.
3083 j(not_equal, not_found); // The cache did not contain this value.
3084 jmp(&load_result_from_cache, Label::kNear);
3085
3086 bind(&smi_hash_calculated);
3087 // Object is smi and hash is now in scratch. Calculate cache index.
3088 and_(scratch, mask);
3089 // Check if the entry is the smi we are looking for.
3090 cmp(object,
3091 FieldOperand(number_string_cache,
3092 index,
3093 times_twice_pointer_size,
3094 FixedArray::kHeaderSize));
3095 j(not_equal, not_found);
3096
3097 // Get the result from the cache.
3098 bind(&load_result_from_cache);
3099 mov(result,
3100 FieldOperand(number_string_cache,
3101 index,
3102 times_twice_pointer_size,
3103 FixedArray::kHeaderSize + kPointerSize));
3104 IncrementCounter(isolate()->counters()->number_to_string_native(), 1);
3105 }
3106
3107
3012 void MacroAssembler::JumpIfInstanceTypeIsNotSequentialAscii( 3108 void MacroAssembler::JumpIfInstanceTypeIsNotSequentialAscii(
3013 Register instance_type, 3109 Register instance_type,
3014 Register scratch, 3110 Register scratch,
3015 Label* failure) { 3111 Label* failure) {
3016 if (!scratch.is(instance_type)) { 3112 if (!scratch.is(instance_type)) {
3017 mov(scratch, instance_type); 3113 mov(scratch, instance_type);
3018 } 3114 }
3019 and_(scratch, 3115 and_(scratch,
3020 kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask); 3116 kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask);
3021 cmp(scratch, kStringTag | kSeqStringTag | kOneByteStringTag); 3117 cmp(scratch, kStringTag | kSeqStringTag | kOneByteStringTag);
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
3430 j(greater, &no_memento_available); 3526 j(greater, &no_memento_available);
3431 cmp(MemOperand(scratch_reg, -AllocationMemento::kSize), 3527 cmp(MemOperand(scratch_reg, -AllocationMemento::kSize),
3432 Immediate(Handle<Map>(isolate()->heap()->allocation_memento_map()))); 3528 Immediate(Handle<Map>(isolate()->heap()->allocation_memento_map())));
3433 bind(&no_memento_available); 3529 bind(&no_memento_available);
3434 } 3530 }
3435 3531
3436 3532
3437 } } // namespace v8::internal 3533 } } // namespace v8::internal
3438 3534
3439 #endif // V8_TARGET_ARCH_IA32 3535 #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