Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: src/api.cc

Issue 98293004: Experimental scanner: support preparsing API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value)); 1649 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
1650 } 1650 }
1651 1651
1652 1652
1653 // --- S c r i p t D a t a --- 1653 // --- S c r i p t D a t a ---
1654 1654
1655 1655
1656 ScriptData* ScriptData::PreCompile(v8::Isolate* isolate, 1656 ScriptData* ScriptData::PreCompile(v8::Isolate* isolate,
1657 const char* input, 1657 const char* input,
1658 int length) { 1658 int length) {
1659 i::Utf8ToUtf16CharacterStream stream( 1659 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
1660 reinterpret_cast<const unsigned char*>(input), length); 1660 i::HandleScope handle_scope(internal_isolate);
1661 return i::PreParserApi::PreParse( 1661 i::Handle<i::String> source = internal_isolate->factory()
1662 reinterpret_cast<i::Isolate*>(isolate), &stream); 1662 ->NewStringFromAscii(i::Vector<const char>(input, length));
1663 return i::PreParserApi::PreParse(internal_isolate, source);
1663 } 1664 }
1664 1665
1665 1666
1666 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) { 1667 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
1667 i::Handle<i::String> str = Utils::OpenHandle(*source); 1668 i::Handle<i::String> str = Utils::OpenHandle(*source);
1668 i::Isolate* isolate = str->GetIsolate(); 1669 i::Isolate* isolate = str->GetIsolate();
1669 if (str->IsExternalTwoByteString()) { 1670 return i::PreParserApi::PreParse(isolate, str);
1670 i::ExternalTwoByteStringUtf16CharacterStream stream(
1671 i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length());
1672 return i::PreParserApi::PreParse(isolate, &stream);
1673 } else {
1674 i::GenericStringUtf16CharacterStream stream(str, 0, str->length());
1675 return i::PreParserApi::PreParse(isolate, &stream);
1676 }
1677 } 1671 }
1678 1672
1679 1673
1680 ScriptData* ScriptData::New(const char* data, int length) { 1674 ScriptData* ScriptData::New(const char* data, int length) {
1681 // Return an empty ScriptData if the length is obviously invalid. 1675 // Return an empty ScriptData if the length is obviously invalid.
1682 if (length % sizeof(unsigned) != 0) { 1676 if (length % sizeof(unsigned) != 0) {
1683 return new i::ScriptDataImpl(); 1677 return new i::ScriptDataImpl();
1684 } 1678 }
1685 1679
1686 // Copy the data to ensure it is properly aligned. 1680 // Copy the data to ensure it is properly aligned.
(...skipping 5932 matching lines...) Expand 10 before | Expand all | Expand 10 after
7619 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7613 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7620 Address callback_address = 7614 Address callback_address =
7621 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7615 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7622 VMState<EXTERNAL> state(isolate); 7616 VMState<EXTERNAL> state(isolate);
7623 ExternalCallbackScope call_scope(isolate, callback_address); 7617 ExternalCallbackScope call_scope(isolate, callback_address);
7624 callback(info); 7618 callback(info);
7625 } 7619 }
7626 7620
7627 7621
7628 } } // namespace v8::internal 7622 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698