OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 | 1323 |
1324 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { | 1324 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { |
1325 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); | 1325 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); |
1326 } | 1326 } |
1327 | 1327 |
1328 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { | 1328 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { |
1329 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); | 1329 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); |
1330 } | 1330 } |
1331 | 1331 |
1332 // static | 1332 // static |
1333 void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm, | |
1334 int field_index) { | |
1335 // ----------- S t a t e ------------- | |
1336 // -- rax : number of arguments | |
1337 // -- rdi : function | |
1338 // -- rsi : context | |
1339 // -- rsp[0] : return address | |
1340 // -- rsp[8] : receiver | |
1341 // ----------------------------------- | |
1342 | |
1343 // 1. Load receiver into rax and check that it's actually a JSDate object. | |
1344 Label receiver_not_date; | |
1345 { | |
1346 StackArgumentsAccessor args(rsp, 0); | |
1347 __ movp(rax, args.GetReceiverOperand()); | |
1348 __ JumpIfSmi(rax, &receiver_not_date); | |
1349 __ CmpObjectType(rax, JS_DATE_TYPE, rbx); | |
1350 __ j(not_equal, &receiver_not_date); | |
1351 } | |
1352 | |
1353 // 2. Load the specified date field, falling back to the runtime as necessary. | |
1354 if (field_index == JSDate::kDateValue) { | |
1355 __ movp(rax, FieldOperand(rax, JSDate::kValueOffset)); | |
1356 } else { | |
1357 if (field_index < JSDate::kFirstUncachedField) { | |
1358 Label stamp_mismatch; | |
1359 __ Load(rdx, ExternalReference::date_cache_stamp(masm->isolate())); | |
1360 __ cmpp(rdx, FieldOperand(rax, JSDate::kCacheStampOffset)); | |
1361 __ j(not_equal, &stamp_mismatch, Label::kNear); | |
1362 __ movp(rax, FieldOperand( | |
1363 rax, JSDate::kValueOffset + field_index * kPointerSize)); | |
1364 __ ret(1 * kPointerSize); | |
1365 __ bind(&stamp_mismatch); | |
1366 } | |
1367 FrameScope scope(masm, StackFrame::INTERNAL); | |
1368 __ PrepareCallCFunction(2); | |
1369 __ Move(arg_reg_1, rax); | |
1370 __ Move(arg_reg_2, Smi::FromInt(field_index)); | |
1371 __ CallCFunction( | |
1372 ExternalReference::get_date_field_function(masm->isolate()), 2); | |
1373 } | |
1374 __ ret(1 * kPointerSize); | |
1375 | |
1376 // 3. Raise a TypeError if the receiver is not a date. | |
1377 __ bind(&receiver_not_date); | |
1378 { | |
1379 FrameScope scope(masm, StackFrame::MANUAL); | |
1380 __ Move(rbx, Smi::FromInt(0)); | |
1381 __ EnterBuiltinFrame(rsi, rdi, rbx); | |
1382 __ CallRuntime(Runtime::kThrowNotDateError); | |
1383 | |
1384 // It's far from obvious, but this final trailing instruction after the call | |
1385 // is required for StackFrame::LookupCode to work correctly. To illustrate | |
1386 // why: if call were the final instruction in the code object, then the pc | |
1387 // (== return address) would point beyond the code object when the stack is | |
1388 // traversed. When we then try to look up the code object through | |
1389 // StackFrame::LookupCode, we actually return the next code object that | |
1390 // happens to be on the same page in memory. | |
1391 // TODO(jgruber): A proper fix for this would be nice. | |
1392 __ int3(); | |
1393 } | |
1394 } | |
1395 | |
1396 // static | |
1397 void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { | 1333 void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { |
1398 // ----------- S t a t e ------------- | 1334 // ----------- S t a t e ------------- |
1399 // -- rax : argc | 1335 // -- rax : argc |
1400 // -- rsp[0] : return address | 1336 // -- rsp[0] : return address |
1401 // -- rsp[8] : argArray | 1337 // -- rsp[8] : argArray |
1402 // -- rsp[16] : thisArg | 1338 // -- rsp[16] : thisArg |
1403 // -- rsp[24] : receiver | 1339 // -- rsp[24] : receiver |
1404 // ----------------------------------- | 1340 // ----------------------------------- |
1405 | 1341 |
1406 // 1. Load receiver into rdi, argArray into rax (if present), remove all | 1342 // 1. Load receiver into rdi, argArray into rax (if present), remove all |
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3124 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3060 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
3125 Generate_OnStackReplacementHelper(masm, true); | 3061 Generate_OnStackReplacementHelper(masm, true); |
3126 } | 3062 } |
3127 | 3063 |
3128 #undef __ | 3064 #undef __ |
3129 | 3065 |
3130 } // namespace internal | 3066 } // namespace internal |
3131 } // namespace v8 | 3067 } // namespace v8 |
3132 | 3068 |
3133 #endif // V8_TARGET_ARCH_X64 | 3069 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |