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 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/api.h" | 5 #include "src/api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "src/deoptimizer.h" | 29 #include "src/deoptimizer.h" |
| 30 #include "src/execution.h" | 30 #include "src/execution.h" |
| 31 #include "src/global-handles.h" | 31 #include "src/global-handles.h" |
| 32 #include "src/heap-profiler.h" | 32 #include "src/heap-profiler.h" |
| 33 #include "src/heap-snapshot-generator-inl.h" | 33 #include "src/heap-snapshot-generator-inl.h" |
| 34 #include "src/icu_util.h" | 34 #include "src/icu_util.h" |
| 35 #include "src/json-parser.h" | 35 #include "src/json-parser.h" |
| 36 #include "src/messages.h" | 36 #include "src/messages.h" |
| 37 #include "src/natives.h" | 37 #include "src/natives.h" |
| 38 #include "src/parser.h" | 38 #include "src/parser.h" |
| 39 #include "src/pending-compilation-error-handler.h" | |
| 39 #include "src/profile-generator-inl.h" | 40 #include "src/profile-generator-inl.h" |
| 40 #include "src/property.h" | 41 #include "src/property.h" |
| 41 #include "src/property-details.h" | 42 #include "src/property-details.h" |
| 42 #include "src/prototype.h" | 43 #include "src/prototype.h" |
| 43 #include "src/runtime/runtime.h" | 44 #include "src/runtime/runtime.h" |
| 44 #include "src/runtime-profiler.h" | 45 #include "src/runtime-profiler.h" |
| 45 #include "src/sampler.h" | 46 #include "src/sampler.h" |
| 46 #include "src/scanner-character-streams.h" | 47 #include "src/scanner-character-streams.h" |
| 47 #include "src/simulator.h" | 48 #include "src/simulator.h" |
| 48 #include "src/snapshot.h" | 49 #include "src/snapshot.h" |
| (...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1483 ScriptCompiler::StreamedSource::GetCachedData() const { | 1484 ScriptCompiler::StreamedSource::GetCachedData() const { |
| 1484 return impl_->cached_data.get(); | 1485 return impl_->cached_data.get(); |
| 1485 } | 1486 } |
| 1486 | 1487 |
| 1487 | 1488 |
| 1488 Local<Script> UnboundScript::BindToCurrentContext() { | 1489 Local<Script> UnboundScript::BindToCurrentContext() { |
| 1489 i::Handle<i::HeapObject> obj = | 1490 i::Handle<i::HeapObject> obj = |
| 1490 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); | 1491 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); |
| 1491 i::Handle<i::SharedFunctionInfo> | 1492 i::Handle<i::SharedFunctionInfo> |
| 1492 function_info(i::SharedFunctionInfo::cast(*obj), obj->GetIsolate()); | 1493 function_info(i::SharedFunctionInfo::cast(*obj), obj->GetIsolate()); |
| 1494 i::Isolate* isolate = obj->GetIsolate(); | |
| 1495 | |
| 1496 i::ScopeInfo* scope_info = function_info->scope_info(); | |
| 1497 i::Handle<i::JSReceiver> global(isolate->native_context()->global_object()); | |
| 1498 for (int i = 0; i < scope_info->StrongModeFreeVariableCount(); ++i) { | |
| 1499 i::Handle<i::Name> name(scope_info->StrongModeFreeVariableName(i)); | |
| 1500 Maybe<bool> has = i::JSReceiver::HasOwnProperty(global, name); | |
|
Dmitry Lomov (no reviews)
2015/03/24 10:16:24
Why only own properties?
Also use ScriptCongtextTa
marja
2015/03/24 14:20:05
Done.
| |
| 1501 if (has.IsJust() && !has.FromJust()) { | |
| 1502 i::PendingCompilationErrorHandler pending_error_handler_; | |
| 1503 pending_error_handler_.ReportMessageAt( | |
| 1504 // FIXME: location | |
| 1505 0, 0, "strong_unbound_global", reinterpret_cast<const char*>(NULL), | |
| 1506 i::kReferenceError); | |
| 1507 i::Handle<i::Script> script(i::Script::cast(function_info->script())); | |
| 1508 pending_error_handler_.ThrowPendingError(isolate, script); | |
| 1509 isolate->ReportPendingMessages(); | |
| 1510 isolate->OptionalRescheduleException(true); | |
| 1511 return Local<Script>(); | |
| 1512 } | |
| 1513 } | |
| 1493 i::Handle<i::JSFunction> function = | 1514 i::Handle<i::JSFunction> function = |
| 1494 obj->GetIsolate()->factory()->NewFunctionFromSharedFunctionInfo( | 1515 obj->GetIsolate()->factory()->NewFunctionFromSharedFunctionInfo( |
| 1495 function_info, obj->GetIsolate()->native_context()); | 1516 function_info, isolate->native_context()); |
| 1496 return ToApiHandle<Script>(function); | 1517 return ToApiHandle<Script>(function); |
| 1497 } | 1518 } |
| 1498 | 1519 |
| 1499 | 1520 |
| 1500 int UnboundScript::GetId() { | 1521 int UnboundScript::GetId() { |
| 1501 i::Handle<i::HeapObject> obj = | 1522 i::Handle<i::HeapObject> obj = |
| 1502 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); | 1523 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); |
| 1503 i::Isolate* isolate = obj->GetIsolate(); | 1524 i::Isolate* isolate = obj->GetIsolate(); |
| 1504 LOG_API(isolate, "v8::UnboundScript::GetId"); | 1525 LOG_API(isolate, "v8::UnboundScript::GetId"); |
| 1505 i::HandleScope scope(isolate); | 1526 i::HandleScope scope(isolate); |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1933 if (has_pending_exception) isolate->ReportPendingMessages(); | 1954 if (has_pending_exception) isolate->ReportPendingMessages(); |
| 1934 RETURN_ON_FAILED_EXECUTION(Script); | 1955 RETURN_ON_FAILED_EXECUTION(Script); |
| 1935 | 1956 |
| 1936 source->info->clear_script(); // because script goes out of scope. | 1957 source->info->clear_script(); // because script goes out of scope. |
| 1937 raw_result = *result; // TODO(titzer): use CloseAndEscape? | 1958 raw_result = *result; // TODO(titzer): use CloseAndEscape? |
| 1938 } | 1959 } |
| 1939 | 1960 |
| 1940 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); | 1961 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); |
| 1941 Local<UnboundScript> generic = ToApiHandle<UnboundScript>(result); | 1962 Local<UnboundScript> generic = ToApiHandle<UnboundScript>(result); |
| 1942 if (generic.IsEmpty()) return Local<Script>(); | 1963 if (generic.IsEmpty()) return Local<Script>(); |
| 1943 RETURN_ESCAPED(generic->BindToCurrentContext()); | 1964 Local<Script> bound = generic->BindToCurrentContext(); |
| 1965 if (bound.IsEmpty()) return Local<Script>(); | |
| 1966 RETURN_ESCAPED(bound); | |
| 1944 } | 1967 } |
| 1945 | 1968 |
| 1946 | 1969 |
| 1947 Local<Script> ScriptCompiler::Compile(Isolate* v8_isolate, | 1970 Local<Script> ScriptCompiler::Compile(Isolate* v8_isolate, |
| 1948 StreamedSource* v8_source, | 1971 StreamedSource* v8_source, |
| 1949 Handle<String> full_source_string, | 1972 Handle<String> full_source_string, |
| 1950 const ScriptOrigin& origin) { | 1973 const ScriptOrigin& origin) { |
| 1951 auto context = v8_isolate->GetCurrentContext(); | 1974 auto context = v8_isolate->GetCurrentContext(); |
| 1952 RETURN_TO_LOCAL_UNCHECKED( | 1975 RETURN_TO_LOCAL_UNCHECKED( |
| 1953 Compile(context, v8_source, full_source_string, origin), Script); | 1976 Compile(context, v8_source, full_source_string, origin), Script); |
| (...skipping 6062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8016 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8039 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 8017 Address callback_address = | 8040 Address callback_address = |
| 8018 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8041 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8019 VMState<EXTERNAL> state(isolate); | 8042 VMState<EXTERNAL> state(isolate); |
| 8020 ExternalCallbackScope call_scope(isolate, callback_address); | 8043 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8021 callback(info); | 8044 callback(info); |
| 8022 } | 8045 } |
| 8023 | 8046 |
| 8024 | 8047 |
| 8025 } } // namespace v8::internal | 8048 } } // namespace v8::internal |
| OLD | NEW |