| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 // Jump to the first instruction in the code stub. | 111 // Jump to the first instruction in the code stub. |
| 112 __ Addu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 112 __ Addu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 113 __ Jump(at); | 113 __ Jump(at); |
| 114 | 114 |
| 115 // Miss: fall through. | 115 // Miss: fall through. |
| 116 __ bind(&miss); | 116 __ bind(&miss); |
| 117 } | 117 } |
| 118 | 118 |
| 119 | 119 |
| 120 // Helper function used to check that the dictionary doesn't contain | 120 void StubCompiler::GenerateDictionaryNegativeLookup(MacroAssembler* masm, |
| 121 // the property. This function may return false negatives, so miss_label | 121 Label* miss_label, |
| 122 // must always call a backup property check that is complete. | 122 Register receiver, |
| 123 // This function is safe to call if the receiver has fast properties. | 123 Handle<Name> name, |
| 124 // Name must be unique and receiver must be a heap object. | 124 Register scratch0, |
| 125 static void GenerateDictionaryNegativeLookup(MacroAssembler* masm, | 125 Register scratch1) { |
| 126 Label* miss_label, | |
| 127 Register receiver, | |
| 128 Handle<Name> name, | |
| 129 Register scratch0, | |
| 130 Register scratch1) { | |
| 131 ASSERT(name->IsUniqueName()); | 126 ASSERT(name->IsUniqueName()); |
| 127 ASSERT(!receiver.is(scratch0)); |
| 132 Counters* counters = masm->isolate()->counters(); | 128 Counters* counters = masm->isolate()->counters(); |
| 133 __ IncrementCounter(counters->negative_lookups(), 1, scratch0, scratch1); | 129 __ IncrementCounter(counters->negative_lookups(), 1, scratch0, scratch1); |
| 134 __ IncrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1); | 130 __ IncrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1); |
| 135 | 131 |
| 136 Label done; | 132 Label done; |
| 137 | 133 |
| 138 const int kInterceptorOrAccessCheckNeededMask = | 134 const int kInterceptorOrAccessCheckNeededMask = |
| 139 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); | 135 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); |
| 140 | 136 |
| 141 // Bail out if the receiver has a named interceptor or requires access checks. | 137 // Bail out if the receiver has a named interceptor or requires access checks. |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 Register receiver, | 401 Register receiver, |
| 406 Register scratch1, | 402 Register scratch1, |
| 407 Register scratch2, | 403 Register scratch2, |
| 408 Label* miss_label) { | 404 Label* miss_label) { |
| 409 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); | 405 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); |
| 410 __ Ret(USE_DELAY_SLOT); | 406 __ Ret(USE_DELAY_SLOT); |
| 411 __ mov(v0, scratch1); | 407 __ mov(v0, scratch1); |
| 412 } | 408 } |
| 413 | 409 |
| 414 | 410 |
| 415 // Generate code to check that a global property cell is empty. Create | 411 void StubCompiler::GenerateCheckPropertyCell(MacroAssembler* masm, |
| 416 // the property cell at compilation time if no cell exists for the | 412 Handle<JSGlobalObject> global, |
| 417 // property. | 413 Handle<Name> name, |
| 418 static void GenerateCheckPropertyCell(MacroAssembler* masm, | 414 Register scratch, |
| 419 Handle<GlobalObject> global, | 415 Label* miss) { |
| 420 Handle<Name> name, | 416 Handle<Cell> cell = JSGlobalObject::EnsurePropertyCell(global, name); |
| 421 Register scratch, | |
| 422 Label* miss) { | |
| 423 Handle<Cell> cell = GlobalObject::EnsurePropertyCell(global, name); | |
| 424 ASSERT(cell->value()->IsTheHole()); | 417 ASSERT(cell->value()->IsTheHole()); |
| 425 __ li(scratch, Operand(cell)); | 418 __ li(scratch, Operand(cell)); |
| 426 __ lw(scratch, FieldMemOperand(scratch, Cell::kValueOffset)); | 419 __ lw(scratch, FieldMemOperand(scratch, Cell::kValueOffset)); |
| 427 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | 420 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
| 428 __ Branch(miss, ne, scratch, Operand(at)); | 421 __ Branch(miss, ne, scratch, Operand(at)); |
| 429 } | 422 } |
| 430 | 423 |
| 431 | 424 |
| 432 void BaseStoreStubCompiler::GenerateNegativeHolderLookup( | 425 void BaseStoreStubCompiler::GenerateNegativeHolderLookup( |
| 433 MacroAssembler* masm, | 426 MacroAssembler* masm, |
| 434 Handle<JSObject> holder, | 427 Handle<JSObject> holder, |
| 435 Register holder_reg, | 428 Register holder_reg, |
| 436 Handle<Name> name, | 429 Handle<Name> name, |
| 437 Label* miss) { | 430 Label* miss) { |
| 438 if (holder->IsJSGlobalObject()) { | 431 if (holder->IsJSGlobalObject()) { |
| 439 GenerateCheckPropertyCell( | 432 GenerateCheckPropertyCell( |
| 440 masm, Handle<GlobalObject>::cast(holder), name, scratch1(), miss); | 433 masm, Handle<JSGlobalObject>::cast(holder), name, scratch1(), miss); |
| 441 } else if (!holder->HasFastProperties() && !holder->IsJSGlobalProxy()) { | 434 } else if (!holder->HasFastProperties() && !holder->IsJSGlobalProxy()) { |
| 442 GenerateDictionaryNegativeLookup( | 435 GenerateDictionaryNegativeLookup( |
| 443 masm, miss, holder_reg, name, scratch1(), scratch2()); | 436 masm, miss, holder_reg, name, scratch1(), scratch2()); |
| 444 } | 437 } |
| 445 } | 438 } |
| 446 | 439 |
| 447 | 440 |
| 448 // Generate StoreTransition code, value is passed in a0 register. | 441 // Generate StoreTransition code, value is passed in a0 register. |
| 449 // After executing generated code, the receiver_reg and name_reg | 442 // After executing generated code, the receiver_reg and name_reg |
| 450 // may be clobbered. | 443 // may be clobbered. |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 __ Branch(interceptor_succeeded, ne, v0, Operand(scratch)); | 1130 __ Branch(interceptor_succeeded, ne, v0, Operand(scratch)); |
| 1138 } | 1131 } |
| 1139 | 1132 |
| 1140 StubCompiler* stub_compiler_; | 1133 StubCompiler* stub_compiler_; |
| 1141 const ParameterCount& arguments_; | 1134 const ParameterCount& arguments_; |
| 1142 Register name_; | 1135 Register name_; |
| 1143 Code::ExtraICState extra_ic_state_; | 1136 Code::ExtraICState extra_ic_state_; |
| 1144 }; | 1137 }; |
| 1145 | 1138 |
| 1146 | 1139 |
| 1147 // Calls GenerateCheckPropertyCell for each global object in the prototype chain | 1140 void StubCompiler::GenerateCheckPropertyCells(MacroAssembler* masm, |
| 1148 // from object to (but not including) holder. | 1141 Handle<JSObject> object, |
| 1149 static void GenerateCheckPropertyCells(MacroAssembler* masm, | 1142 Handle<JSObject> holder, |
| 1150 Handle<JSObject> object, | 1143 Handle<Name> name, |
| 1151 Handle<JSObject> holder, | 1144 Register scratch, |
| 1152 Handle<Name> name, | 1145 Label* miss) { |
| 1153 Register scratch, | |
| 1154 Label* miss) { | |
| 1155 Handle<JSObject> current = object; | 1146 Handle<JSObject> current = object; |
| 1156 while (!current.is_identical_to(holder)) { | 1147 while (!current.is_identical_to(holder)) { |
| 1157 if (current->IsGlobalObject()) { | 1148 if (current->IsJSGlobalObject()) { |
| 1158 GenerateCheckPropertyCell(masm, | 1149 GenerateCheckPropertyCell(masm, |
| 1159 Handle<GlobalObject>::cast(current), | 1150 Handle<JSGlobalObject>::cast(current), |
| 1160 name, | 1151 name, |
| 1161 scratch, | 1152 scratch, |
| 1162 miss); | 1153 miss); |
| 1163 } | 1154 } |
| 1164 current = Handle<JSObject>(JSObject::cast(current->GetPrototype())); | 1155 current = Handle<JSObject>(JSObject::cast(current->GetPrototype())); |
| 1165 } | 1156 } |
| 1166 } | 1157 } |
| 1167 | 1158 |
| 1168 | 1159 |
| 1169 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { | 1160 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 const int kValueOffset = kElementsStartOffset + kPointerSize; | 1342 const int kValueOffset = kElementsStartOffset + kPointerSize; |
| 1352 __ lw(scratch2(), FieldMemOperand(pointer, kValueOffset)); | 1343 __ lw(scratch2(), FieldMemOperand(pointer, kValueOffset)); |
| 1353 __ Branch(&miss, ne, scratch2(), Operand(callback)); | 1344 __ Branch(&miss, ne, scratch2(), Operand(callback)); |
| 1354 } | 1345 } |
| 1355 | 1346 |
| 1356 HandlerFrontendFooter(name, success, &miss); | 1347 HandlerFrontendFooter(name, success, &miss); |
| 1357 return reg; | 1348 return reg; |
| 1358 } | 1349 } |
| 1359 | 1350 |
| 1360 | 1351 |
| 1361 void BaseLoadStubCompiler::NonexistentHandlerFrontend( | |
| 1362 Handle<JSObject> object, | |
| 1363 Handle<JSObject> last, | |
| 1364 Handle<Name> name, | |
| 1365 Label* success, | |
| 1366 Handle<GlobalObject> global) { | |
| 1367 Label miss; | |
| 1368 | |
| 1369 HandlerFrontendHeader(object, receiver(), last, name, &miss); | |
| 1370 | |
| 1371 // If the last object in the prototype chain is a global object, | |
| 1372 // check that the global property cell is empty. | |
| 1373 if (!global.is_null()) { | |
| 1374 GenerateCheckPropertyCell(masm(), global, name, scratch2(), &miss); | |
| 1375 } | |
| 1376 | |
| 1377 HandlerFrontendFooter(name, success, &miss); | |
| 1378 } | |
| 1379 | |
| 1380 | |
| 1381 void BaseLoadStubCompiler::GenerateLoadField(Register reg, | 1352 void BaseLoadStubCompiler::GenerateLoadField(Register reg, |
| 1382 Handle<JSObject> holder, | 1353 Handle<JSObject> holder, |
| 1383 PropertyIndex field, | 1354 PropertyIndex field, |
| 1384 Representation representation) { | 1355 Representation representation) { |
| 1385 if (!reg.is(receiver())) __ mov(receiver(), reg); | 1356 if (!reg.is(receiver())) __ mov(receiver(), reg); |
| 1386 if (kind() == Code::LOAD_IC) { | 1357 if (kind() == Code::LOAD_IC) { |
| 1387 LoadFieldStub stub(field.is_inobject(holder), | 1358 LoadFieldStub stub(field.is_inobject(holder), |
| 1388 field.translate(holder), | 1359 field.translate(holder), |
| 1389 representation); | 1360 representation); |
| 1390 GenerateTailCall(masm(), stub.GetCode(isolate())); | 1361 GenerateTailCall(masm(), stub.GetCode(isolate())); |
| (...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2942 | 2913 |
| 2943 // Return the generated code. | 2914 // Return the generated code. |
| 2944 return GetCode(kind(), Code::INTERCEPTOR, name); | 2915 return GetCode(kind(), Code::INTERCEPTOR, name); |
| 2945 } | 2916 } |
| 2946 | 2917 |
| 2947 | 2918 |
| 2948 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( | 2919 Handle<Code> LoadStubCompiler::CompileLoadNonexistent( |
| 2949 Handle<JSObject> object, | 2920 Handle<JSObject> object, |
| 2950 Handle<JSObject> last, | 2921 Handle<JSObject> last, |
| 2951 Handle<Name> name, | 2922 Handle<Name> name, |
| 2952 Handle<GlobalObject> global) { | 2923 Handle<JSGlobalObject> global) { |
| 2953 Label success; | 2924 Label success; |
| 2954 | 2925 |
| 2955 NonexistentHandlerFrontend(object, last, name, &success, global); | 2926 NonexistentHandlerFrontend(object, last, name, &success, global); |
| 2956 | 2927 |
| 2957 __ bind(&success); | 2928 __ bind(&success); |
| 2958 // Return undefined if maps of the full prototype chain is still the same. | 2929 // Return undefined if maps of the full prototype chain is still the same. |
| 2959 __ LoadRoot(v0, Heap::kUndefinedValueRootIndex); | 2930 __ LoadRoot(v0, Heap::kUndefinedValueRootIndex); |
| 2960 __ Ret(); | 2931 __ Ret(); |
| 2961 | 2932 |
| 2962 // Return the generated code. | 2933 // Return the generated code. |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3194 // ----------------------------------- | 3165 // ----------------------------------- |
| 3195 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); | 3166 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); |
| 3196 } | 3167 } |
| 3197 | 3168 |
| 3198 | 3169 |
| 3199 #undef __ | 3170 #undef __ |
| 3200 | 3171 |
| 3201 } } // namespace v8::internal | 3172 } } // namespace v8::internal |
| 3202 | 3173 |
| 3203 #endif // V8_TARGET_ARCH_MIPS | 3174 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |