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 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 return js_function; | 1323 return js_function; |
1324 } | 1324 } |
1325 | 1325 |
1326 | 1326 |
1327 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { | 1327 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { |
1328 return DoGenerateCode(isolate, this); | 1328 return DoGenerateCode(isolate, this); |
1329 } | 1329 } |
1330 | 1330 |
1331 | 1331 |
1332 template<> | 1332 template<> |
| 1333 HValue* CodeStubGraphBuilder<FastNewContextStub>::BuildCodeStub() { |
| 1334 int length = casted_stub()->slots() + Context::MIN_CONTEXT_SLOTS; |
| 1335 |
| 1336 // Get the function. |
| 1337 HParameter* function = GetParameter(FastNewContextStub::kFunction); |
| 1338 |
| 1339 // Allocate the context in new space. |
| 1340 HAllocate* function_context = Add<HAllocate>( |
| 1341 Add<HConstant>(length * kPointerSize + FixedArray::kHeaderSize), |
| 1342 HType::Tagged(), NOT_TENURED, FIXED_ARRAY_TYPE); |
| 1343 |
| 1344 // Set up the object header. |
| 1345 AddStoreMapConstant(function_context, |
| 1346 isolate()->factory()->function_context_map()); |
| 1347 Add<HStoreNamedField>(function_context, |
| 1348 HObjectAccess::ForFixedArrayLength(), |
| 1349 Add<HConstant>(length)); |
| 1350 |
| 1351 // Set up the fixed slots. |
| 1352 Add<HStoreNamedField>(function_context, |
| 1353 HObjectAccess::ForContextSlot(Context::CLOSURE_INDEX), |
| 1354 function); |
| 1355 Add<HStoreNamedField>(function_context, |
| 1356 HObjectAccess::ForContextSlot(Context::PREVIOUS_INDEX), |
| 1357 context()); |
| 1358 Add<HStoreNamedField>(function_context, |
| 1359 HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX), |
| 1360 graph()->GetConstant0()); |
| 1361 |
| 1362 // Copy the global object from the previous context. |
| 1363 HValue* global_object = Add<HLoadNamedField>( |
| 1364 context(), HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); |
| 1365 Add<HStoreNamedField>(function_context, |
| 1366 HObjectAccess::ForContextSlot( |
| 1367 Context::GLOBAL_OBJECT_INDEX), |
| 1368 global_object); |
| 1369 |
| 1370 // Initialize the rest of the slots to undefined. |
| 1371 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; ++i) { |
| 1372 Add<HStoreNamedField>(function_context, |
| 1373 HObjectAccess::ForContextSlot(i), |
| 1374 graph()->GetConstantUndefined()); |
| 1375 } |
| 1376 |
| 1377 return function_context; |
| 1378 } |
| 1379 |
| 1380 |
| 1381 Handle<Code> FastNewContextStub::GenerateCode(Isolate* isolate) { |
| 1382 return DoGenerateCode(isolate, this); |
| 1383 } |
| 1384 |
| 1385 |
| 1386 template<> |
1333 HValue* CodeStubGraphBuilder<KeyedLoadDictionaryElementStub>::BuildCodeStub() { | 1387 HValue* CodeStubGraphBuilder<KeyedLoadDictionaryElementStub>::BuildCodeStub() { |
1334 HValue* receiver = GetParameter(0); | 1388 HValue* receiver = GetParameter(0); |
1335 HValue* key = GetParameter(1); | 1389 HValue* key = GetParameter(1); |
1336 | 1390 |
1337 Add<HCheckSmi>(key); | 1391 Add<HCheckSmi>(key); |
1338 | 1392 |
1339 return BuildUncheckedDictionaryElementLoad(receiver, key); | 1393 return BuildUncheckedDictionaryElementLoad(receiver, key); |
1340 } | 1394 } |
1341 | 1395 |
1342 | 1396 |
1343 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) { | 1397 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) { |
1344 return DoGenerateCode(isolate, this); | 1398 return DoGenerateCode(isolate, this); |
1345 } | 1399 } |
1346 | 1400 |
1347 | 1401 |
1348 } } // namespace v8::internal | 1402 } } // namespace v8::internal |
OLD | NEW |