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 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 ASSERT(!holder_reg.is(scratch)); | 975 ASSERT(!holder_reg.is(scratch)); |
976 | 976 |
977 // Load current lexical context from the stack frame. | 977 // Load current lexical context from the stack frame. |
978 mov(scratch, Operand(ebp, StandardFrameConstants::kContextOffset)); | 978 mov(scratch, Operand(ebp, StandardFrameConstants::kContextOffset)); |
979 | 979 |
980 // When generating debug code, make sure the lexical context is set. | 980 // When generating debug code, make sure the lexical context is set. |
981 if (emit_debug_code()) { | 981 if (emit_debug_code()) { |
982 cmp(scratch, Immediate(0)); | 982 cmp(scratch, Immediate(0)); |
983 Check(not_equal, "we should not have an empty lexical context"); | 983 Check(not_equal, "we should not have an empty lexical context"); |
984 } | 984 } |
985 // Load the native context of the current context. | 985 // Load the global context of the current context. |
986 int offset = | 986 int offset = Context::kHeaderSize + Context::GLOBAL_INDEX * kPointerSize; |
987 Context::kHeaderSize + Context::GLOBAL_OBJECT_INDEX * kPointerSize; | |
988 mov(scratch, FieldOperand(scratch, offset)); | 987 mov(scratch, FieldOperand(scratch, offset)); |
989 mov(scratch, FieldOperand(scratch, GlobalObject::kNativeContextOffset)); | 988 mov(scratch, FieldOperand(scratch, GlobalObject::kGlobalContextOffset)); |
990 | 989 |
991 // Check the context is a native context. | 990 // Check the context is a global context. |
992 if (emit_debug_code()) { | 991 if (emit_debug_code()) { |
993 push(scratch); | 992 push(scratch); |
994 // Read the first word and compare to native_context_map. | 993 // Read the first word and compare to global_context_map. |
995 mov(scratch, FieldOperand(scratch, HeapObject::kMapOffset)); | 994 mov(scratch, FieldOperand(scratch, HeapObject::kMapOffset)); |
996 cmp(scratch, isolate()->factory()->native_context_map()); | 995 cmp(scratch, isolate()->factory()->global_context_map()); |
997 Check(equal, "JSGlobalObject::native_context should be a native context."); | 996 Check(equal, "JSGlobalObject::global_context should be a global context."); |
998 pop(scratch); | 997 pop(scratch); |
999 } | 998 } |
1000 | 999 |
1001 // Check if both contexts are the same. | 1000 // Check if both contexts are the same. |
1002 cmp(scratch, FieldOperand(holder_reg, JSGlobalProxy::kNativeContextOffset)); | 1001 cmp(scratch, FieldOperand(holder_reg, JSGlobalProxy::kContextOffset)); |
1003 j(equal, &same_contexts); | 1002 j(equal, &same_contexts); |
1004 | 1003 |
1005 // Compare security tokens, save holder_reg on the stack so we can use it | 1004 // Compare security tokens, save holder_reg on the stack so we can use it |
1006 // as a temporary register. | 1005 // as a temporary register. |
1007 // | 1006 // |
1008 // TODO(119): avoid push(holder_reg)/pop(holder_reg) | 1007 // TODO(119): avoid push(holder_reg)/pop(holder_reg) |
1009 push(holder_reg); | 1008 push(holder_reg); |
1010 // Check that the security token in the calling global object is | 1009 // Check that the security token in the calling global object is |
1011 // compatible with the security token in the receiving global | 1010 // compatible with the security token in the receiving global |
1012 // object. | 1011 // object. |
1013 mov(holder_reg, | 1012 mov(holder_reg, FieldOperand(holder_reg, JSGlobalProxy::kContextOffset)); |
1014 FieldOperand(holder_reg, JSGlobalProxy::kNativeContextOffset)); | |
1015 | 1013 |
1016 // Check the context is a native context. | 1014 // Check the context is a global context. |
1017 if (emit_debug_code()) { | 1015 if (emit_debug_code()) { |
1018 cmp(holder_reg, isolate()->factory()->null_value()); | 1016 cmp(holder_reg, isolate()->factory()->null_value()); |
1019 Check(not_equal, "JSGlobalProxy::context() should not be null."); | 1017 Check(not_equal, "JSGlobalProxy::context() should not be null."); |
1020 | 1018 |
1021 push(holder_reg); | 1019 push(holder_reg); |
1022 // Read the first word and compare to native_context_map(), | 1020 // Read the first word and compare to global_context_map(), |
1023 mov(holder_reg, FieldOperand(holder_reg, HeapObject::kMapOffset)); | 1021 mov(holder_reg, FieldOperand(holder_reg, HeapObject::kMapOffset)); |
1024 cmp(holder_reg, isolate()->factory()->native_context_map()); | 1022 cmp(holder_reg, isolate()->factory()->global_context_map()); |
1025 Check(equal, "JSGlobalObject::native_context should be a native context."); | 1023 Check(equal, "JSGlobalObject::global_context should be a global context."); |
1026 pop(holder_reg); | 1024 pop(holder_reg); |
1027 } | 1025 } |
1028 | 1026 |
1029 int token_offset = Context::kHeaderSize + | 1027 int token_offset = Context::kHeaderSize + |
1030 Context::SECURITY_TOKEN_INDEX * kPointerSize; | 1028 Context::SECURITY_TOKEN_INDEX * kPointerSize; |
1031 mov(scratch, FieldOperand(scratch, token_offset)); | 1029 mov(scratch, FieldOperand(scratch, token_offset)); |
1032 cmp(scratch, FieldOperand(holder_reg, token_offset)); | 1030 cmp(scratch, FieldOperand(holder_reg, token_offset)); |
1033 pop(holder_reg); | 1031 pop(holder_reg); |
1034 j(not_equal, miss); | 1032 j(not_equal, miss); |
1035 | 1033 |
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2165 ParameterCount expected(0); | 2163 ParameterCount expected(0); |
2166 GetBuiltinFunction(edi, id); | 2164 GetBuiltinFunction(edi, id); |
2167 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 2165 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), |
2168 expected, expected, flag, call_wrapper, CALL_AS_METHOD); | 2166 expected, expected, flag, call_wrapper, CALL_AS_METHOD); |
2169 } | 2167 } |
2170 | 2168 |
2171 | 2169 |
2172 void MacroAssembler::GetBuiltinFunction(Register target, | 2170 void MacroAssembler::GetBuiltinFunction(Register target, |
2173 Builtins::JavaScript id) { | 2171 Builtins::JavaScript id) { |
2174 // Load the JavaScript builtin function from the builtins object. | 2172 // Load the JavaScript builtin function from the builtins object. |
2175 mov(target, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 2173 mov(target, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
2176 mov(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); | 2174 mov(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); |
2177 mov(target, FieldOperand(target, | 2175 mov(target, FieldOperand(target, |
2178 JSBuiltinsObject::OffsetOfFunctionWithId(id))); | 2176 JSBuiltinsObject::OffsetOfFunctionWithId(id))); |
2179 } | 2177 } |
2180 | 2178 |
2181 | 2179 |
2182 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { | 2180 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { |
2183 ASSERT(!target.is(edi)); | 2181 ASSERT(!target.is(edi)); |
2184 // Load the JavaScript builtin function from the builtins object. | 2182 // Load the JavaScript builtin function from the builtins object. |
2185 GetBuiltinFunction(edi, id); | 2183 GetBuiltinFunction(edi, id); |
(...skipping 28 matching lines...) Expand all Loading... |
2214 } | 2212 } |
2215 | 2213 |
2216 | 2214 |
2217 void MacroAssembler::LoadTransitionedArrayMapConditional( | 2215 void MacroAssembler::LoadTransitionedArrayMapConditional( |
2218 ElementsKind expected_kind, | 2216 ElementsKind expected_kind, |
2219 ElementsKind transitioned_kind, | 2217 ElementsKind transitioned_kind, |
2220 Register map_in_out, | 2218 Register map_in_out, |
2221 Register scratch, | 2219 Register scratch, |
2222 Label* no_map_match) { | 2220 Label* no_map_match) { |
2223 // Load the global or builtins object from the current context. | 2221 // Load the global or builtins object from the current context. |
2224 mov(scratch, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 2222 mov(scratch, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
2225 mov(scratch, FieldOperand(scratch, GlobalObject::kNativeContextOffset)); | 2223 mov(scratch, FieldOperand(scratch, GlobalObject::kGlobalContextOffset)); |
2226 | 2224 |
2227 // Check that the function's map is the same as the expected cached map. | 2225 // Check that the function's map is the same as the expected cached map. |
2228 mov(scratch, Operand(scratch, | 2226 mov(scratch, Operand(scratch, |
2229 Context::SlotOffset(Context::JS_ARRAY_MAPS_INDEX))); | 2227 Context::SlotOffset(Context::JS_ARRAY_MAPS_INDEX))); |
2230 | 2228 |
2231 size_t offset = expected_kind * kPointerSize + | 2229 size_t offset = expected_kind * kPointerSize + |
2232 FixedArrayBase::kHeaderSize; | 2230 FixedArrayBase::kHeaderSize; |
2233 cmp(map_in_out, FieldOperand(scratch, offset)); | 2231 cmp(map_in_out, FieldOperand(scratch, offset)); |
2234 j(not_equal, no_map_match); | 2232 j(not_equal, no_map_match); |
2235 | 2233 |
(...skipping 24 matching lines...) Expand all Loading... |
2260 map_out, | 2258 map_out, |
2261 scratch, | 2259 scratch, |
2262 &done); | 2260 &done); |
2263 } | 2261 } |
2264 bind(&done); | 2262 bind(&done); |
2265 } | 2263 } |
2266 | 2264 |
2267 | 2265 |
2268 void MacroAssembler::LoadGlobalFunction(int index, Register function) { | 2266 void MacroAssembler::LoadGlobalFunction(int index, Register function) { |
2269 // Load the global or builtins object from the current context. | 2267 // Load the global or builtins object from the current context. |
2270 mov(function, | 2268 mov(function, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
2271 Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 2269 // Load the global context from the global or builtins object. |
2272 // Load the native context from the global or builtins object. | 2270 mov(function, FieldOperand(function, GlobalObject::kGlobalContextOffset)); |
2273 mov(function, FieldOperand(function, GlobalObject::kNativeContextOffset)); | 2271 // Load the function from the global context. |
2274 // Load the function from the native context. | |
2275 mov(function, Operand(function, Context::SlotOffset(index))); | 2272 mov(function, Operand(function, Context::SlotOffset(index))); |
2276 } | 2273 } |
2277 | 2274 |
2278 | 2275 |
2279 void MacroAssembler::LoadGlobalFunctionInitialMap(Register function, | 2276 void MacroAssembler::LoadGlobalFunctionInitialMap(Register function, |
2280 Register map) { | 2277 Register map) { |
2281 // Load the initial map. The global functions all have initial maps. | 2278 // Load the initial map. The global functions all have initial maps. |
2282 mov(map, FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | 2279 mov(map, FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); |
2283 if (emit_debug_code()) { | 2280 if (emit_debug_code()) { |
2284 Label ok, fail; | 2281 Label ok, fail; |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2924 // Load the prototype from the map and loop if non-null. | 2921 // Load the prototype from the map and loop if non-null. |
2925 bind(&check_prototype); | 2922 bind(&check_prototype); |
2926 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); | 2923 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); |
2927 cmp(ecx, isolate()->factory()->null_value()); | 2924 cmp(ecx, isolate()->factory()->null_value()); |
2928 j(not_equal, &next); | 2925 j(not_equal, &next); |
2929 } | 2926 } |
2930 | 2927 |
2931 } } // namespace v8::internal | 2928 } } // namespace v8::internal |
2932 | 2929 |
2933 #endif // V8_TARGET_ARCH_IA32 | 2930 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |