| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 #endif | 114 #endif |
| 115 | 115 |
| 116 // Jump to the first instruction in the code stub. | 116 // Jump to the first instruction in the code stub. |
| 117 __ add(pc, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 117 __ add(pc, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 118 | 118 |
| 119 // Miss: fall through. | 119 // Miss: fall through. |
| 120 __ bind(&miss); | 120 __ bind(&miss); |
| 121 } | 121 } |
| 122 | 122 |
| 123 | 123 |
| 124 // Helper function used to check that the dictionary doesn't contain | 124 void StubCompiler::GenerateDictionaryNegativeLookup(MacroAssembler* masm, |
| 125 // the property. This function may return false negatives, so miss_label | 125 Label* miss_label, |
| 126 // must always call a backup property check that is complete. | 126 Register receiver, |
| 127 // This function is safe to call if the receiver has fast properties. | 127 Handle<Name> name, |
| 128 // Name must be unique and receiver must be a heap object. | 128 Register scratch0, |
| 129 static void GenerateDictionaryNegativeLookup(MacroAssembler* masm, | 129 Register scratch1) { |
| 130 Label* miss_label, | |
| 131 Register receiver, | |
| 132 Handle<Name> name, | |
| 133 Register scratch0, | |
| 134 Register scratch1) { | |
| 135 ASSERT(name->IsUniqueName()); | 130 ASSERT(name->IsUniqueName()); |
| 131 ASSERT(!receiver.is(scratch0)); |
| 136 Counters* counters = masm->isolate()->counters(); | 132 Counters* counters = masm->isolate()->counters(); |
| 137 __ IncrementCounter(counters->negative_lookups(), 1, scratch0, scratch1); | 133 __ IncrementCounter(counters->negative_lookups(), 1, scratch0, scratch1); |
| 138 __ IncrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1); | 134 __ IncrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1); |
| 139 | 135 |
| 140 Label done; | 136 Label done; |
| 141 | 137 |
| 142 const int kInterceptorOrAccessCheckNeededMask = | 138 const int kInterceptorOrAccessCheckNeededMask = |
| 143 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); | 139 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); |
| 144 | 140 |
| 145 // Bail out if the receiver has a named interceptor or requires access checks. | 141 // Bail out if the receiver has a named interceptor or requires access checks. |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 Label* miss_label) { | 411 Label* miss_label) { |
| 416 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); | 412 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); |
| 417 __ mov(r0, scratch1); | 413 __ mov(r0, scratch1); |
| 418 __ Ret(); | 414 __ Ret(); |
| 419 } | 415 } |
| 420 | 416 |
| 421 | 417 |
| 422 // Generate code to check that a global property cell is empty. Create | 418 // Generate code to check that a global property cell is empty. Create |
| 423 // the property cell at compilation time if no cell exists for the | 419 // the property cell at compilation time if no cell exists for the |
| 424 // property. | 420 // property. |
| 425 static void GenerateCheckPropertyCell(MacroAssembler* masm, | 421 void StubCompiler::GenerateCheckPropertyCell(MacroAssembler* masm, |
| 426 Handle<GlobalObject> global, | 422 Handle<JSGlobalObject> global, |
| 427 Handle<Name> name, | 423 Handle<Name> name, |
| 428 Register scratch, | 424 Register scratch, |
| 429 Label* miss) { | 425 Label* miss) { |
| 430 Handle<Cell> cell = GlobalObject::EnsurePropertyCell(global, name); | 426 Handle<Cell> cell = JSGlobalObject::EnsurePropertyCell(global, name); |
| 431 ASSERT(cell->value()->IsTheHole()); | 427 ASSERT(cell->value()->IsTheHole()); |
| 432 __ mov(scratch, Operand(cell)); | 428 __ mov(scratch, Operand(cell)); |
| 433 __ ldr(scratch, FieldMemOperand(scratch, Cell::kValueOffset)); | 429 __ ldr(scratch, FieldMemOperand(scratch, Cell::kValueOffset)); |
| 434 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 430 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
| 435 __ cmp(scratch, ip); | 431 __ cmp(scratch, ip); |
| 436 __ b(ne, miss); | 432 __ b(ne, miss); |
| 437 } | 433 } |
| 438 | 434 |
| 439 | 435 |
| 440 void BaseStoreStubCompiler::GenerateNegativeHolderLookup( | 436 void BaseStoreStubCompiler::GenerateNegativeHolderLookup( |
| 441 MacroAssembler* masm, | 437 MacroAssembler* masm, |
| 442 Handle<JSObject> holder, | 438 Handle<JSObject> holder, |
| 443 Register holder_reg, | 439 Register holder_reg, |
| 444 Handle<Name> name, | 440 Handle<Name> name, |
| 445 Label* miss) { | 441 Label* miss) { |
| 446 if (holder->IsJSGlobalObject()) { | 442 if (holder->IsJSGlobalObject()) { |
| 447 GenerateCheckPropertyCell( | 443 GenerateCheckPropertyCell( |
| 448 masm, Handle<GlobalObject>::cast(holder), name, scratch1(), miss); | 444 masm, Handle<JSGlobalObject>::cast(holder), name, scratch1(), miss); |
| 449 } else if (!holder->HasFastProperties() && !holder->IsJSGlobalProxy()) { | 445 } else if (!holder->HasFastProperties() && !holder->IsJSGlobalProxy()) { |
| 450 GenerateDictionaryNegativeLookup( | 446 GenerateDictionaryNegativeLookup( |
| 451 masm, miss, holder_reg, name, scratch1(), scratch2()); | 447 masm, miss, holder_reg, name, scratch1(), scratch2()); |
| 452 } | 448 } |
| 453 } | 449 } |
| 454 | 450 |
| 455 | 451 |
| 456 // Generate StoreTransition code, value is passed in r0 register. | 452 // Generate StoreTransition code, value is passed in r0 register. |
| 457 // When leaving generated code after success, the receiver_reg and name_reg | 453 // When leaving generated code after success, the receiver_reg and name_reg |
| 458 // may be clobbered. Upon branch to miss_label, the receiver and name | 454 // may be clobbered. Upon branch to miss_label, the receiver and name |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 __ b(ne, interceptor_succeeded); | 1136 __ b(ne, interceptor_succeeded); |
| 1141 } | 1137 } |
| 1142 | 1138 |
| 1143 StubCompiler* stub_compiler_; | 1139 StubCompiler* stub_compiler_; |
| 1144 const ParameterCount& arguments_; | 1140 const ParameterCount& arguments_; |
| 1145 Register name_; | 1141 Register name_; |
| 1146 Code::ExtraICState extra_ic_state_; | 1142 Code::ExtraICState extra_ic_state_; |
| 1147 }; | 1143 }; |
| 1148 | 1144 |
| 1149 | 1145 |
| 1150 // Calls GenerateCheckPropertyCell for each global object in the prototype chain | 1146 void StubCompiler::GenerateCheckPropertyCells(MacroAssembler* masm, |
| 1151 // from object to (but not including) holder. | 1147 Handle<JSObject> object, |
| 1152 static void GenerateCheckPropertyCells(MacroAssembler* masm, | 1148 Handle<JSObject> holder, |
| 1153 Handle<JSObject> object, | 1149 Handle<Name> name, |
| 1154 Handle<JSObject> holder, | 1150 Register scratch, |
| 1155 Handle<Name> name, | 1151 Label* miss) { |
| 1156 Register scratch, | |
| 1157 Label* miss) { | |
| 1158 Handle<JSObject> current = object; | 1152 Handle<JSObject> current = object; |
| 1159 while (!current.is_identical_to(holder)) { | 1153 while (!current.is_identical_to(holder)) { |
| 1160 if (current->IsGlobalObject()) { | 1154 if (current->IsJSGlobalObject()) { |
| 1161 GenerateCheckPropertyCell(masm, | 1155 GenerateCheckPropertyCell(masm, |
| 1162 Handle<GlobalObject>::cast(current), | 1156 Handle<JSGlobalObject>::cast(current), |
| 1163 name, | 1157 name, |
| 1164 scratch, | 1158 scratch, |
| 1165 miss); | 1159 miss); |
| 1166 } | 1160 } |
| 1167 current = Handle<JSObject>(JSObject::cast(current->GetPrototype())); | 1161 current = Handle<JSObject>(JSObject::cast(current->GetPrototype())); |
| 1168 } | 1162 } |
| 1169 } | 1163 } |
| 1170 | 1164 |
| 1171 | 1165 |
| 1172 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { | 1166 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 __ ldr(scratch2(), FieldMemOperand(pointer, kValueOffset)); | 1350 __ ldr(scratch2(), FieldMemOperand(pointer, kValueOffset)); |
| 1357 __ cmp(scratch2(), Operand(callback)); | 1351 __ cmp(scratch2(), Operand(callback)); |
| 1358 __ b(ne, &miss); | 1352 __ b(ne, &miss); |
| 1359 } | 1353 } |
| 1360 | 1354 |
| 1361 HandlerFrontendFooter(name, success, &miss); | 1355 HandlerFrontendFooter(name, success, &miss); |
| 1362 return reg; | 1356 return reg; |
| 1363 } | 1357 } |
| 1364 | 1358 |
| 1365 | 1359 |
| 1366 void BaseLoadStubCompiler::NonexistentHandlerFrontend( | |
| 1367 Handle<JSObject> object, | |
| 1368 Handle<JSObject> last, | |
| 1369 Handle<Name> name, | |
| 1370 Label* success, | |
| 1371 Handle<GlobalObject> global) { | |
| 1372 Label miss; | |
| 1373 | |
| 1374 HandlerFrontendHeader(object, receiver(), last, name, &miss); | |
| 1375 | |
| 1376 // If the last object in the prototype chain is a global object, | |
| 1377 // check that the global property cell is empty. | |
| 1378 if (!global.is_null()) { | |
| 1379 GenerateCheckPropertyCell(masm(), global, name, scratch2(), &miss); | |
| 1380 } | |
| 1381 | |
| 1382 HandlerFrontendFooter(name, success, &miss); | |
| 1383 } | |
| 1384 | |
| 1385 | |
| 1386 void BaseLoadStubCompiler::GenerateLoadField(Register reg, | 1360 void BaseLoadStubCompiler::GenerateLoadField(Register reg, |
| 1387 Handle<JSObject> holder, | 1361 Handle<JSObject> holder, |
| 1388 PropertyIndex field, | 1362 PropertyIndex field, |
| 1389 Representation representation) { | 1363 Representation representation) { |
| 1390 if (!reg.is(receiver())) __ mov(receiver(), reg); | 1364 if (!reg.is(receiver())) __ mov(receiver(), reg); |
| 1391 if (kind() == Code::LOAD_IC) { | 1365 if (kind() == Code::LOAD_IC) { |
| 1392 LoadFieldStub stub(field.is_inobject(holder), | 1366 LoadFieldStub stub(field.is_inobject(holder), |
| 1393 field.translate(holder), | 1367 field.translate(holder), |
| 1394 representation); | 1368 representation); |
| 1395 GenerateTailCall(masm(), stub.GetCode(isolate())); | 1369 GenerateTailCall(masm(), stub.GetCode(isolate())); |
| (...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2919 | 2893 |
| 2920 // Return the generated code. | 2894 // Return the generated code. |
| 2921 return GetCode(kind(), Code::INTERCEPTOR, name); | 2895 return GetCode(kind(), Code::INTERCEPTOR, name); |
| 2922 } | 2896 } |
| 2923 | 2897 |
| 2924 | 2898 |
| 2925 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( | 2899 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( |
| 2926 Handle<JSObject> object, | 2900 Handle<JSObject> object, |
| 2927 Handle<JSObject> last, | 2901 Handle<JSObject> last, |
| 2928 Handle<Name> name, | 2902 Handle<Name> name, |
| 2929 Handle<GlobalObject> global) { | 2903 Handle<JSGlobalObject> global) { |
| 2930 Label success; | 2904 Label success; |
| 2931 | 2905 |
| 2932 NonexistentHandlerFrontend(object, last, name, &success, global); | 2906 NonexistentHandlerFrontend(object, last, name, &success, global); |
| 2933 | 2907 |
| 2934 __ bind(&success); | 2908 __ bind(&success); |
| 2935 // Return undefined if maps of the full prototype chain are still the | 2909 // Return undefined if maps of the full prototype chain are still the |
| 2936 // same and no global property with this name contains a value. | 2910 // same and no global property with this name contains a value. |
| 2937 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 2911 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 2938 __ Ret(); | 2912 __ Ret(); |
| 2939 | 2913 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3175 // ----------------------------------- | 3149 // ----------------------------------- |
| 3176 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); | 3150 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); |
| 3177 } | 3151 } |
| 3178 | 3152 |
| 3179 | 3153 |
| 3180 #undef __ | 3154 #undef __ |
| 3181 | 3155 |
| 3182 } } // namespace v8::internal | 3156 } } // namespace v8::internal |
| 3183 | 3157 |
| 3184 #endif // V8_TARGET_ARCH_ARM | 3158 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |