| 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 2312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2323 | 2323 |
| 2324 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 2324 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
| 2325 // Cache the called function in a feedback vector slot. Cache states | 2325 // Cache the called function in a feedback vector slot. Cache states |
| 2326 // are uninitialized, monomorphic (indicated by a JSFunction), and | 2326 // are uninitialized, monomorphic (indicated by a JSFunction), and |
| 2327 // megamorphic. | 2327 // megamorphic. |
| 2328 // eax : number of arguments to the construct function | 2328 // eax : number of arguments to the construct function |
| 2329 // ebx : Feedback vector | 2329 // ebx : Feedback vector |
| 2330 // edx : slot in feedback vector (Smi) | 2330 // edx : slot in feedback vector (Smi) |
| 2331 // edi : the function to call | 2331 // edi : the function to call |
| 2332 Isolate* isolate = masm->isolate(); | 2332 Isolate* isolate = masm->isolate(); |
| 2333 Label initialize, done, miss, megamorphic, not_array_function; | 2333 Label check_array, initialize_array, initialize_non_array, megamorphic, done; |
| 2334 | 2334 |
| 2335 // Load the cache state into ecx. | 2335 // Load the cache state into ecx. |
| 2336 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, | 2336 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, |
| 2337 FixedArray::kHeaderSize)); | 2337 FixedArray::kHeaderSize)); |
| 2338 | 2338 |
| 2339 // A monomorphic cache hit or an already megamorphic state: invoke the | 2339 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 2340 // function without changing the state. | 2340 // function without changing the state. |
| 2341 __ cmp(ecx, edi); | 2341 __ cmp(ecx, edi); |
| 2342 __ j(equal, &done, Label::kFar); | 2342 __ j(equal, &done, Label::kFar); |
| 2343 __ cmp(ecx, Immediate(TypeFeedbackInfo::MegamorphicSentinel(isolate))); | 2343 __ cmp(ecx, Immediate(TypeFeedbackInfo::MegamorphicSentinel(isolate))); |
| 2344 __ j(equal, &done, Label::kFar); | 2344 __ j(equal, &done, Label::kFar); |
| 2345 | 2345 |
| 2346 // If we came here, we need to see if we are the array function. | 2346 // Load the global or builtins object from the current context and check |
| 2347 // If we didn't have a matching function, and we didn't find the megamorph | 2347 // if we're dealing with the Array function or not. |
| 2348 // sentinel, then we have in the slot either some other function or an | |
| 2349 // AllocationSite. Do a map check on the object in ecx. | |
| 2350 Handle<Map> allocation_site_map = | |
| 2351 masm->isolate()->factory()->allocation_site_map(); | |
| 2352 __ cmp(FieldOperand(ecx, 0), Immediate(allocation_site_map)); | |
| 2353 __ j(not_equal, &miss); | |
| 2354 | |
| 2355 // Load the global or builtins object from the current context | |
| 2356 __ LoadGlobalContext(ecx); | 2348 __ LoadGlobalContext(ecx); |
| 2357 // Make sure the function is the Array() function | |
| 2358 __ cmp(edi, Operand(ecx, | 2349 __ cmp(edi, Operand(ecx, |
| 2359 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); | 2350 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); |
| 2351 __ j(equal, &check_array); |
| 2352 |
| 2353 // Non-array cache: Reload the cache state and check it. |
| 2354 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, |
| 2355 FixedArray::kHeaderSize)); |
| 2356 __ cmp(ecx, Immediate(TypeFeedbackInfo::PremonomorphicSentinel(isolate))); |
| 2357 __ j(equal, &initialize_non_array); |
| 2358 __ cmp(ecx, Immediate(TypeFeedbackInfo::UninitializedSentinel(isolate))); |
| 2360 __ j(not_equal, &megamorphic); | 2359 __ j(not_equal, &megamorphic); |
| 2360 |
| 2361 // Non-array cache: Uninitialized -> premonomorphic. The sentinel is an |
| 2362 // immortal immovable object (null) so no write-barrier is needed. |
| 2363 __ mov(FieldOperand(ebx, edx, times_half_pointer_size, |
| 2364 FixedArray::kHeaderSize), |
| 2365 Immediate(TypeFeedbackInfo::PremonomorphicSentinel(isolate))); |
| 2361 __ jmp(&done, Label::kFar); | 2366 __ jmp(&done, Label::kFar); |
| 2362 | 2367 |
| 2363 __ bind(&miss); | 2368 // Array cache: Reload the cache state and check to see if we're in a |
| 2369 // monomorphic state where the state object is an AllocationSite object. |
| 2370 __ bind(&check_array); |
| 2371 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, |
| 2372 FixedArray::kHeaderSize)); |
| 2373 Handle<Map> allocation_site_map = isolate->factory()->allocation_site_map(); |
| 2374 __ cmp(FieldOperand(ecx, 0), Immediate(allocation_site_map)); |
| 2375 __ j(equal, &done, Label::kFar); |
| 2364 | 2376 |
| 2365 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 2377 // Array cache: Uninitialized or premonomorphic -> monomorphic. |
| 2366 // megamorphic. | |
| 2367 __ cmp(ecx, Immediate(TypeFeedbackInfo::UninitializedSentinel(isolate))); | 2378 __ cmp(ecx, Immediate(TypeFeedbackInfo::UninitializedSentinel(isolate))); |
| 2368 __ j(equal, &initialize); | 2379 __ j(equal, &initialize_array); |
| 2369 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 2380 __ cmp(ecx, Immediate(TypeFeedbackInfo::PremonomorphicSentinel(isolate))); |
| 2370 // write-barrier is needed. | 2381 __ j(equal, &initialize_array); |
| 2382 |
| 2383 // Both caches: Monomorphic -> megamorphic. The sentinel is an |
| 2384 // immortal immovable object (undefined) so no write-barrier is needed. |
| 2371 __ bind(&megamorphic); | 2385 __ bind(&megamorphic); |
| 2372 __ mov(FieldOperand(ebx, edx, times_half_pointer_size, | 2386 __ mov(FieldOperand(ebx, edx, times_half_pointer_size, |
| 2373 FixedArray::kHeaderSize), | 2387 FixedArray::kHeaderSize), |
| 2374 Immediate(TypeFeedbackInfo::MegamorphicSentinel(isolate))); | 2388 Immediate(TypeFeedbackInfo::MegamorphicSentinel(isolate))); |
| 2375 __ jmp(&done, Label::kFar); | 2389 __ jmp(&done, Label::kFar); |
| 2376 | 2390 |
| 2377 // An uninitialized cache is patched with the function or sentinel to | 2391 // Array cache: Uninitialized or premonomorphic -> monomorphic. |
| 2378 // indicate the ElementsKind if function is the Array constructor. | 2392 __ bind(&initialize_array); |
| 2379 __ bind(&initialize); | |
| 2380 __ LoadGlobalContext(ecx); | |
| 2381 // Make sure the function is the Array() function | |
| 2382 __ cmp(edi, Operand(ecx, | |
| 2383 Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX))); | |
| 2384 __ j(not_equal, ¬_array_function); | |
| 2385 | |
| 2386 // The target function is the Array constructor, | |
| 2387 // Create an AllocationSite if we don't already have it, store it in the slot. | |
| 2388 { | 2393 { |
| 2389 FrameScope scope(masm, StackFrame::INTERNAL); | 2394 FrameScope scope(masm, StackFrame::INTERNAL); |
| 2390 | 2395 |
| 2391 // Arguments register must be smi-tagged to call out. | 2396 // Arguments register must be smi-tagged to call out. |
| 2392 __ SmiTag(eax); | 2397 __ SmiTag(eax); |
| 2393 __ push(eax); | 2398 __ push(eax); |
| 2394 __ push(edi); | 2399 __ push(edi); |
| 2395 __ push(edx); | 2400 __ push(edx); |
| 2396 __ push(ebx); | 2401 __ push(ebx); |
| 2397 | 2402 |
| 2398 CreateAllocationSiteStub create_stub; | 2403 CreateAllocationSiteStub create_stub; |
| 2399 __ CallStub(&create_stub); | 2404 __ CallStub(&create_stub); |
| 2400 | 2405 |
| 2401 __ pop(ebx); | 2406 __ pop(ebx); |
| 2402 __ pop(edx); | 2407 __ pop(edx); |
| 2403 __ pop(edi); | 2408 __ pop(edi); |
| 2404 __ pop(eax); | 2409 __ pop(eax); |
| 2405 __ SmiUntag(eax); | 2410 __ SmiUntag(eax); |
| 2406 } | 2411 } |
| 2407 __ jmp(&done); | 2412 __ jmp(&done); |
| 2408 | 2413 |
| 2409 __ bind(¬_array_function); | 2414 // Non-array cache: Premonomorphic -> monomorphic. |
| 2415 __ bind(&initialize_non_array); |
| 2410 __ mov(FieldOperand(ebx, edx, times_half_pointer_size, | 2416 __ mov(FieldOperand(ebx, edx, times_half_pointer_size, |
| 2411 FixedArray::kHeaderSize), | 2417 FixedArray::kHeaderSize), |
| 2412 edi); | 2418 edi); |
| 2413 // We won't need edx or ebx anymore, just save edi | |
| 2414 __ push(edi); | 2419 __ push(edi); |
| 2415 __ push(ebx); | 2420 __ push(ebx); |
| 2416 __ push(edx); | 2421 __ push(edx); |
| 2417 __ RecordWriteArray(ebx, edi, edx, kDontSaveFPRegs, | 2422 __ RecordWriteArray(ebx, edi, edx, kDontSaveFPRegs, |
| 2418 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | 2423 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
| 2419 __ pop(edx); | 2424 __ pop(edx); |
| 2420 __ pop(ebx); | 2425 __ pop(ebx); |
| 2421 __ pop(edi); | 2426 __ pop(edi); |
| 2422 | 2427 |
| 2423 __ bind(&done); | 2428 __ bind(&done); |
| (...skipping 3034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5458 Operand(ebp, 7 * kPointerSize), | 5463 Operand(ebp, 7 * kPointerSize), |
| 5459 NULL); | 5464 NULL); |
| 5460 } | 5465 } |
| 5461 | 5466 |
| 5462 | 5467 |
| 5463 #undef __ | 5468 #undef __ |
| 5464 | 5469 |
| 5465 } } // namespace v8::internal | 5470 } } // namespace v8::internal |
| 5466 | 5471 |
| 5467 #endif // V8_TARGET_ARCH_IA32 | 5472 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |