Chromium Code Reviews| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 } | 359 } |
| 360 | 360 |
| 361 | 361 |
| 362 Handle<JSValue> GetScriptWrapper(Handle<Script> script) { | 362 Handle<JSValue> GetScriptWrapper(Handle<Script> script) { |
| 363 if (script->wrapper()->foreign_address() != NULL) { | 363 if (script->wrapper()->foreign_address() != NULL) { |
| 364 // Return the script wrapper directly from the cache. | 364 // Return the script wrapper directly from the cache. |
| 365 return Handle<JSValue>( | 365 return Handle<JSValue>( |
| 366 reinterpret_cast<JSValue**>(script->wrapper()->foreign_address())); | 366 reinterpret_cast<JSValue**>(script->wrapper()->foreign_address())); |
| 367 } | 367 } |
| 368 Isolate* isolate = script->GetIsolate(); | 368 Isolate* isolate = script->GetIsolate(); |
| 369 if (!isolate->IsInitialized()) { | |
|
yurys
2013/06/11 11:23:06
Can we move this check to Logger::LogExistingFunct
| |
| 370 return Handle<JSValue>(); | |
| 371 } | |
| 369 // Construct a new script wrapper. | 372 // Construct a new script wrapper. |
| 370 isolate->counters()->script_wrappers()->Increment(); | 373 isolate->counters()->script_wrappers()->Increment(); |
| 371 Handle<JSFunction> constructor = isolate->script_function(); | 374 Handle<JSFunction> constructor = isolate->script_function(); |
| 372 Handle<JSValue> result = | 375 Handle<JSValue> result = |
| 373 Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor)); | 376 Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor)); |
| 374 | 377 |
| 375 // The allocation might have triggered a GC, which could have called this | 378 // The allocation might have triggered a GC, which could have called this |
| 376 // function recursively, and a wrapper has already been created and cached. | 379 // function recursively, and a wrapper has already been created and cached. |
| 377 // In that case, simply return the cached wrapper. | 380 // In that case, simply return the cached wrapper. |
| 378 if (script->wrapper()->foreign_address() != NULL) { | 381 if (script->wrapper()->foreign_address() != NULL) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 return result; | 597 return result; |
| 595 } | 598 } |
| 596 | 599 |
| 597 | 600 |
| 598 Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) { | 601 Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) { |
| 599 Isolate* isolate = script->GetIsolate(); | 602 Isolate* isolate = script->GetIsolate(); |
| 600 Handle<String> name_or_source_url_key = | 603 Handle<String> name_or_source_url_key = |
| 601 isolate->factory()->InternalizeOneByteString( | 604 isolate->factory()->InternalizeOneByteString( |
| 602 STATIC_ASCII_VECTOR("nameOrSourceURL")); | 605 STATIC_ASCII_VECTOR("nameOrSourceURL")); |
| 603 Handle<JSValue> script_wrapper = GetScriptWrapper(script); | 606 Handle<JSValue> script_wrapper = GetScriptWrapper(script); |
| 607 if (script_wrapper.is_null()) { | |
| 608 return isolate->factory()->undefined_value(); | |
| 609 } | |
| 604 Handle<Object> property = GetProperty(isolate, | 610 Handle<Object> property = GetProperty(isolate, |
| 605 script_wrapper, | 611 script_wrapper, |
| 606 name_or_source_url_key); | 612 name_or_source_url_key); |
| 607 ASSERT(property->IsJSFunction()); | 613 Handle<Object> result; |
| 608 Handle<JSFunction> method = Handle<JSFunction>::cast(property); | 614 if (property->IsJSFunction()) { |
|
yurys
2013/06/11 11:23:06
How can it happen? We should be checking for is_bo
| |
| 609 bool caught_exception; | 615 Handle<JSFunction> method = Handle<JSFunction>::cast(property); |
| 610 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0, | 616 bool caught_exception; |
| 611 NULL, &caught_exception); | 617 result = Execution::TryCall(method, script_wrapper, 0, |
| 612 if (caught_exception) { | 618 NULL, &caught_exception); |
| 619 if (caught_exception) { | |
| 620 result = isolate->factory()->undefined_value(); | |
| 621 } | |
| 622 } else { | |
| 613 result = isolate->factory()->undefined_value(); | 623 result = isolate->factory()->undefined_value(); |
| 614 } | 624 } |
| 615 return result; | 625 return result; |
| 616 } | 626 } |
| 617 | 627 |
| 618 | 628 |
| 619 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) { | 629 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) { |
| 620 int len = array->length(); | 630 int len = array->length(); |
| 621 for (int i = 0; i < len; i++) { | 631 for (int i = 0; i < len; i++) { |
| 622 Object* e = array->get(i); | 632 Object* e = array->get(i); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 data->next = prev_next_; | 932 data->next = prev_next_; |
| 923 data->limit = prev_limit_; | 933 data->limit = prev_limit_; |
| 924 #ifdef DEBUG | 934 #ifdef DEBUG |
| 925 handles_detached_ = true; | 935 handles_detached_ = true; |
| 926 #endif | 936 #endif |
| 927 return deferred; | 937 return deferred; |
| 928 } | 938 } |
| 929 | 939 |
| 930 | 940 |
| 931 } } // namespace v8::internal | 941 } } // namespace v8::internal |
| OLD | NEW |