| 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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 // parameter count to avoid emitting code to do the check. | 799 // parameter count to avoid emitting code to do the check. |
| 800 ParameterCount expected(0); | 800 ParameterCount expected(0); |
| 801 GetBuiltinEntry(rdx, id); | 801 GetBuiltinEntry(rdx, id); |
| 802 InvokeCode(rdx, expected, expected, flag, call_wrapper, CALL_AS_METHOD); | 802 InvokeCode(rdx, expected, expected, flag, call_wrapper, CALL_AS_METHOD); |
| 803 } | 803 } |
| 804 | 804 |
| 805 | 805 |
| 806 void MacroAssembler::GetBuiltinFunction(Register target, | 806 void MacroAssembler::GetBuiltinFunction(Register target, |
| 807 Builtins::JavaScript id) { | 807 Builtins::JavaScript id) { |
| 808 // Load the builtins object into target register. | 808 // Load the builtins object into target register. |
| 809 movq(target, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 809 movq(target, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 810 movq(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); | 810 movq(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); |
| 811 movq(target, FieldOperand(target, | 811 movq(target, FieldOperand(target, |
| 812 JSBuiltinsObject::OffsetOfFunctionWithId(id))); | 812 JSBuiltinsObject::OffsetOfFunctionWithId(id))); |
| 813 } | 813 } |
| 814 | 814 |
| 815 | 815 |
| 816 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { | 816 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { |
| 817 ASSERT(!target.is(rdi)); | 817 ASSERT(!target.is(rdi)); |
| 818 // Load the JavaScript builtin function from the builtins object. | 818 // Load the JavaScript builtin function from the builtins object. |
| 819 GetBuiltinFunction(rdi, id); | 819 GetBuiltinFunction(rdi, id); |
| (...skipping 2615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3435 ASSERT(!holder_reg.is(scratch)); | 3435 ASSERT(!holder_reg.is(scratch)); |
| 3436 ASSERT(!scratch.is(kScratchRegister)); | 3436 ASSERT(!scratch.is(kScratchRegister)); |
| 3437 // Load current lexical context from the stack frame. | 3437 // Load current lexical context from the stack frame. |
| 3438 movq(scratch, Operand(rbp, StandardFrameConstants::kContextOffset)); | 3438 movq(scratch, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 3439 | 3439 |
| 3440 // When generating debug code, make sure the lexical context is set. | 3440 // When generating debug code, make sure the lexical context is set. |
| 3441 if (emit_debug_code()) { | 3441 if (emit_debug_code()) { |
| 3442 cmpq(scratch, Immediate(0)); | 3442 cmpq(scratch, Immediate(0)); |
| 3443 Check(not_equal, "we should not have an empty lexical context"); | 3443 Check(not_equal, "we should not have an empty lexical context"); |
| 3444 } | 3444 } |
| 3445 // Load the native context of the current context. | 3445 // Load the global context of the current context. |
| 3446 int offset = | 3446 int offset = Context::kHeaderSize + Context::GLOBAL_INDEX * kPointerSize; |
| 3447 Context::kHeaderSize + Context::GLOBAL_OBJECT_INDEX * kPointerSize; | |
| 3448 movq(scratch, FieldOperand(scratch, offset)); | 3447 movq(scratch, FieldOperand(scratch, offset)); |
| 3449 movq(scratch, FieldOperand(scratch, GlobalObject::kNativeContextOffset)); | 3448 movq(scratch, FieldOperand(scratch, GlobalObject::kGlobalContextOffset)); |
| 3450 | 3449 |
| 3451 // Check the context is a native context. | 3450 // Check the context is a global context. |
| 3452 if (emit_debug_code()) { | 3451 if (emit_debug_code()) { |
| 3453 Cmp(FieldOperand(scratch, HeapObject::kMapOffset), | 3452 Cmp(FieldOperand(scratch, HeapObject::kMapOffset), |
| 3454 isolate()->factory()->native_context_map()); | 3453 isolate()->factory()->global_context_map()); |
| 3455 Check(equal, "JSGlobalObject::native_context should be a native context."); | 3454 Check(equal, "JSGlobalObject::global_context should be a global context."); |
| 3456 } | 3455 } |
| 3457 | 3456 |
| 3458 // Check if both contexts are the same. | 3457 // Check if both contexts are the same. |
| 3459 cmpq(scratch, FieldOperand(holder_reg, JSGlobalProxy::kNativeContextOffset)); | 3458 cmpq(scratch, FieldOperand(holder_reg, JSGlobalProxy::kContextOffset)); |
| 3460 j(equal, &same_contexts); | 3459 j(equal, &same_contexts); |
| 3461 | 3460 |
| 3462 // Compare security tokens. | 3461 // Compare security tokens. |
| 3463 // Check that the security token in the calling global object is | 3462 // Check that the security token in the calling global object is |
| 3464 // compatible with the security token in the receiving global | 3463 // compatible with the security token in the receiving global |
| 3465 // object. | 3464 // object. |
| 3466 | 3465 |
| 3467 // Check the context is a native context. | 3466 // Check the context is a global context. |
| 3468 if (emit_debug_code()) { | 3467 if (emit_debug_code()) { |
| 3469 // Preserve original value of holder_reg. | 3468 // Preserve original value of holder_reg. |
| 3470 push(holder_reg); | 3469 push(holder_reg); |
| 3471 movq(holder_reg, | 3470 movq(holder_reg, FieldOperand(holder_reg, JSGlobalProxy::kContextOffset)); |
| 3472 FieldOperand(holder_reg, JSGlobalProxy::kNativeContextOffset)); | |
| 3473 CompareRoot(holder_reg, Heap::kNullValueRootIndex); | 3471 CompareRoot(holder_reg, Heap::kNullValueRootIndex); |
| 3474 Check(not_equal, "JSGlobalProxy::context() should not be null."); | 3472 Check(not_equal, "JSGlobalProxy::context() should not be null."); |
| 3475 | 3473 |
| 3476 // Read the first word and compare to native_context_map(), | 3474 // Read the first word and compare to global_context_map(), |
| 3477 movq(holder_reg, FieldOperand(holder_reg, HeapObject::kMapOffset)); | 3475 movq(holder_reg, FieldOperand(holder_reg, HeapObject::kMapOffset)); |
| 3478 CompareRoot(holder_reg, Heap::kNativeContextMapRootIndex); | 3476 CompareRoot(holder_reg, Heap::kGlobalContextMapRootIndex); |
| 3479 Check(equal, "JSGlobalObject::native_context should be a native context."); | 3477 Check(equal, "JSGlobalObject::global_context should be a global context."); |
| 3480 pop(holder_reg); | 3478 pop(holder_reg); |
| 3481 } | 3479 } |
| 3482 | 3480 |
| 3483 movq(kScratchRegister, | 3481 movq(kScratchRegister, |
| 3484 FieldOperand(holder_reg, JSGlobalProxy::kNativeContextOffset)); | 3482 FieldOperand(holder_reg, JSGlobalProxy::kContextOffset)); |
| 3485 int token_offset = | 3483 int token_offset = |
| 3486 Context::kHeaderSize + Context::SECURITY_TOKEN_INDEX * kPointerSize; | 3484 Context::kHeaderSize + Context::SECURITY_TOKEN_INDEX * kPointerSize; |
| 3487 movq(scratch, FieldOperand(scratch, token_offset)); | 3485 movq(scratch, FieldOperand(scratch, token_offset)); |
| 3488 cmpq(scratch, FieldOperand(kScratchRegister, token_offset)); | 3486 cmpq(scratch, FieldOperand(kScratchRegister, token_offset)); |
| 3489 j(not_equal, miss); | 3487 j(not_equal, miss); |
| 3490 | 3488 |
| 3491 bind(&same_contexts); | 3489 bind(&same_contexts); |
| 3492 } | 3490 } |
| 3493 | 3491 |
| 3494 | 3492 |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4094 } | 4092 } |
| 4095 | 4093 |
| 4096 | 4094 |
| 4097 void MacroAssembler::LoadTransitionedArrayMapConditional( | 4095 void MacroAssembler::LoadTransitionedArrayMapConditional( |
| 4098 ElementsKind expected_kind, | 4096 ElementsKind expected_kind, |
| 4099 ElementsKind transitioned_kind, | 4097 ElementsKind transitioned_kind, |
| 4100 Register map_in_out, | 4098 Register map_in_out, |
| 4101 Register scratch, | 4099 Register scratch, |
| 4102 Label* no_map_match) { | 4100 Label* no_map_match) { |
| 4103 // Load the global or builtins object from the current context. | 4101 // Load the global or builtins object from the current context. |
| 4104 movq(scratch, | 4102 movq(scratch, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 4105 Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 4103 movq(scratch, FieldOperand(scratch, GlobalObject::kGlobalContextOffset)); |
| 4106 movq(scratch, FieldOperand(scratch, GlobalObject::kNativeContextOffset)); | |
| 4107 | 4104 |
| 4108 // Check that the function's map is the same as the expected cached map. | 4105 // Check that the function's map is the same as the expected cached map. |
| 4109 movq(scratch, Operand(scratch, | 4106 movq(scratch, Operand(scratch, |
| 4110 Context::SlotOffset(Context::JS_ARRAY_MAPS_INDEX))); | 4107 Context::SlotOffset(Context::JS_ARRAY_MAPS_INDEX))); |
| 4111 | 4108 |
| 4112 int offset = expected_kind * kPointerSize + | 4109 int offset = expected_kind * kPointerSize + |
| 4113 FixedArrayBase::kHeaderSize; | 4110 FixedArrayBase::kHeaderSize; |
| 4114 cmpq(map_in_out, FieldOperand(scratch, offset)); | 4111 cmpq(map_in_out, FieldOperand(scratch, offset)); |
| 4115 j(not_equal, no_map_match); | 4112 j(not_equal, no_map_match); |
| 4116 | 4113 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 4146 } | 4143 } |
| 4147 | 4144 |
| 4148 #ifdef _WIN64 | 4145 #ifdef _WIN64 |
| 4149 static const int kRegisterPassedArguments = 4; | 4146 static const int kRegisterPassedArguments = 4; |
| 4150 #else | 4147 #else |
| 4151 static const int kRegisterPassedArguments = 6; | 4148 static const int kRegisterPassedArguments = 6; |
| 4152 #endif | 4149 #endif |
| 4153 | 4150 |
| 4154 void MacroAssembler::LoadGlobalFunction(int index, Register function) { | 4151 void MacroAssembler::LoadGlobalFunction(int index, Register function) { |
| 4155 // Load the global or builtins object from the current context. | 4152 // Load the global or builtins object from the current context. |
| 4156 movq(function, | 4153 movq(function, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 4157 Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 4154 // Load the global context from the global or builtins object. |
| 4158 // Load the native context from the global or builtins object. | 4155 movq(function, FieldOperand(function, GlobalObject::kGlobalContextOffset)); |
| 4159 movq(function, FieldOperand(function, GlobalObject::kNativeContextOffset)); | 4156 // Load the function from the global context. |
| 4160 // Load the function from the native context. | |
| 4161 movq(function, Operand(function, Context::SlotOffset(index))); | 4157 movq(function, Operand(function, Context::SlotOffset(index))); |
| 4162 } | 4158 } |
| 4163 | 4159 |
| 4164 | 4160 |
| 4165 void MacroAssembler::LoadGlobalFunctionInitialMap(Register function, | 4161 void MacroAssembler::LoadGlobalFunctionInitialMap(Register function, |
| 4166 Register map) { | 4162 Register map) { |
| 4167 // Load the initial map. The global functions all have initial maps. | 4163 // Load the initial map. The global functions all have initial maps. |
| 4168 movq(map, FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | 4164 movq(map, FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); |
| 4169 if (emit_debug_code()) { | 4165 if (emit_debug_code()) { |
| 4170 Label ok, fail; | 4166 Label ok, fail; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4505 bind(&check_prototype); | 4501 bind(&check_prototype); |
| 4506 movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); | 4502 movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); |
| 4507 cmpq(rcx, null_value); | 4503 cmpq(rcx, null_value); |
| 4508 j(not_equal, &next); | 4504 j(not_equal, &next); |
| 4509 } | 4505 } |
| 4510 | 4506 |
| 4511 | 4507 |
| 4512 } } // namespace v8::internal | 4508 } } // namespace v8::internal |
| 4513 | 4509 |
| 4514 #endif // V8_TARGET_ARCH_X64 | 4510 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |