OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
8 | 8 |
9 #include "src/ic/call-optimization.h" | 9 #include "src/ic/call-optimization.h" |
10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
11 #include "src/ic/ic.h" | 11 #include "src/ic/ic.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 #define __ ACCESS_MASM(masm) | 16 #define __ ACCESS_MASM(masm) |
17 | 17 |
18 | 18 |
19 void NamedLoadHandlerCompiler::GenerateLoadViaGetter( | 19 void NamedLoadHandlerCompiler::GenerateLoadViaGetter( |
20 MacroAssembler* masm, Handle<HeapType> type, Register receiver, | 20 MacroAssembler* masm, Handle<Map> map, Register receiver, Register holder, |
21 Register holder, int accessor_index, int expected_arguments, | 21 int accessor_index, int expected_arguments, Register scratch) { |
22 Register scratch) { | |
23 // ----------- S t a t e ------------- | 22 // ----------- S t a t e ------------- |
24 // -- a0 : receiver | 23 // -- a0 : receiver |
25 // -- a2 : name | 24 // -- a2 : name |
26 // -- ra : return address | 25 // -- ra : return address |
27 // ----------------------------------- | 26 // ----------------------------------- |
28 { | 27 { |
29 FrameScope scope(masm, StackFrame::INTERNAL); | 28 FrameScope scope(masm, StackFrame::INTERNAL); |
30 | 29 |
31 if (accessor_index >= 0) { | 30 if (accessor_index >= 0) { |
32 DCHECK(!holder.is(scratch)); | 31 DCHECK(!holder.is(scratch)); |
33 DCHECK(!receiver.is(scratch)); | 32 DCHECK(!receiver.is(scratch)); |
34 // Call the JavaScript getter with the receiver on the stack. | 33 // Call the JavaScript getter with the receiver on the stack. |
35 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { | 34 if (map->IsJSGlobalObjectMap()) { |
36 // Swap in the global receiver. | 35 // Swap in the global receiver. |
37 __ lw(scratch, | 36 __ lw(scratch, |
38 FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); | 37 FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); |
39 receiver = scratch; | 38 receiver = scratch; |
40 } | 39 } |
41 __ push(receiver); | 40 __ push(receiver); |
42 ParameterCount actual(0); | 41 ParameterCount actual(0); |
43 ParameterCount expected(expected_arguments); | 42 ParameterCount expected(expected_arguments); |
44 __ LoadAccessor(a1, holder, accessor_index, ACCESSOR_GETTER); | 43 __ LoadAccessor(a1, holder, accessor_index, ACCESSOR_GETTER); |
45 __ InvokeFunction(a1, expected, actual, CALL_FUNCTION, NullCallWrapper()); | 44 __ InvokeFunction(a1, expected, actual, CALL_FUNCTION, NullCallWrapper()); |
46 } else { | 45 } else { |
47 // If we generate a global code snippet for deoptimization only, remember | 46 // If we generate a global code snippet for deoptimization only, remember |
48 // the place to continue after deoptimization. | 47 // the place to continue after deoptimization. |
49 masm->isolate()->heap()->SetGetterStubDeoptPCOffset(masm->pc_offset()); | 48 masm->isolate()->heap()->SetGetterStubDeoptPCOffset(masm->pc_offset()); |
50 } | 49 } |
51 | 50 |
52 // Restore context register. | 51 // Restore context register. |
53 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 52 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
54 } | 53 } |
55 __ Ret(); | 54 __ Ret(); |
56 } | 55 } |
57 | 56 |
58 | 57 |
59 void NamedStoreHandlerCompiler::GenerateStoreViaSetter( | 58 void NamedStoreHandlerCompiler::GenerateStoreViaSetter( |
60 MacroAssembler* masm, Handle<HeapType> type, Register receiver, | 59 MacroAssembler* masm, Handle<Map> map, Register receiver, Register holder, |
61 Register holder, int accessor_index, int expected_arguments, | 60 int accessor_index, int expected_arguments, Register scratch) { |
62 Register scratch) { | |
63 // ----------- S t a t e ------------- | 61 // ----------- S t a t e ------------- |
64 // -- ra : return address | 62 // -- ra : return address |
65 // ----------------------------------- | 63 // ----------------------------------- |
66 { | 64 { |
67 FrameScope scope(masm, StackFrame::INTERNAL); | 65 FrameScope scope(masm, StackFrame::INTERNAL); |
68 | 66 |
69 // Save value register, so we can restore it later. | 67 // Save value register, so we can restore it later. |
70 __ push(value()); | 68 __ push(value()); |
71 | 69 |
72 if (accessor_index >= 0) { | 70 if (accessor_index >= 0) { |
73 DCHECK(!holder.is(scratch)); | 71 DCHECK(!holder.is(scratch)); |
74 DCHECK(!receiver.is(scratch)); | 72 DCHECK(!receiver.is(scratch)); |
75 DCHECK(!value().is(scratch)); | 73 DCHECK(!value().is(scratch)); |
76 // Call the JavaScript setter with receiver and value on the stack. | 74 // Call the JavaScript setter with receiver and value on the stack. |
77 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { | 75 if (map->IsJSGlobalObjectMap()) { |
78 // Swap in the global receiver. | 76 // Swap in the global receiver. |
79 __ lw(scratch, | 77 __ lw(scratch, |
80 FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); | 78 FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); |
81 receiver = scratch; | 79 receiver = scratch; |
82 } | 80 } |
83 __ Push(receiver, value()); | 81 __ Push(receiver, value()); |
84 ParameterCount actual(1); | 82 ParameterCount actual(1); |
85 ParameterCount expected(expected_arguments); | 83 ParameterCount expected(expected_arguments); |
86 __ LoadAccessor(a1, holder, accessor_index, ACCESSOR_SETTER); | 84 __ LoadAccessor(a1, holder, accessor_index, ACCESSOR_SETTER); |
87 __ InvokeFunction(a1, expected, actual, CALL_FUNCTION, NullCallWrapper()); | 85 __ InvokeFunction(a1, expected, actual, CALL_FUNCTION, NullCallWrapper()); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 } | 396 } |
399 __ bind(&do_store); | 397 __ bind(&do_store); |
400 } | 398 } |
401 } | 399 } |
402 | 400 |
403 | 401 |
404 Register PropertyHandlerCompiler::CheckPrototypes( | 402 Register PropertyHandlerCompiler::CheckPrototypes( |
405 Register object_reg, Register holder_reg, Register scratch1, | 403 Register object_reg, Register holder_reg, Register scratch1, |
406 Register scratch2, Handle<Name> name, Label* miss, | 404 Register scratch2, Handle<Name> name, Label* miss, |
407 PrototypeCheckType check) { | 405 PrototypeCheckType check) { |
408 Handle<Map> receiver_map(IC::TypeToMap(*type(), isolate())); | 406 Handle<Map> receiver_map = map(); |
409 | 407 |
410 // Make sure there's no overlap between holder and object registers. | 408 // Make sure there's no overlap between holder and object registers. |
411 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); | 409 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); |
412 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) && | 410 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) && |
413 !scratch2.is(scratch1)); | 411 !scratch2.is(scratch1)); |
414 | 412 |
415 // Keep track of the current object in register reg. | 413 // Keep track of the current object in register reg. |
416 Register reg = object_reg; | 414 Register reg = object_reg; |
417 int depth = 0; | 415 int depth = 0; |
418 | 416 |
419 Handle<JSObject> current = Handle<JSObject>::null(); | 417 Handle<JSObject> current = Handle<JSObject>::null(); |
420 if (type()->IsConstant()) { | 418 if (receiver_map->IsJSGlobalObjectMap()) { |
421 current = Handle<JSObject>::cast(type()->AsConstant()->Value()); | 419 current = isolate()->global_object(); |
422 } | 420 } |
423 Handle<JSObject> prototype = Handle<JSObject>::null(); | 421 Handle<JSObject> prototype = Handle<JSObject>::null(); |
424 Handle<Map> current_map = receiver_map; | 422 Handle<Map> current_map = receiver_map; |
425 Handle<Map> holder_map(holder()->map()); | 423 Handle<Map> holder_map(holder()->map()); |
426 // Traverse the prototype chain and check the maps in the prototype chain for | 424 // Traverse the prototype chain and check the maps in the prototype chain for |
427 // fast and global objects or do negative lookup for normal objects. | 425 // fast and global objects or do negative lookup for normal objects. |
428 while (!current_map.is_identical_to(holder_map)) { | 426 while (!current_map.is_identical_to(holder_map)) { |
429 ++depth; | 427 ++depth; |
430 | 428 |
431 // Only global objects and objects that do not require access | 429 // Only global objects and objects that do not require access |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 // Return the generated code. | 734 // Return the generated code. |
737 return GetCode(kind(), Code::NORMAL, name); | 735 return GetCode(kind(), Code::NORMAL, name); |
738 } | 736 } |
739 | 737 |
740 | 738 |
741 #undef __ | 739 #undef __ |
742 } | 740 } |
743 } // namespace v8::internal | 741 } // namespace v8::internal |
744 | 742 |
745 #endif // V8_TARGET_ARCH_MIPS | 743 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |