| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 Accessors::FunctionSetPrototype(*function, | 254 Accessors::FunctionSetPrototype(*function, |
| 255 *prototype, | 255 *prototype, |
| 256 NULL), | 256 NULL), |
| 257 Object); | 257 Object); |
| 258 } | 258 } |
| 259 | 259 |
| 260 | 260 |
| 261 Handle<Object> SetProperty(Handle<JSObject> object, | 261 Handle<Object> SetProperty(Handle<JSObject> object, |
| 262 Handle<String> key, | 262 Handle<String> key, |
| 263 Handle<Object> value, | 263 Handle<Object> value, |
| 264 PropertyAttributes attributes) { | 264 PropertyAttributes attributes, |
| 265 StrictModeFlag strict) { |
| 265 CALL_HEAP_FUNCTION(object->GetHeap()->isolate(), | 266 CALL_HEAP_FUNCTION(object->GetHeap()->isolate(), |
| 266 object->SetProperty(*key, *value, attributes), Object); | 267 object->SetProperty(*key, *value, attributes, strict), |
| 268 Object); |
| 267 } | 269 } |
| 268 | 270 |
| 269 | 271 |
| 270 Handle<Object> SetProperty(Handle<Object> object, | 272 Handle<Object> SetProperty(Handle<Object> object, |
| 271 Handle<Object> key, | 273 Handle<Object> key, |
| 272 Handle<Object> value, | 274 Handle<Object> value, |
| 273 PropertyAttributes attributes) { | 275 PropertyAttributes attributes, |
| 276 StrictModeFlag strict) { |
| 274 Isolate* isolate = Isolate::Current(); | 277 Isolate* isolate = Isolate::Current(); |
| 275 CALL_HEAP_FUNCTION( | 278 CALL_HEAP_FUNCTION( |
| 276 isolate, | 279 isolate, |
| 277 Runtime::SetObjectProperty(isolate, object, key, value, attributes), | 280 Runtime::SetObjectProperty( |
| 281 isolate, object, key, value, attributes, strict), |
| 278 Object); | 282 Object); |
| 279 } | 283 } |
| 280 | 284 |
| 281 | 285 |
| 282 Handle<Object> ForceSetProperty(Handle<JSObject> object, | 286 Handle<Object> ForceSetProperty(Handle<JSObject> object, |
| 283 Handle<Object> key, | 287 Handle<Object> key, |
| 284 Handle<Object> value, | 288 Handle<Object> value, |
| 285 PropertyAttributes attributes) { | 289 PropertyAttributes attributes) { |
| 286 Isolate* isolate = object->GetIsolate(); | 290 Isolate* isolate = object->GetIsolate(); |
| 287 CALL_HEAP_FUNCTION( | 291 CALL_HEAP_FUNCTION( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 315 Handle<String> key, | 319 Handle<String> key, |
| 316 Handle<Object> value, | 320 Handle<Object> value, |
| 317 PropertyAttributes attributes) { | 321 PropertyAttributes attributes) { |
| 318 CALL_HEAP_FUNCTION( | 322 CALL_HEAP_FUNCTION( |
| 319 object->GetIsolate(), | 323 object->GetIsolate(), |
| 320 object->SetLocalPropertyIgnoreAttributes(*key, *value, attributes), | 324 object->SetLocalPropertyIgnoreAttributes(*key, *value, attributes), |
| 321 Object); | 325 Object); |
| 322 } | 326 } |
| 323 | 327 |
| 324 | 328 |
| 329 void SetLocalPropertyNoThrow(Handle<JSObject> object, |
| 330 Handle<String> key, |
| 331 Handle<Object> value, |
| 332 PropertyAttributes attributes) { |
| 333 ASSERT(!object->GetIsolate()->has_pending_exception()); |
| 334 CHECK(!SetLocalPropertyIgnoreAttributes( |
| 335 object, key, value, attributes).is_null()); |
| 336 CHECK(!object->GetIsolate()->has_pending_exception()); |
| 337 } |
| 338 |
| 339 |
| 325 Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object, | 340 Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object, |
| 326 Handle<String> key, | 341 Handle<String> key, |
| 327 Handle<Object> value, | 342 Handle<Object> value, |
| 328 PropertyAttributes attributes) { | 343 PropertyAttributes attributes, |
| 344 StrictModeFlag strict) { |
| 329 CALL_HEAP_FUNCTION(object->GetIsolate(), | 345 CALL_HEAP_FUNCTION(object->GetIsolate(), |
| 330 object->SetPropertyWithInterceptor(*key, | 346 object->SetPropertyWithInterceptor(*key, |
| 331 *value, | 347 *value, |
| 332 attributes), | 348 attributes, |
| 349 strict), |
| 333 Object); | 350 Object); |
| 334 } | 351 } |
| 335 | 352 |
| 336 | 353 |
| 337 Handle<Object> GetProperty(Handle<JSObject> obj, | 354 Handle<Object> GetProperty(Handle<JSObject> obj, |
| 338 const char* name) { | 355 const char* name) { |
| 339 Isolate* isolate = obj->GetIsolate(); | 356 Isolate* isolate = obj->GetIsolate(); |
| 340 Handle<String> str = isolate->factory()->LookupAsciiSymbol(name); | 357 Handle<String> str = isolate->factory()->LookupAsciiSymbol(name); |
| 341 CALL_HEAP_FUNCTION(isolate, obj->GetProperty(*str), Object); | 358 CALL_HEAP_FUNCTION(isolate, obj->GetProperty(*str), Object); |
| 342 } | 359 } |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 } | 907 } |
| 891 | 908 |
| 892 | 909 |
| 893 bool CompileLazyShared(Handle<SharedFunctionInfo> shared, | 910 bool CompileLazyShared(Handle<SharedFunctionInfo> shared, |
| 894 ClearExceptionFlag flag) { | 911 ClearExceptionFlag flag) { |
| 895 CompilationInfo info(shared); | 912 CompilationInfo info(shared); |
| 896 return CompileLazyHelper(&info, flag); | 913 return CompileLazyHelper(&info, flag); |
| 897 } | 914 } |
| 898 | 915 |
| 899 | 916 |
| 900 bool CompileLazy(Handle<JSFunction> function, | 917 static bool CompileLazyFunction(Handle<JSFunction> function, |
| 901 ClearExceptionFlag flag) { | 918 ClearExceptionFlag flag, |
| 919 InLoopFlag in_loop_flag) { |
| 902 bool result = true; | 920 bool result = true; |
| 903 if (function->shared()->is_compiled()) { | 921 if (function->shared()->is_compiled()) { |
| 904 function->ReplaceCode(function->shared()->code()); | 922 function->ReplaceCode(function->shared()->code()); |
| 905 function->shared()->set_code_age(0); | 923 function->shared()->set_code_age(0); |
| 906 } else { | 924 } else { |
| 907 CompilationInfo info(function); | 925 CompilationInfo info(function); |
| 926 if (in_loop_flag == IN_LOOP) info.MarkAsInLoop(); |
| 908 result = CompileLazyHelper(&info, flag); | 927 result = CompileLazyHelper(&info, flag); |
| 909 ASSERT(!result || function->is_compiled()); | 928 ASSERT(!result || function->is_compiled()); |
| 910 } | 929 } |
| 911 if (result && function->is_compiled()) { | |
| 912 PROFILE(FunctionCreateEvent(*function)); | |
| 913 } | |
| 914 return result; | 930 return result; |
| 915 } | 931 } |
| 916 | 932 |
| 917 | 933 |
| 918 bool CompileLazyInLoop(Handle<JSFunction> function, | 934 bool CompileLazy(Handle<JSFunction> function, |
| 919 ClearExceptionFlag flag) { | 935 ClearExceptionFlag flag) { |
| 920 bool result = true; | 936 return CompileLazyFunction(function, flag, NOT_IN_LOOP); |
| 921 if (function->shared()->is_compiled()) { | |
| 922 function->ReplaceCode(function->shared()->code()); | |
| 923 function->shared()->set_code_age(0); | |
| 924 } else { | |
| 925 CompilationInfo info(function); | |
| 926 info.MarkAsInLoop(); | |
| 927 result = CompileLazyHelper(&info, flag); | |
| 928 ASSERT(!result || function->is_compiled()); | |
| 929 } | |
| 930 if (result && function->is_compiled()) { | |
| 931 PROFILE(FunctionCreateEvent(*function)); | |
| 932 } | |
| 933 return result; | |
| 934 } | 937 } |
| 935 | 938 |
| 936 | 939 |
| 937 bool CompileOptimized(Handle<JSFunction> function, int osr_ast_id) { | 940 bool CompileLazyInLoop(Handle<JSFunction> function, |
| 938 CompilationInfo info(function); | 941 ClearExceptionFlag flag) { |
| 939 info.SetOptimizing(osr_ast_id); | 942 return CompileLazyFunction(function, flag, IN_LOOP); |
| 940 bool result = CompileLazyHelper(&info, KEEP_EXCEPTION); | |
| 941 if (result) PROFILE(FunctionCreateEvent(*function)); | |
| 942 return result; | |
| 943 } | 943 } |
| 944 | 944 |
| 945 | 945 |
| 946 bool CompileOptimized(Handle<JSFunction> function, |
| 947 int osr_ast_id, |
| 948 ClearExceptionFlag flag) { |
| 949 CompilationInfo info(function); |
| 950 info.SetOptimizing(osr_ast_id); |
| 951 return CompileLazyHelper(&info, flag); |
| 952 } |
| 953 |
| 954 |
| 946 OptimizedObjectForAddingMultipleProperties:: | 955 OptimizedObjectForAddingMultipleProperties:: |
| 947 OptimizedObjectForAddingMultipleProperties(Handle<JSObject> object, | 956 OptimizedObjectForAddingMultipleProperties(Handle<JSObject> object, |
| 948 int expected_additional_properties, | 957 int expected_additional_properties, |
| 949 bool condition) { | 958 bool condition) { |
| 950 object_ = object; | 959 object_ = object; |
| 951 if (condition && object_->HasFastProperties() && !object->IsJSGlobalProxy()) { | 960 if (condition && object_->HasFastProperties() && !object->IsJSGlobalProxy()) { |
| 952 // Normalize the properties of object to avoid n^2 behavior | 961 // Normalize the properties of object to avoid n^2 behavior |
| 953 // when extending the object multiple properties. Indicate the number of | 962 // when extending the object multiple properties. Indicate the number of |
| 954 // properties to be added. | 963 // properties to be added. |
| 955 unused_property_fields_ = object->map()->unused_property_fields(); | 964 unused_property_fields_ = object->map()->unused_property_fields(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 966 | 975 |
| 967 OptimizedObjectForAddingMultipleProperties:: | 976 OptimizedObjectForAddingMultipleProperties:: |
| 968 ~OptimizedObjectForAddingMultipleProperties() { | 977 ~OptimizedObjectForAddingMultipleProperties() { |
| 969 // Reoptimize the object to allow fast property access. | 978 // Reoptimize the object to allow fast property access. |
| 970 if (has_been_transformed_) { | 979 if (has_been_transformed_) { |
| 971 TransformToFastProperties(object_, unused_property_fields_); | 980 TransformToFastProperties(object_, unused_property_fields_); |
| 972 } | 981 } |
| 973 } | 982 } |
| 974 | 983 |
| 975 } } // namespace v8::internal | 984 } } // namespace v8::internal |
| OLD | NEW |