OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 | 227 |
228 Handle<Object> args[] = { receiver, name }; | 228 Handle<Object> args[] = { receiver, name }; |
229 Handle<Object> result = CallTrap( | 229 Handle<Object> result = CallTrap( |
230 "get", isolate->derived_get_trap(), ARRAY_SIZE(args), args); | 230 "get", isolate->derived_get_trap(), ARRAY_SIZE(args), args); |
231 if (isolate->has_pending_exception()) return Failure::Exception(); | 231 if (isolate->has_pending_exception()) return Failure::Exception(); |
232 | 232 |
233 return *result; | 233 return *result; |
234 } | 234 } |
235 | 235 |
236 | 236 |
237 Handle<Object> Object::GetElement(Handle<Object> object, uint32_t index) { | |
238 Isolate* isolate = object->IsHeapObject() | |
239 ? Handle<HeapObject>::cast(object)->GetIsolate() | |
240 : Isolate::Current(); | |
241 CALL_HEAP_FUNCTION(isolate, object->GetElement(index), Object); | |
242 } | |
243 | |
244 | |
237 MaybeObject* JSProxy::GetElementWithHandler(Object* receiver, | 245 MaybeObject* JSProxy::GetElementWithHandler(Object* receiver, |
238 uint32_t index) { | 246 uint32_t index) { |
239 String* name; | 247 String* name; |
240 MaybeObject* maybe = GetHeap()->Uint32ToString(index); | 248 MaybeObject* maybe = GetHeap()->Uint32ToString(index); |
241 if (!maybe->To<String>(&name)) return maybe; | 249 if (!maybe->To<String>(&name)) return maybe; |
242 return GetPropertyWithHandler(receiver, name); | 250 return GetPropertyWithHandler(receiver, name); |
243 } | 251 } |
244 | 252 |
245 | 253 |
246 MaybeObject* JSProxy::SetElementWithHandler(uint32_t index, | 254 MaybeObject* JSProxy::SetElementWithHandler(uint32_t index, |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 if (!fun->shared()->IsApiFunction()) | 529 if (!fun->shared()->IsApiFunction()) |
522 return true; | 530 return true; |
523 // If the object is fully fast case and has the same map it was | 531 // If the object is fully fast case and has the same map it was |
524 // created with then no changes can have been made to it. | 532 // created with then no changes can have been made to it. |
525 return map() != fun->initial_map() | 533 return map() != fun->initial_map() |
526 || !HasFastElements() | 534 || !HasFastElements() |
527 || !HasFastProperties(); | 535 || !HasFastProperties(); |
528 } | 536 } |
529 | 537 |
530 | 538 |
531 Handle<Object> Object::GetProperty(Isolate* isolate, | 539 Handle<Object> Object::GetProperty(Handle<Object> object, |
Kevin Millikin (Chromium)
2011/10/19 07:20:30
I can't decide if I like the isolate argument or n
ulan
2011/10/19 08:48:12
We are using an implicit invariant that the 'isola
| |
532 Handle<Object> object, | |
533 Handle<Object> receiver, | 540 Handle<Object> receiver, |
534 LookupResult* result, | 541 LookupResult* result, |
535 Handle<String> key, | 542 Handle<String> key, |
536 PropertyAttributes* attributes) { | 543 PropertyAttributes* attributes) { |
544 Isolate* isolate = object->IsHeapObject() | |
545 ? Handle<HeapObject>::cast(object)->GetIsolate() | |
546 : Isolate::Current(); | |
537 CALL_HEAP_FUNCTION( | 547 CALL_HEAP_FUNCTION( |
538 isolate, | 548 isolate, |
539 object->GetProperty(*receiver, result, *key, attributes), | 549 object->GetProperty(*receiver, result, *key, attributes), |
540 Object); | 550 Object); |
541 } | 551 } |
542 | 552 |
543 | 553 |
544 MaybeObject* Object::GetProperty(Object* receiver, | 554 MaybeObject* Object::GetProperty(Object* receiver, |
545 LookupResult* result, | 555 LookupResult* result, |
546 String* name, | 556 String* name, |
(...skipping 6387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6934 | 6944 |
6935 void JSFunction::MarkForLazyRecompilation() { | 6945 void JSFunction::MarkForLazyRecompilation() { |
6936 ASSERT(is_compiled() && !IsOptimized()); | 6946 ASSERT(is_compiled() && !IsOptimized()); |
6937 ASSERT(shared()->allows_lazy_compilation() || | 6947 ASSERT(shared()->allows_lazy_compilation() || |
6938 code()->optimizable()); | 6948 code()->optimizable()); |
6939 Builtins* builtins = GetIsolate()->builtins(); | 6949 Builtins* builtins = GetIsolate()->builtins(); |
6940 ReplaceCode(builtins->builtin(Builtins::kLazyRecompile)); | 6950 ReplaceCode(builtins->builtin(Builtins::kLazyRecompile)); |
6941 } | 6951 } |
6942 | 6952 |
6943 | 6953 |
6954 bool SharedFunctionInfo::EnsureCompiled(Handle<SharedFunctionInfo> shared, | |
6955 ClearExceptionFlag flag) { | |
6956 return shared->is_compiled() || CompileLazy(shared, flag); | |
6957 } | |
6958 | |
6959 | |
6960 static bool CompileLazyHelper(CompilationInfo* info, | |
6961 ClearExceptionFlag flag) { | |
6962 // Compile the source information to a code object. | |
6963 ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled()); | |
6964 ASSERT(!info->isolate()->has_pending_exception()); | |
6965 bool result = Compiler::CompileLazy(info); | |
6966 ASSERT(result != Isolate::Current()->has_pending_exception()); | |
6967 if (!result && flag == CLEAR_EXCEPTION) { | |
6968 info->isolate()->clear_pending_exception(); | |
6969 } | |
6970 return result; | |
6971 } | |
6972 | |
6973 | |
6974 bool SharedFunctionInfo::CompileLazy(Handle<SharedFunctionInfo> shared, | |
6975 ClearExceptionFlag flag) { | |
6976 CompilationInfo info(shared); | |
6977 return CompileLazyHelper(&info, flag); | |
6978 } | |
6979 | |
6980 | |
6981 bool JSFunction::CompileLazy(Handle<JSFunction> function, | |
6982 ClearExceptionFlag flag) { | |
6983 bool result = true; | |
6984 if (function->shared()->is_compiled()) { | |
6985 function->ReplaceCode(function->shared()->code()); | |
6986 function->shared()->set_code_age(0); | |
6987 } else { | |
6988 CompilationInfo info(function); | |
6989 result = CompileLazyHelper(&info, flag); | |
6990 ASSERT(!result || function->is_compiled()); | |
6991 } | |
6992 return result; | |
6993 } | |
6994 | |
6995 | |
6996 bool JSFunction::CompileOptimized(Handle<JSFunction> function, | |
6997 int osr_ast_id, | |
6998 ClearExceptionFlag flag) { | |
6999 CompilationInfo info(function); | |
7000 info.SetOptimizing(osr_ast_id); | |
7001 return CompileLazyHelper(&info, flag); | |
7002 } | |
7003 | |
7004 | |
6944 bool JSFunction::IsInlineable() { | 7005 bool JSFunction::IsInlineable() { |
6945 if (IsBuiltin()) return false; | 7006 if (IsBuiltin()) return false; |
6946 SharedFunctionInfo* shared_info = shared(); | 7007 SharedFunctionInfo* shared_info = shared(); |
6947 // Check that the function has a script associated with it. | 7008 // Check that the function has a script associated with it. |
6948 if (!shared_info->script()->IsScript()) return false; | 7009 if (!shared_info->script()->IsScript()) return false; |
6949 if (shared_info->optimization_disabled()) return false; | 7010 if (shared_info->optimization_disabled()) return false; |
6950 Code* code = shared_info->code(); | 7011 Code* code = shared_info->code(); |
6951 if (code->kind() == Code::OPTIMIZED_FUNCTION) return true; | 7012 if (code->kind() == Code::OPTIMIZED_FUNCTION) return true; |
6952 // If we never ran this (unlikely) then lets try to optimize it. | 7013 // If we never ran this (unlikely) then lets try to optimize it. |
6953 if (code->kind() != Code::FUNCTION) return true; | 7014 if (code->kind() != Code::FUNCTION) return true; |
(...skipping 5384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12338 if (break_point_objects()->IsUndefined()) return 0; | 12399 if (break_point_objects()->IsUndefined()) return 0; |
12339 // Single break point. | 12400 // Single break point. |
12340 if (!break_point_objects()->IsFixedArray()) return 1; | 12401 if (!break_point_objects()->IsFixedArray()) return 1; |
12341 // Multiple break points. | 12402 // Multiple break points. |
12342 return FixedArray::cast(break_point_objects())->length(); | 12403 return FixedArray::cast(break_point_objects())->length(); |
12343 } | 12404 } |
12344 #endif // ENABLE_DEBUGGER_SUPPORT | 12405 #endif // ENABLE_DEBUGGER_SUPPORT |
12345 | 12406 |
12346 | 12407 |
12347 } } // namespace v8::internal | 12408 } } // namespace v8::internal |
OLD | NEW |