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