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 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 | 1449 |
1450 | 1450 |
1451 Local<Script> Script::New(v8::Handle<String> source, | 1451 Local<Script> Script::New(v8::Handle<String> source, |
1452 v8::ScriptOrigin* origin, | 1452 v8::ScriptOrigin* origin, |
1453 v8::ScriptData* pre_data, | 1453 v8::ScriptData* pre_data, |
1454 v8::Handle<String> script_data) { | 1454 v8::Handle<String> script_data) { |
1455 i::Isolate* isolate = i::Isolate::Current(); | 1455 i::Isolate* isolate = i::Isolate::Current(); |
1456 ON_BAILOUT(isolate, "v8::Script::New()", return Local<Script>()); | 1456 ON_BAILOUT(isolate, "v8::Script::New()", return Local<Script>()); |
1457 LOG_API(isolate, "Script::New"); | 1457 LOG_API(isolate, "Script::New"); |
1458 ENTER_V8(isolate); | 1458 ENTER_V8(isolate); |
1459 i::Handle<i::String> str = Utils::OpenHandle(*source); | 1459 i::SharedFunctionInfo* raw_result = NULL; |
1460 i::Handle<i::Object> name_obj; | 1460 { i::HandleScope scope(isolate); |
1461 int line_offset = 0; | 1461 i::Handle<i::String> str = Utils::OpenHandle(*source); |
1462 int column_offset = 0; | 1462 i::Handle<i::Object> name_obj; |
1463 if (origin != NULL) { | 1463 int line_offset = 0; |
1464 if (!origin->ResourceName().IsEmpty()) { | 1464 int column_offset = 0; |
1465 name_obj = Utils::OpenHandle(*origin->ResourceName()); | 1465 if (origin != NULL) { |
| 1466 if (!origin->ResourceName().IsEmpty()) { |
| 1467 name_obj = Utils::OpenHandle(*origin->ResourceName()); |
| 1468 } |
| 1469 if (!origin->ResourceLineOffset().IsEmpty()) { |
| 1470 line_offset = static_cast<int>(origin->ResourceLineOffset()->Value()); |
| 1471 } |
| 1472 if (!origin->ResourceColumnOffset().IsEmpty()) { |
| 1473 column_offset = |
| 1474 static_cast<int>(origin->ResourceColumnOffset()->Value()); |
| 1475 } |
1466 } | 1476 } |
1467 if (!origin->ResourceLineOffset().IsEmpty()) { | 1477 EXCEPTION_PREAMBLE(isolate); |
1468 line_offset = static_cast<int>(origin->ResourceLineOffset()->Value()); | 1478 i::ScriptDataImpl* pre_data_impl = |
| 1479 static_cast<i::ScriptDataImpl*>(pre_data); |
| 1480 // We assert that the pre-data is sane, even though we can actually |
| 1481 // handle it if it turns out not to be in release mode. |
| 1482 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck()); |
| 1483 // If the pre-data isn't sane we simply ignore it |
| 1484 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) { |
| 1485 pre_data_impl = NULL; |
1469 } | 1486 } |
1470 if (!origin->ResourceColumnOffset().IsEmpty()) { | 1487 i::Handle<i::SharedFunctionInfo> result = |
1471 column_offset = static_cast<int>(origin->ResourceColumnOffset()->Value()); | |
1472 } | |
1473 } | |
1474 EXCEPTION_PREAMBLE(isolate); | |
1475 i::ScriptDataImpl* pre_data_impl = static_cast<i::ScriptDataImpl*>(pre_data); | |
1476 // We assert that the pre-data is sane, even though we can actually | |
1477 // handle it if it turns out not to be in release mode. | |
1478 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck()); | |
1479 // If the pre-data isn't sane we simply ignore it | |
1480 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) { | |
1481 pre_data_impl = NULL; | |
1482 } | |
1483 i::Handle<i::SharedFunctionInfo> result = | |
1484 i::Compiler::Compile(str, | 1488 i::Compiler::Compile(str, |
1485 name_obj, | 1489 name_obj, |
1486 line_offset, | 1490 line_offset, |
1487 column_offset, | 1491 column_offset, |
1488 NULL, | 1492 NULL, |
1489 pre_data_impl, | 1493 pre_data_impl, |
1490 Utils::OpenHandle(*script_data), | 1494 Utils::OpenHandle(*script_data), |
1491 i::NOT_NATIVES_CODE); | 1495 i::NOT_NATIVES_CODE); |
1492 has_pending_exception = result.is_null(); | 1496 has_pending_exception = result.is_null(); |
1493 EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>()); | 1497 EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>()); |
| 1498 raw_result = *result; |
| 1499 } |
| 1500 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); |
1494 return Local<Script>(ToApi<Script>(result)); | 1501 return Local<Script>(ToApi<Script>(result)); |
1495 } | 1502 } |
1496 | 1503 |
1497 | 1504 |
1498 Local<Script> Script::New(v8::Handle<String> source, | 1505 Local<Script> Script::New(v8::Handle<String> source, |
1499 v8::Handle<Value> file_name) { | 1506 v8::Handle<Value> file_name) { |
1500 ScriptOrigin origin(file_name); | 1507 ScriptOrigin origin(file_name); |
1501 return New(source, &origin); | 1508 return New(source, &origin); |
1502 } | 1509 } |
1503 | 1510 |
(...skipping 4582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6086 | 6093 |
6087 | 6094 |
6088 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6095 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
6089 HandleScopeImplementer* scope_implementer = | 6096 HandleScopeImplementer* scope_implementer = |
6090 reinterpret_cast<HandleScopeImplementer*>(storage); | 6097 reinterpret_cast<HandleScopeImplementer*>(storage); |
6091 scope_implementer->IterateThis(v); | 6098 scope_implementer->IterateThis(v); |
6092 return storage + ArchiveSpacePerThread(); | 6099 return storage + ArchiveSpacePerThread(); |
6093 } | 6100 } |
6094 | 6101 |
6095 } } // namespace v8::internal | 6102 } } // namespace v8::internal |
OLD | NEW |