| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 if (FLAG_inline_new) { | 70 if (FLAG_inline_new) { |
| 71 Label undo_allocation; | 71 Label undo_allocation; |
| 72 ExternalReference debug_step_in_fp = | 72 ExternalReference debug_step_in_fp = |
| 73 ExternalReference::debug_step_in_fp_address(); | 73 ExternalReference::debug_step_in_fp_address(); |
| 74 __ cmp(Operand::StaticVariable(debug_step_in_fp), Immediate(0)); | 74 __ cmp(Operand::StaticVariable(debug_step_in_fp), Immediate(0)); |
| 75 __ j(not_equal, &rt_call); | 75 __ j(not_equal, &rt_call); |
| 76 // Check that function is not a Smi. | 76 // Check that function is not a Smi. |
| 77 __ test(edi, Immediate(kSmiTagMask)); | 77 __ test(edi, Immediate(kSmiTagMask)); |
| 78 __ j(zero, &rt_call); | 78 __ j(zero, &rt_call); |
| 79 // Check that function is a JSFunction | 79 // Check that function is a JSFunction |
| 80 __ mov(eax, FieldOperand(edi, JSFunction::kMapOffset)); | 80 __ CmpObjectType(edi, JS_FUNCTION_TYPE, eax); |
| 81 __ movzx_b(eax, FieldOperand(eax, Map::kInstanceTypeOffset)); | |
| 82 __ cmp(eax, JS_FUNCTION_TYPE); | |
| 83 __ j(not_equal, &rt_call); | 81 __ j(not_equal, &rt_call); |
| 84 | 82 |
| 85 // Verified that the constructor is a JSFunction. | 83 // Verified that the constructor is a JSFunction. |
| 86 // Load the initial map and verify that it is in fact a map. | 84 // Load the initial map and verify that it is in fact a map. |
| 87 // edi: constructor | 85 // edi: constructor |
| 88 __ mov(eax, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); | 86 __ mov(eax, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); |
| 89 // Will both indicate a NULL and a Smi | 87 // Will both indicate a NULL and a Smi |
| 90 __ test(eax, Immediate(kSmiTagMask)); | 88 __ test(eax, Immediate(kSmiTagMask)); |
| 91 __ j(zero, &rt_call); | 89 __ j(zero, &rt_call); |
| 92 // edi: constructor | 90 // edi: constructor |
| 93 // eax: initial map (if proven valid below) | 91 // eax: initial map (if proven valid below) |
| 94 __ mov(ebx, FieldOperand(eax, JSFunction::kMapOffset)); | 92 __ CmpObjectType(eax, MAP_TYPE, ebx); |
| 95 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | |
| 96 __ cmp(ebx, MAP_TYPE); | |
| 97 __ j(not_equal, &rt_call); | 93 __ j(not_equal, &rt_call); |
| 98 | 94 |
| 99 // Check that the constructor is not constructing a JSFunction (see comments | 95 // Check that the constructor is not constructing a JSFunction (see comments |
| 100 // in Runtime_NewObject in runtime.cc). In which case the initial map's | 96 // in Runtime_NewObject in runtime.cc). In which case the initial map's |
| 101 // instance type would be JS_FUNCTION_TYPE. | 97 // instance type would be JS_FUNCTION_TYPE. |
| 102 // edi: constructor | 98 // edi: constructor |
| 103 // eax: initial map | 99 // eax: initial map |
| 104 __ movzx_b(ebx, FieldOperand(eax, Map::kInstanceTypeOffset)); | 100 __ CmpInstanceType(eax, JS_FUNCTION_TYPE); |
| 105 __ cmp(ebx, JS_FUNCTION_TYPE); | |
| 106 __ j(equal, &rt_call); | 101 __ j(equal, &rt_call); |
| 107 | 102 |
| 108 // Now allocate the JSObject on the heap. | 103 // Now allocate the JSObject on the heap. |
| 109 // edi: constructor | 104 // edi: constructor |
| 110 // eax: initial map | 105 // eax: initial map |
| 111 __ movzx_b(edi, FieldOperand(eax, Map::kInstanceSizeOffset)); | 106 __ movzx_b(edi, FieldOperand(eax, Map::kInstanceSizeOffset)); |
| 112 __ shl(edi, kPointerSizeLog2); | 107 __ shl(edi, kPointerSizeLog2); |
| 113 // Make sure that the maximum heap object size will never cause us | 108 // Make sure that the maximum heap object size will never cause us |
| 114 // problem here, because it is always greater than the maximum | 109 // problem here, because it is always greater than the maximum |
| 115 // instance size that can be represented in a byte. | 110 // instance size that can be represented in a byte. |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 __ inc(eax); | 379 __ inc(eax); |
| 385 __ bind(&done); | 380 __ bind(&done); |
| 386 } | 381 } |
| 387 | 382 |
| 388 // 2. Get the function to call from the stack. | 383 // 2. Get the function to call from the stack. |
| 389 { Label done, non_function, function; | 384 { Label done, non_function, function; |
| 390 // +1 ~ return address. | 385 // +1 ~ return address. |
| 391 __ mov(edi, Operand(esp, eax, times_4, +1 * kPointerSize)); | 386 __ mov(edi, Operand(esp, eax, times_4, +1 * kPointerSize)); |
| 392 __ test(edi, Immediate(kSmiTagMask)); | 387 __ test(edi, Immediate(kSmiTagMask)); |
| 393 __ j(zero, &non_function, not_taken); | 388 __ j(zero, &non_function, not_taken); |
| 394 __ mov(ecx, FieldOperand(edi, HeapObject::kMapOffset)); // get the map | 389 __ CmpObjectType(edi,JS_FUNCTION_TYPE, ecx); |
| 395 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); | |
| 396 __ cmp(ecx, JS_FUNCTION_TYPE); | |
| 397 __ j(equal, &function, taken); | 390 __ j(equal, &function, taken); |
| 398 | 391 |
| 399 // Non-function called: Clear the function to force exception. | 392 // Non-function called: Clear the function to force exception. |
| 400 __ bind(&non_function); | 393 __ bind(&non_function); |
| 401 __ xor_(edi, Operand(edi)); | 394 __ xor_(edi, Operand(edi)); |
| 402 __ jmp(&done); | 395 __ jmp(&done); |
| 403 | 396 |
| 404 // Function called: Change context eagerly to get the right global object. | 397 // Function called: Change context eagerly to get the right global object. |
| 405 __ bind(&function); | 398 __ bind(&function); |
| 406 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 399 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 // Dont adapt arguments. | 747 // Dont adapt arguments. |
| 755 // ------------------------------------------- | 748 // ------------------------------------------- |
| 756 __ bind(&dont_adapt_arguments); | 749 __ bind(&dont_adapt_arguments); |
| 757 __ jmp(Operand(edx)); | 750 __ jmp(Operand(edx)); |
| 758 } | 751 } |
| 759 | 752 |
| 760 | 753 |
| 761 #undef __ | 754 #undef __ |
| 762 | 755 |
| 763 } } // namespace v8::internal | 756 } } // namespace v8::internal |
| OLD | NEW |