| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 GetParameter(1), | 350 GetParameter(1), |
| 351 static_cast<HValue*>(NULL), | 351 static_cast<HValue*>(NULL), |
| 352 FAST_ELEMENTS); | 352 FAST_ELEMENTS); |
| 353 IfBuilder checker(this); | 353 IfBuilder checker(this); |
| 354 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, | 354 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, |
| 355 undefined); | 355 undefined); |
| 356 checker.Then(); | 356 checker.Then(); |
| 357 | 357 |
| 358 HObjectAccess access = HObjectAccess::ForAllocationSiteTransitionInfo(); | 358 HObjectAccess access = HObjectAccess::ForAllocationSiteTransitionInfo(); |
| 359 HInstruction* boilerplate = Add<HLoadNamedField>(allocation_site, access); | 359 HInstruction* boilerplate = Add<HLoadNamedField>(allocation_site, access); |
| 360 HValue* push_value; |
| 360 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { | 361 if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { |
| 361 HValue* elements = AddLoadElements(boilerplate); | 362 HValue* elements = AddLoadElements(boilerplate); |
| 362 | 363 |
| 363 IfBuilder if_fixed_cow(this); | 364 IfBuilder if_fixed_cow(this); |
| 364 if_fixed_cow.If<HCompareMap>(elements, factory->fixed_cow_array_map()); | 365 if_fixed_cow.If<HCompareMap>(elements, factory->fixed_cow_array_map()); |
| 365 if_fixed_cow.Then(); | 366 if_fixed_cow.Then(); |
| 366 environment()->Push(BuildCloneShallowArray(boilerplate, | 367 push_value = BuildCloneShallowArray(boilerplate, |
| 367 allocation_site, | 368 allocation_site, |
| 368 alloc_site_mode, | 369 alloc_site_mode, |
| 369 FAST_ELEMENTS, | 370 FAST_ELEMENTS, |
| 370 0/*copy-on-write*/)); | 371 0/*copy-on-write*/); |
| 372 environment()->Push(push_value); |
| 371 if_fixed_cow.Else(); | 373 if_fixed_cow.Else(); |
| 372 | 374 |
| 373 IfBuilder if_fixed(this); | 375 IfBuilder if_fixed(this); |
| 374 if_fixed.If<HCompareMap>(elements, factory->fixed_array_map()); | 376 if_fixed.If<HCompareMap>(elements, factory->fixed_array_map()); |
| 375 if_fixed.Then(); | 377 if_fixed.Then(); |
| 376 environment()->Push(BuildCloneShallowArray(boilerplate, | 378 push_value = BuildCloneShallowArray(boilerplate, |
| 377 allocation_site, | 379 allocation_site, |
| 378 alloc_site_mode, | 380 alloc_site_mode, |
| 379 FAST_ELEMENTS, | 381 FAST_ELEMENTS, |
| 380 length)); | 382 length); |
| 383 environment()->Push(push_value); |
| 381 if_fixed.Else(); | 384 if_fixed.Else(); |
| 382 environment()->Push(BuildCloneShallowArray(boilerplate, | 385 push_value = BuildCloneShallowArray(boilerplate, |
| 383 allocation_site, | 386 allocation_site, |
| 384 alloc_site_mode, | 387 alloc_site_mode, |
| 385 FAST_DOUBLE_ELEMENTS, | 388 FAST_DOUBLE_ELEMENTS, |
| 386 length)); | 389 length); |
| 390 environment()->Push(push_value); |
| 387 } else { | 391 } else { |
| 388 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); | 392 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); |
| 389 environment()->Push(BuildCloneShallowArray(boilerplate, | 393 push_value = BuildCloneShallowArray(boilerplate, |
| 390 allocation_site, | 394 allocation_site, |
| 391 alloc_site_mode, | 395 alloc_site_mode, |
| 392 elements_kind, | 396 elements_kind, |
| 393 length)); | 397 length); |
| 398 environment()->Push(push_value); |
| 394 } | 399 } |
| 395 | 400 |
| 396 checker.ElseDeopt("Uninitialized boilerplate literals"); | 401 checker.ElseDeopt("Uninitialized boilerplate literals"); |
| 397 checker.End(); | 402 checker.End(); |
| 398 | 403 |
| 399 return environment()->Pop(); | 404 return environment()->Pop(); |
| 400 } | 405 } |
| 401 | 406 |
| 402 | 407 |
| 403 Handle<Code> FastCloneShallowArrayStub::GenerateCode(Isolate* isolate) { | 408 Handle<Code> FastCloneShallowArrayStub::GenerateCode(Isolate* isolate) { |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 Handle<Code> ElementsTransitionAndStoreStub::GenerateCode(Isolate* isolate) { | 916 Handle<Code> ElementsTransitionAndStoreStub::GenerateCode(Isolate* isolate) { |
| 912 return DoGenerateCode(isolate, this); | 917 return DoGenerateCode(isolate, this); |
| 913 } | 918 } |
| 914 | 919 |
| 915 | 920 |
| 916 void CodeStubGraphBuilderBase::BuildInstallOptimizedCode( | 921 void CodeStubGraphBuilderBase::BuildInstallOptimizedCode( |
| 917 HValue* js_function, | 922 HValue* js_function, |
| 918 HValue* native_context, | 923 HValue* native_context, |
| 919 HValue* code_object) { | 924 HValue* code_object) { |
| 920 Counters* counters = isolate()->counters(); | 925 Counters* counters = isolate()->counters(); |
| 921 AddIncrementCounter(counters->fast_new_closure_install_optimized(), | 926 AddIncrementCounter(counters->fast_new_closure_install_optimized()); |
| 922 context()); | |
| 923 | 927 |
| 924 // TODO(fschneider): Idea: store proper code pointers in the optimized code | 928 // TODO(fschneider): Idea: store proper code pointers in the optimized code |
| 925 // map and either unmangle them on marking or do nothing as the whole map is | 929 // map and either unmangle them on marking or do nothing as the whole map is |
| 926 // discarded on major GC anyway. | 930 // discarded on major GC anyway. |
| 927 Add<HStoreCodeEntry>(js_function, code_object); | 931 Add<HStoreCodeEntry>(js_function, code_object); |
| 928 | 932 |
| 929 // Now link a function into a list of optimized functions. | 933 // Now link a function into a list of optimized functions. |
| 930 HValue* optimized_functions_list = Add<HLoadNamedField>(native_context, | 934 HValue* optimized_functions_list = Add<HLoadNamedField>(native_context, |
| 931 HObjectAccess::ForContextSlot(Context::OPTIMIZED_FUNCTIONS_LIST)); | 935 HObjectAccess::ForContextSlot(Context::OPTIMIZED_FUNCTIONS_LIST)); |
| 932 Add<HStoreNamedField>(js_function, | 936 Add<HStoreNamedField>(js_function, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 960 HInstruction* optimized_map = Add<HLoadNamedField>(shared_info, | 964 HInstruction* optimized_map = Add<HLoadNamedField>(shared_info, |
| 961 HObjectAccess::ForOptimizedCodeMap()); | 965 HObjectAccess::ForOptimizedCodeMap()); |
| 962 HValue* null_constant = Add<HConstant>(0); | 966 HValue* null_constant = Add<HConstant>(0); |
| 963 is_optimized.If<HCompareObjectEqAndBranch>(optimized_map, null_constant); | 967 is_optimized.If<HCompareObjectEqAndBranch>(optimized_map, null_constant); |
| 964 is_optimized.Then(); | 968 is_optimized.Then(); |
| 965 { | 969 { |
| 966 BuildInstallCode(js_function, shared_info); | 970 BuildInstallCode(js_function, shared_info); |
| 967 } | 971 } |
| 968 is_optimized.Else(); | 972 is_optimized.Else(); |
| 969 { | 973 { |
| 970 AddIncrementCounter(counters->fast_new_closure_try_optimized(), context()); | 974 AddIncrementCounter(counters->fast_new_closure_try_optimized()); |
| 971 // optimized_map points to fixed array of 3-element entries | 975 // optimized_map points to fixed array of 3-element entries |
| 972 // (native context, optimized code, literals). | 976 // (native context, optimized code, literals). |
| 973 // Map must never be empty, so check the first elements. | 977 // Map must never be empty, so check the first elements. |
| 974 Label install_optimized; | 978 Label install_optimized; |
| 975 HValue* first_context_slot = Add<HLoadNamedField>(optimized_map, | 979 HValue* first_context_slot = Add<HLoadNamedField>(optimized_map, |
| 976 HObjectAccess::ForFirstContextSlot()); | 980 HObjectAccess::ForFirstContextSlot()); |
| 977 IfBuilder already_in(this); | 981 IfBuilder already_in(this); |
| 978 already_in.If<HCompareObjectEqAndBranch>(native_context, | 982 already_in.If<HCompareObjectEqAndBranch>(native_context, |
| 979 first_context_slot); | 983 first_context_slot); |
| 980 already_in.Then(); | 984 already_in.Then(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 Counters* counters = isolate()->counters(); | 1053 Counters* counters = isolate()->counters(); |
| 1050 Factory* factory = isolate()->factory(); | 1054 Factory* factory = isolate()->factory(); |
| 1051 HInstruction* empty_fixed_array = | 1055 HInstruction* empty_fixed_array = |
| 1052 Add<HConstant>(factory->empty_fixed_array()); | 1056 Add<HConstant>(factory->empty_fixed_array()); |
| 1053 HValue* shared_info = GetParameter(0); | 1057 HValue* shared_info = GetParameter(0); |
| 1054 | 1058 |
| 1055 // Create a new closure from the given function info in new space | 1059 // Create a new closure from the given function info in new space |
| 1056 HValue* size = Add<HConstant>(JSFunction::kSize); | 1060 HValue* size = Add<HConstant>(JSFunction::kSize); |
| 1057 HInstruction* js_function = Add<HAllocate>(size, HType::JSObject(), | 1061 HInstruction* js_function = Add<HAllocate>(size, HType::JSObject(), |
| 1058 NOT_TENURED, JS_FUNCTION_TYPE); | 1062 NOT_TENURED, JS_FUNCTION_TYPE); |
| 1059 AddIncrementCounter(counters->fast_new_closure_total(), context()); | 1063 AddIncrementCounter(counters->fast_new_closure_total()); |
| 1060 | 1064 |
| 1061 int map_index = Context::FunctionMapIndex(casted_stub()->language_mode(), | 1065 int map_index = Context::FunctionMapIndex(casted_stub()->language_mode(), |
| 1062 casted_stub()->is_generator()); | 1066 casted_stub()->is_generator()); |
| 1063 | 1067 |
| 1064 // Compute the function map in the current native context and set that | 1068 // Compute the function map in the current native context and set that |
| 1065 // as the map of the allocated object. | 1069 // as the map of the allocated object. |
| 1066 HInstruction* native_context = BuildGetNativeContext(); | 1070 HInstruction* native_context = BuildGetNativeContext(); |
| 1067 HInstruction* map_slot_value = Add<HLoadNamedField>(native_context, | 1071 HInstruction* map_slot_value = Add<HLoadNamedField>(native_context, |
| 1068 HObjectAccess::ForContextSlot(map_index)); | 1072 HObjectAccess::ForContextSlot(map_index)); |
| 1069 Add<HStoreNamedField>(js_function, HObjectAccess::ForMap(), map_slot_value); | 1073 Add<HStoreNamedField>(js_function, HObjectAccess::ForMap(), map_slot_value); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1097 return js_function; | 1101 return js_function; |
| 1098 } | 1102 } |
| 1099 | 1103 |
| 1100 | 1104 |
| 1101 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { | 1105 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { |
| 1102 return DoGenerateCode(isolate, this); | 1106 return DoGenerateCode(isolate, this); |
| 1103 } | 1107 } |
| 1104 | 1108 |
| 1105 | 1109 |
| 1106 } } // namespace v8::internal | 1110 } } // namespace v8::internal |
| OLD | NEW |