| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 2304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2315 // Push the return address to get ready to return. | 2315 // Push the return address to get ready to return. |
| 2316 push(rcx); | 2316 push(rcx); |
| 2317 | 2317 |
| 2318 // Clear the top frame. | 2318 // Clear the top frame. |
| 2319 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); | 2319 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); |
| 2320 movq(kScratchRegister, c_entry_fp_address); | 2320 movq(kScratchRegister, c_entry_fp_address); |
| 2321 movq(Operand(kScratchRegister, 0), Immediate(0)); | 2321 movq(Operand(kScratchRegister, 0), Immediate(0)); |
| 2322 } | 2322 } |
| 2323 | 2323 |
| 2324 | 2324 |
| 2325 Register MacroAssembler::CheckMaps(JSObject* object, | |
| 2326 Register object_reg, | |
| 2327 JSObject* holder, | |
| 2328 Register holder_reg, | |
| 2329 Register scratch, | |
| 2330 int save_at_depth, | |
| 2331 Label* miss) { | |
| 2332 // Make sure there's no overlap between scratch and the other | |
| 2333 // registers. | |
| 2334 ASSERT(!scratch.is(object_reg) && !scratch.is(holder_reg)); | |
| 2335 | |
| 2336 // Keep track of the current object in register reg. On the first | |
| 2337 // iteration, reg is an alias for object_reg, on later iterations, | |
| 2338 // it is an alias for holder_reg. | |
| 2339 Register reg = object_reg; | |
| 2340 int depth = 0; | |
| 2341 | |
| 2342 if (save_at_depth == depth) { | |
| 2343 movq(Operand(rsp, kPointerSize), object_reg); | |
| 2344 } | |
| 2345 | |
| 2346 // Check the maps in the prototype chain. | |
| 2347 // Traverse the prototype chain from the object and do map checks. | |
| 2348 while (object != holder) { | |
| 2349 depth++; | |
| 2350 | |
| 2351 // Only global objects and objects that do not require access | |
| 2352 // checks are allowed in stubs. | |
| 2353 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); | |
| 2354 | |
| 2355 JSObject* prototype = JSObject::cast(object->GetPrototype()); | |
| 2356 if (Heap::InNewSpace(prototype)) { | |
| 2357 // Get the map of the current object. | |
| 2358 movq(scratch, FieldOperand(reg, HeapObject::kMapOffset)); | |
| 2359 Cmp(scratch, Handle<Map>(object->map())); | |
| 2360 // Branch on the result of the map check. | |
| 2361 j(not_equal, miss); | |
| 2362 // Check access rights to the global object. This has to happen | |
| 2363 // after the map check so that we know that the object is | |
| 2364 // actually a global object. | |
| 2365 if (object->IsJSGlobalProxy()) { | |
| 2366 CheckAccessGlobalProxy(reg, scratch, miss); | |
| 2367 | |
| 2368 // Restore scratch register to be the map of the object. | |
| 2369 // We load the prototype from the map in the scratch register. | |
| 2370 movq(scratch, FieldOperand(reg, HeapObject::kMapOffset)); | |
| 2371 } | |
| 2372 // The prototype is in new space; we cannot store a reference | |
| 2373 // to it in the code. Load it from the map. | |
| 2374 reg = holder_reg; // from now the object is in holder_reg | |
| 2375 movq(reg, FieldOperand(scratch, Map::kPrototypeOffset)); | |
| 2376 | |
| 2377 } else { | |
| 2378 // Check the map of the current object. | |
| 2379 Cmp(FieldOperand(reg, HeapObject::kMapOffset), | |
| 2380 Handle<Map>(object->map())); | |
| 2381 // Branch on the result of the map check. | |
| 2382 j(not_equal, miss); | |
| 2383 // Check access rights to the global object. This has to happen | |
| 2384 // after the map check so that we know that the object is | |
| 2385 // actually a global object. | |
| 2386 if (object->IsJSGlobalProxy()) { | |
| 2387 CheckAccessGlobalProxy(reg, scratch, miss); | |
| 2388 } | |
| 2389 // The prototype is in old space; load it directly. | |
| 2390 reg = holder_reg; // from now the object is in holder_reg | |
| 2391 Move(reg, Handle<JSObject>(prototype)); | |
| 2392 } | |
| 2393 | |
| 2394 if (save_at_depth == depth) { | |
| 2395 movq(Operand(rsp, kPointerSize), reg); | |
| 2396 } | |
| 2397 | |
| 2398 // Go to the next object in the prototype chain. | |
| 2399 object = prototype; | |
| 2400 } | |
| 2401 | |
| 2402 // Check the holder map. | |
| 2403 Cmp(FieldOperand(reg, HeapObject::kMapOffset), Handle<Map>(holder->map())); | |
| 2404 j(not_equal, miss); | |
| 2405 | |
| 2406 // Log the check depth. | |
| 2407 LOG(IntEvent("check-maps-depth", depth + 1)); | |
| 2408 | |
| 2409 // Perform security check for access to the global object and return | |
| 2410 // the holder register. | |
| 2411 ASSERT(object == holder); | |
| 2412 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); | |
| 2413 if (object->IsJSGlobalProxy()) { | |
| 2414 CheckAccessGlobalProxy(reg, scratch, miss); | |
| 2415 } | |
| 2416 return reg; | |
| 2417 } | |
| 2418 | |
| 2419 | |
| 2420 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, | 2325 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, |
| 2421 Register scratch, | 2326 Register scratch, |
| 2422 Label* miss) { | 2327 Label* miss) { |
| 2423 Label same_contexts; | 2328 Label same_contexts; |
| 2424 | 2329 |
| 2425 ASSERT(!holder_reg.is(scratch)); | 2330 ASSERT(!holder_reg.is(scratch)); |
| 2426 ASSERT(!scratch.is(kScratchRegister)); | 2331 ASSERT(!scratch.is(kScratchRegister)); |
| 2427 // Load current lexical context from the stack frame. | 2332 // Load current lexical context from the stack frame. |
| 2428 movq(scratch, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2333 movq(scratch, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 2429 | 2334 |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2879 CPU::FlushICache(address_, size_); | 2784 CPU::FlushICache(address_, size_); |
| 2880 | 2785 |
| 2881 // Check that the code was patched as expected. | 2786 // Check that the code was patched as expected. |
| 2882 ASSERT(masm_.pc_ == address_ + size_); | 2787 ASSERT(masm_.pc_ == address_ + size_); |
| 2883 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2788 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 2884 } | 2789 } |
| 2885 | 2790 |
| 2886 } } // namespace v8::internal | 2791 } } // namespace v8::internal |
| 2887 | 2792 |
| 2888 #endif // V8_TARGET_ARCH_X64 | 2793 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |